Shoutbox

[?] EditControl/Displaying Hotkeys - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] EditControl/Displaying Hotkeys (/showthread.php?tid=69165)

[?] EditControl/Displaying Hotkeys by Spunky on 12-05-2006 at 12:34 AM

Does anybody know how the EditControl in the following picture is accomplished?

[Image: attachment.php?pid=759128]

I need it for a config window :(


RE: [?] EditControl/Displaying Hotkeys by CookieRevised on 12-05-2006 at 12:49 AM

quote:
Originally posted by SpunkyLoveMuff
Does anybody know how the EditControl in the following picture is accomplished?

[Image: attachment.php?pid=759128]

I need it for a config window :(

It isn't...

What I mean is it isn't an "EditControl", but a "HotKeyControl".
See Official Plus! Scripting Documentation > XML Schemas Reference > Interface Windows > Schema Documentation.
RE: [?] EditControl/Displaying Hotkeys by markee on 12-05-2006 at 12:53 AM

I'm not sure about what it returns but the coding for the XML is quite simple.

code:
<Control xsi:type="HotKeyControl" Id="hot">
        <Position Left="200" Top="50" Width="40" Height="15"/>
</Control>

Have fun with it :cheesy:

EDIT: Beaten to it again, I had to try it out first didn't I :sad:
RE: [?] EditControl/Displaying Hotkeys by Spunky on 12-05-2006 at 12:57 AM

OMG! I never noticed that before :o

Feel like a n00b :(

EDIT: Nah, I can't find how to read informatin from it either :S


RE: [?] EditControl/Displaying Hotkeys by matty on 12-05-2006 at 01:20 AM

And you need to use SendMessage along with WM_SetHotKey and WM_GetHotKey messages to read and set the text.


RE: [?] EditControl/Displaying Hotkeys by Spunky on 12-05-2006 at 01:25 AM

* Spunky breaks down and cries :'(

In good old "Spunky Style", I'll give it a bash

EDIT: In good old "SPunky Style", I failed :(


RE: [?] EditControl/Displaying Hotkeys by matty on 12-05-2006 at 02:43 AM

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.
RE: [?] EditControl/Displaying Hotkeys by Spunky on 12-05-2006 at 02:57 AM

quote:
Originally posted by Matty
Again like normal I am doing this while at work no way to test it.

Ok thanks for the code Matty. Had to add a closing brace at the end of the script (it's included above though) and had to change cTmp to pPlusWnd, but it works :p I'll set about adding it to my own script tomorrow