What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] EditControl/Displaying Hotkeys

[?] EditControl/Displaying Hotkeys
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] EditControl/Displaying Hotkeys
Window.xml code:
code:
<?xml version="1.0" encoding="UTF-16"?>
<Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd" Name="Hotkey Example">
    <Window Id="Window" Version="1">
        <Attributes>
            <Caption>Hotkey Example</Caption>
        </Attributes>
        <TitleBar>
            <Title><Text></Text></Title>
        </TitleBar>
        <Position Width="186" Height="80"/>
        <DialogTmpl>
            <BottomBar Style="Plain">
                <LeftControls>
                    <Control xsi:type="ButtonControl" Id="BtnCancel">
                        <Position Left="0" Top="0" Width="50"/>
                        <Caption>Cancel</Caption>
                    </Control>
                </LeftControls>
                <RightControls>
                    <Control xsi:type="ButtonControl" Id="btnAdd">
                        <Position Left="0" Top="0" Width="50"/>
                        <Caption>Add</Caption>
                    </Control>
                </RightControls>
            </BottomBar>
        </DialogTmpl>
        <Controls>
            <Control xsi:type="StaticControl" Id="lbl1">
                <Position Top="7" Left="5" Width="60" Height="10" />
                <Caption>Hotkey:</Caption>
                <Attributes>
                    <AutoAdjustWidth>true</AutoAdjustWidth>
                </Attributes>
            </Control>
            <Control xsi:type="HotKeyControl" Id="hkHotKeyCombination">
                <Position Top="5" Left="40" Width="130" />
            </Control>
        </Controls>
    </Window>
</Interfaces>

Script Code
code:
var WM_USER = 0x0400;
var HK_GETKEY = (WM_USER+2);
var HK_SETKEY = (WM_USER+1);
var _mKey;

function OnWindowEvent_CtrlClicked(pPlusWnd, sControlId){
    if (sControlId == 'btnAdd'){
        _mKey = Interop.Call('user32','SendMessageW', pPlusWnd.GetControlHandle('hkHotKeyCombination'), HK_GETKEY, 0, 0);
        Debug.Trace(hibyte2modkey(hibyte(_mKey)) + '+' + lobyte2key(lobyte(_mKey)));
    }
}

function OnGetScriptMenu(nLocation){
    sMenu = '<ScriptMenu><MenuEntry Id="test">Test Window</MenuEntry></ScriptMenu>';
}

function OnEvent_MenuClicked(sMenuId, nLocation, ChatWnd){
    if (sMenuId == 'test'){
        var pPlusWnd = MsgPlus.CreateWnd('Window.xml', 'Window');
        Interop.Call('user32', 'SendMessageW', cTmp.GetControlHandle('hkHotKeyCombination'), HK_SETKEY, _mKey, 0);
    }
}
   
function hibyte2modkey(w){
    switch(w){
        case 1:
            return 'Shift';
            break;
        case 2:
            return 'Ctrl';
            break;
        case 3:
            return 'Ctrl + Shift';
            break;
        case 4:
            return 'Alt';
            break;
        case 5:
            return 'Alt + Shift';
            break;
        case 6:
            return 'Ctrl + Alt';
            break;
        case 7:
            return 'Ctrl + Shift + Alt';
            break;
    }
}

function lobyte2key(w){
    if (w >= 49 && w <= 91){
        return String.fromCharCode(w);
    }
    else if (w >= 112 && w <= 123){
        return 'F'+(w - 111);
    }else{ return w; }
}

function lobyte(w){ return w & 0xff; }
function hibyte(w){ return w >> 8; }

Again like normal I am doing this while at work no way to test it.

.plsc File Attachment: Hotkey Example.plsc (1.83 KB)
This file has been downloaded 125 time(s).

This post was edited on 12-05-2006 at 02:43 AM by matty.
12-05-2006 02:43 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[?] EditControl/Displaying Hotkeys - by Spunky on 12-05-2006 at 12:34 AM
RE: [?] EditControl/Displaying Hotkeys - by CookieRevised on 12-05-2006 at 12:49 AM
RE: [?] EditControl/Displaying Hotkeys - by markee on 12-05-2006 at 12:53 AM
RE: [?] EditControl/Displaying Hotkeys - by Spunky on 12-05-2006 at 12:57 AM
RE: [?] EditControl/Displaying Hotkeys - by matty on 12-05-2006 at 01:20 AM
RE: [?] EditControl/Displaying Hotkeys - by Spunky on 12-05-2006 at 01:25 AM
RE: [?] EditControl/Displaying Hotkeys - by matty on 12-05-2006 at 02:43 AM
RE: [?] EditControl/Displaying Hotkeys - by Spunky on 12-05-2006 at 02:57 AM


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