What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » HELP - Hotkeys!

Pages: (2): « First [ 1 ] 2 » Last »
HELP - Hotkeys!
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. Huh?  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...  :S
06-08-2009 05:05 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
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
Profile PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: HELP - Hotkeys!
Well you can also look into my HopperLive script's CHopkeyReceiver.js file. Basically you just need to know how RegisterHotKey() API works, how PlusWnd.RegisterMessageNotification() works and how OnWindowIdEvent_MessageNotification() works :)

This post was edited on 06-08-2009 at 05:20 PM by Mnjul.
06-08-2009 05:18 PM
Profile PM Web Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - Hotkeys!
I've added the following lines to my script:
Javascript 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:
Javascript 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
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
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.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
06-08-2009 06:35 PM
Profile E-Mail PM Web Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - Hotkeys!
Javascript 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
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
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
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
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
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
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
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - Hotkeys!
Javascript code:
function OnWndSubclassEvent_MessageNotification(PlusWnd, Message, wParam, lParam)
{
    if (wParam == 0x100)
    {
        // ...
    }
}

Like that?
06-08-2009 07:10 PM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On