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.