最新消息:

nsKeyHook是NSIS使用钩子程序响应按键处理WM_CHAR和WM_KEYDOWN和WM_KEYUP和WM_PASTE事件的插件

nsis 永恒心锁 2912浏览 0评论
/*
nsKeyHook是NSIS使用钩子程序响应按键处理WM_CHAR和WM_KEYDOWN和WM_KEYUP和WM_PASTE事件的插件
nsKeyHook插件封装了有关铵键响应事件的功能,可以对用户键盘事件做出相应的操作,并且将功能键进行了宏定义.在自定义界面中增强了字符处理能力.
*/
!AddPluginDir "../../Plugins"
!AddIncludeDir "../../Include"
!include MUI2.nsh
!include nsKeyHook.nsh
Name `nsKeyHook plug-in`
OutFile nsKeyHookExample.exe
RequestExecutionLevel user
!insertmacro MUI_PAGE_WELCOME
Page Custom TextBoxPage_Show
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Function TextBoxPage_Show
 !insertmacro MUI_HEADER_TEXT `nsKeyHook` `Added Ctrl+Alt+Shift+P hook to the text box.`
 nsDialogs::Create 1018
 Pop $R0
 ${NSD_CreateText} 0 0 100% 12u `Now press Ctrl+Alt+Shift+P.`
 Pop $R0
 ${NSKH_OnKeyUp} $R0 ${KEY_P} ${ANY_CTRL}|${ANY_ALT}|${ANY_SHIFT} KeyHook_KeyUp
 ${NSKH_OnChar} $R0 0 0 KeyHook_Char
 ${NSD_SetFocus} $R0
 nsDialogs::Show
FunctionEnd
Function KeyHook_KeyUp
 MessageBox MB_OK|MB_ICONINFORMATION `Ctrl+Alt+Shift+P pressed!`
FunctionEnd
Function KeyHook_Char
 ; The current character (ASCII value).
 Pop $R0
 ${If} $R0 >= 33
 ${AndIf} $R0 <= 126
 IntFmt $R1 `Key '%c'` $R0
 ${Else}
 StrCpy $R1 `Character code #$R0`
 ${EndIf}
 MessageBox MB_OK|MB_ICONINFORMATION `$R1 entered! 'p' and 'Q' are suppressed!`
 ${If} $R0 == 81
 ${OrIf} $R0 == 112
 StrCpy $R0 0
 ${EndIf}
 ; Allow all input.
 Push 1
FunctionEnd
Section
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » nsKeyHook是NSIS使用钩子程序响应按键处理WM_CHAR和WM_KEYDOWN和WM_KEYUP和WM_PASTE事件的插件

您必须 登录 才能发表评论!