自完义热键框(单键)
By
admin
at 2020-01-12 • 0人收藏 • 1450人看过
感谢 aardio培训群: 圣地 分享源码 , 收藏学习
当运行代码的时候,会hook全局键盘操作, 包括win键,printscreen键 esc键等特效键
注意: 开启hook导致ctrl+alt+A截图用的快捷键啥的都没用了....
import win.ui; import win.ui.ctrl.edit; import key; import key.hook; import console; namespace win.ui.ctrl begin class hotkeyex { ctor (parent, tParam) { tParam.cls = "edit"; tParam.style |= 0x800/*_ES_READONLY*/ tParam.exstyle |= 0x200/*_WS_EX_CLIENTEDGE*/; tParam.bgcolor = ::GetSysColor(0x5/*_COLOR_WINDOW*/ ); this = ..win.ui.ctrl.edit(parent, tParam); } keyhookproc = function(){ keyhook.proc = function(msg,vkcode,scancode,injected,flags,timeStamp,extraInfo){ if( injected ) return; select(msg) { case 0x100/*_WM_KEYDOWN*/ ,0x104/*_WM_SYSKEYDOWN*/{ return true; } case 0x101/*_WM_KEYUP*/,0x105/*_WM_SYSKEYUP*/{ this.text = ..key.getName(vkcode) return true; } } } } oncommand = function(id,event){ select(event) { case 0x200/*_EN_KILLFOCUS*/{keyhook.close()} case 0x100/*_EN_SETFOCUS*/{ keyhook = ..key.hook() this.keyhookproc() } } } } end; /*DSG{{*/ var winform = win.form(text="aardio Form";right=744;bottom=489;border="dialog frame";max=false;parent=...) winform.add( edit={cls="edit";text="Edit";left=250;top=299;right=472;bottom=374;edge=1;multiline=1;z=2}; hotkeyex={cls="hotkeyex";text="无";left=300;top=167;right=504;bottom=207;bgcolor=0;z=1} ) /*}}*/ winform.show(); win.loopMessage();
登录后方可回帖