HELP - Hotkeys! |
Author: |
Message: |
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. HELP - Hotkeys!
Basically, I need a hotkey that can be used anywhere (is this called "global"?), but I'm not sure how to go about it. I have had a look in a few scripts (including Matty's hotkey example script), but either they're for picking up the key combination within a window, or I have no idea how it works...
|
|
06-08-2009 05:05 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
RE: HELP - Hotkeys!
The problem with some scripts is, that they cannot be used anywhere (indeed "global"). They only listen for keypresses when a window is in the foreground (which is called "local"; although I still have problems specifying whether the window is actually in the foreground..).
However, you may try Matti's "Countdown live" script. There's a file called "GlobalHotkey.js". See if you can do anything with that
|
|
06-08-2009 05:12 PM |
|
|
Mnjul
forum super mod
plz wub me
Posts: 5396 Reputation: 58
– / /
Joined: Nov 2002
Status: Away
|
|
06-08-2009 05:18 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Hotkeys!
I've added the following lines to my script:
js code: var MOD_ALT = 0x1;
var MOD_CONTROL = 0x2;
var MOD_SHIFT = 0x4;
var WndSbc = MsgPlus.CreateWnd("Windows.xml", "WndSubclass", 2);
RegisterHotKey(WndSbc.Handle, "OpenMenu", MOD_ALT + MOD_SHIFT, 0x4D);
...but the debugger shows "Error: Object expected (code: -2146823281)".
Do I need to register the hotkey with the window, like this:
js code: WndSbc.RegisterHotKey(WndSbc.Handle, "OpenMenu", MOD_ALT + MOD_SHIFT, 0x4D);
EDIT: updated the top code (included Alt/Control/Shift variables) - still doesn't work, though.
This post was edited on 06-08-2009 at 06:26 PM by whiz.
|
|
06-08-2009 06:19 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: HELP - Hotkeys!
"RegisterHotkey" is a Win32 API function and is located in the "user32.dll" library. You can find this at the bottom of the MSDN page. This means you have to use Interop.Call() to call this function.
|
|
06-08-2009 06:35 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Hotkeys!
js code: Interop.Call("user32", "RegisterHotKey", WndSbc.Handle, "OpenMenu", MOD_ALT + MOD_SHIFT, 0x4D);
And if that is the case, how can I monitor it so I can perform an action when the combination is pressed?
EDIT: It works with just "MOD_ALT", or with just "MOD_SHIFT", but can I use both?
This post was edited on 06-08-2009 at 06:52 PM by whiz.
|
|
06-08-2009 06:46 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
RE: HELP - Hotkeys!
MOD_ALT | MOD_SHIFT?
Also, what you do with the "OpenMenu" thingy is wrong. you have to send a number, not a string. This works, because Plus! sends the pointer to your string (which is actually a number), but you need to use something like 0x100.
This post was edited on 06-08-2009 at 07:02 PM by SmokingCookie.
|
|
06-08-2009 06:57 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Hotkeys!
Ok. Just one other thing. "MOD_CONTROL" and "MOD_ALT" work fine, but I can't seem to get "MOD_SHIFT" to work (0x4). Is this the wrong number?
|
|
06-08-2009 07:02 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
RE: HELP - Hotkeys!
Weird, it is the right number...
Also (just to make sure you know about this), in the OnWindowIDEvent_MessageNotification() function, you might want to check for the hotkey identifier (that is the 0x100 number I told ya about). The wParam is this identifier.
This post was edited on 06-08-2009 at 07:06 PM by SmokingCookie.
|
|
06-08-2009 07:05 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Hotkeys!
js code: function OnWndSubclassEvent_MessageNotification(PlusWnd, Message, wParam, lParam)
{
if (wParam == 0x100)
{
// ...
}
}
Like that?
|
|
06-08-2009 07:10 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|