-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
Is there a way to define global hotkeys, i.e. that work when other programs are in focus?
Thx
Dieter
Thx
Dieter
-
- VIP Member
- Posts: 204
- Joined: 16 Oct 2001 23:01
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotekeys
Accelerators are only local to the program, no? They do not work if I am in another program, for instance a browser, as far as I can tell?
-
- VIP Member
- Posts: 204
- Joined: 16 Oct 2001 23:01
Sorry, I did not read your first post correctly.
So you want to press F5 from a browser like IE (or from Excel or Word) to start an action in your VP7 application : is it what you want to do ?
Maybe look at gui_Native::registerHotKey + http://discuss.visual-prolog.com/viewto ... sterhotkey
So you want to press F5 from a browser like IE (or from Excel or Word) to start an action in your VP7 application : is it what you want to do ?
Maybe look at gui_Native::registerHotKey + http://discuss.visual-prolog.com/viewto ... sterhotkey
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
yes, that would be the idea. I will have a look at the linked info. Thx for your help.
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
Some time ago I asked about defining global hotkeys and received the hint to look at
gui_Native::registerHotKey + http://discuss.visual-prolog.com/viewto ... sterhotkey (this link seems to be erased)
Although I tried over time to do something with this, I got no further. I assumed that registering the hotkey correctly would call a menu entry in my program or perhaps do other things not requiring a menu entry?
What I am trying to do now is copy something from outside my program and paste into an edit control.
the first step seemed clear:
_=gui_native::registerHotKey(vpi::winGetActiveWindow(),id_file_open,0x0001,0x31)
Alt-1 should be the hotkey:
0x0001=mod_alt
0x31=K_1
Am I correct so far? how to continue?
Any help is much appreciated!
gui_Native::registerHotKey + http://discuss.visual-prolog.com/viewto ... sterhotkey (this link seems to be erased)
Although I tried over time to do something with this, I got no further. I assumed that registering the hotkey correctly would call a menu entry in my program or perhaps do other things not requiring a menu entry?
What I am trying to do now is copy something from outside my program and paste into an edit control.
the first step seemed clear:
_=gui_native::registerHotKey(vpi::winGetActiveWindow(),id_file_open,0x0001,0x31)
Alt-1 should be the hotkey:
0x0001=mod_alt
0x31=K_1
Am I correct so far? how to continue?
Any help is much appreciated!
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
The API function is described here RegisterHotKey function.
The window that is given as argument will receive a WM_HOTKEY event once the key is pressed.
So the window you supply should not be some "random (happens to be active)" window, it should be the one that handles the hotkey. I assume the task window will be most appropriate, as it is the one that that is available all the time.
To react on the WM_HOTKEY message, you will have to attach a native handler to the window.
This seems to work (update in taskWindow.pro):
The window that is given as argument will receive a WM_HOTKEY event once the key is pressed.
So the window you supply should not be some "random (happens to be active)" window, it should be the one that handles the hotkey. I assume the task window will be most appropriate, as it is the one that that is available all the time.
To react on the WM_HOTKEY message, you will have to attach a native handler to the window.
This seems to work (update in taskWindow.pro):
Code: Select all
constants
hotKeyId = 17.
predicates
onShow : window::showListener.
clauses
onShow(_, _CreationData) :-
_MessageForm = messageForm::display(This),
R = gui_native::registerHotKey(getVpiWindow(), hotKeyId, gui_native::mod_alt, gui_native::vk_1key),
if 0 = R then
E = exception::getLastError(),
exception::raise_nativeCallException("registerHotKey", E, [])
end if,
addNativeMessageHandler(hotKeyHandler).
predicates
hotKeyHandler : window::nativeMessageHandler.
clauses
hotKeyHandler(_, gui_native::wm_hotkey, WParam, LParam) = defaultNativeHandling :-
!,
stdio::writef("Hotkey pressed WParam = % LParam = %\n", WParam, LParam).
hotKeyHandler(_, _, _, _) = defaultNativeHandling.
predicates
onDestroy : window::destroyListener.
clauses
onDestroy(_) :-
_ = gui_native::unregisterHotKey(getVpiWindow(), hotKeyId).
Regards Thomas Linder Puls
PDC
PDC
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
Great, thanks for your help, Thomas. I had looked at the registerhotkey function, but did not really get it.
Copying marked data from outside my prolog program to clipboard then uses gui_api::setClipboardData?I couldn't find anything else that looks promising.(but admittedly have not yet had time to try it).
Copying marked data from outside my prolog program to clipboard then uses gui_api::setClipboardData?I couldn't find anything else that looks promising.(but admittedly have not yet had time to try it).
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
Quick response! Thx.
But in order to put a string on the clipboard, I have to capture it first?
But in order to put a string on the clipboard, I have to capture it first?
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
Are you trying to make another program put its selection on the clipboard?
I believe that is in general impossible, you could try to simulate a Ctrl-C to the application and hope that it handles it as "copy". I don't know how to simulate key strokes to other applications.
I believe that is in general impossible, you could try to simulate a Ctrl-C to the application and hope that it handles it as "copy". I don't know how to simulate key strokes to other applications.
Regards Thomas Linder Puls
PDC
PDC
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
yes, that's the idea. On using the hotkey, grab some text (which is already marked) from another program screen and insert it into my program. I was hoping that that is what gui_api::setClipboardData does somehow, or that there is another command somewhere in the vast number of MSDN commands in gui_api or gui_native.
Simulating Ctl-C is an interesting idea, maybe with outputStream_console?
Simulating Ctl-C is an interesting idea, maybe with outputStream_console?
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
An application can place data on the clipboard, but it can only place data it have access to. So you cannot place another applications data on the clipboard (unless you somehow get access to the data and in that case you don't really need to put it on the clipboard).
outputStream_console deals with your applications console (if it has one). Dealing with other application is significantly more complicated.
I know that the UI Automation framework can do such things. But that is rather complex, and there are no bindings to it in Visual Prolog.
There may be other ways, but I am not aware of them.
outputStream_console deals with your applications console (if it has one). Dealing with other application is significantly more complicated.
I know that the UI Automation framework can do such things. But that is rather complex, and there are no bindings to it in Visual Prolog.
There may be other ways, but I am not aware of them.
Regards Thomas Linder Puls
PDC
PDC
-
- Posts: 23
- Joined: 21 Dec 2010 19:40
global hotkeys
Thanks for your comments. It seems the (quick and dirty) solution would be to write a small program with Autokey or similar which I then call from Prolog. This would copy marked text and send to clipboard, where my program can pick up the string again..