找回密码
 加入
搜索
查看: 4984|回复: 4

[系统综合] 【已解决】Hotkeyset快捷键干扰抢断系统按键

  [复制链接]
发表于 2015-7-17 15:08:17 | 显示全部楼层 |阅读模式
本帖最后由 user11 于 2015-7-18 15:06 编辑

IC读卡器,在读卡以后,会自动加一个回车,所以就用这个【回车】触发,转换功能

但是,如此设置,,win7 64旗舰版,会抢断系统的回车,难道hotkeyset是全局快捷键??

即使软件不激活,回车键也没办法使用了,,这可怎么办??试着判断窗口是否激活?  貌似没用,是注册了系统消息???


求高手帮忙解决一下问题。。,能否把快捷键加在 button1 ?谢谢




#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 3)  
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("ID卡号8位转换10位", 416, 240, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$Group1 = GUICtrlCreateGroup("", 8, 8, 401, 225)
$Label1 = GUICtrlCreateLabel("ID卡号8位转10位", 132, 34, 136, 17)
$Label2 = GUICtrlCreateLabel("原始卡号:", 46, 80, 55, 17)
$Label3 = GUICtrlCreateLabel("转换卡号:", 46, 136, 55, 17)
$Input1 = GUICtrlCreateInput("", 104, 80, 185, 21)
$Input2 = GUICtrlCreateInput("", 104, 128, 185, 21)
$Button1 = GUICtrlCreateButton("转换", 304, 80, 65, 25)
GUICtrlSetOnEvent(-1, "button1")
$Button2 = GUICtrlCreateButton("复制", 304, 128, 65, 25)
GUICtrlSetOnEvent(-1, "button2")
$Label4 = GUICtrlCreateLabel("Code By  ", 178, 184, 136, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        Sleep(10)
        
;~         If WinActive("ID卡号8位转换10位") Then
                HotKeySet("{Enter}", "button1")
 
;~         EndIf


        HotKeySet("{ESC}", "close")
WEnd


Func button1()
        
        GUICtrlSetData($Input2, "")
        $oid = StringStripWS(StringStripCR(GUICtrlRead($Input1)), 8)        
        $l5 = Hex(StringRight($oid, 5), 4)        
        $ok = StringRight($l5, 2) & StringLeft($l5, 2) & Hex(StringLeft($oid, 3), 2)        
        GUICtrlSetData($Input2, $ok)
        
 
        
EndFunc   ;==>button1



Func button2()
        ClipPut(StringStripWS(StringStripCR(GUICtrlRead($Input2)), 8))
        MsgBox(64, "", "卡号已经复制到剪贴板")
EndFunc   ;==>button2

Func close()
        Exit
EndFunc   ;==>close


发表于 2015-7-17 15:33:19 | 显示全部楼层
同求。AUTOIt的快捷键就是不是当前窗口,也接管了
发表于 2015-7-17 20:53:32 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 3)  
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("ID卡号8位转换10位", 416, 240, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$Group1 = GUICtrlCreateGroup("", 8, 8, 401, 225)
$Label1 = GUICtrlCreateLabel("ID卡号8位转10位", 132, 34, 136, 17)
$Label2 = GUICtrlCreateLabel("原始卡号:", 46, 80, 55, 17)
$Label3 = GUICtrlCreateLabel("转换卡号:", 46, 136, 55, 17)
$Input1 = GUICtrlCreateInput("", 104, 80, 185, 21)
$Input2 = GUICtrlCreateInput("", 104, 128, 185, 21)
$Button1 = GUICtrlCreateButton("转换", 304, 80, 65, 25)
GUICtrlSetOnEvent(-1, "button1")
$Button2 = GUICtrlCreateButton("复制", 304, 128, 65, 25)
GUICtrlSetOnEvent(-1, "button2")
$Label4 = GUICtrlCreateLabel("Code By  ", 178, 184, 136, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

Local $AccelKeys[2][2] = [["{Enter}", $Button1],['{esc}', $Button2]]
GUISetAccelerators($AccelKeys)
        
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
 
While 1
        Sleep(10)
WEnd
 
Func button1()
        
        GUICtrlSetData($Input2, "")
        $oid = StringStripWS(StringStripCR(GUICtrlRead($Input1)), 8)    
        $l5 = Hex(StringRight($oid, 5), 4)      
        $ok = StringRight($l5, 2) & StringLeft($l5, 2) & Hex(StringLeft($oid, 3), 2)    
        GUICtrlSetData($Input2, $ok)
        
 
        
EndFunc   ;==>button1
 
 
 
Func button2()
        ClipPut(StringStripWS(StringStripCR(GUICtrlRead($Input2)), 8))
        MsgBox(64, "", "卡号已经复制到剪贴板")
EndFunc   ;==>button2
 
Func close()
        Exit
EndFunc   ;==>close
发表于 2015-7-17 20:54:02 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 3)  
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("ID卡号8位转换10位", 416, 240, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$Group1 = GUICtrlCreateGroup("", 8, 8, 401, 225)
$Label1 = GUICtrlCreateLabel("ID卡号8位转10位", 132, 34, 136, 17)
$Label2 = GUICtrlCreateLabel("原始卡号:", 46, 80, 55, 17)
$Label3 = GUICtrlCreateLabel("转换卡号:", 46, 136, 55, 17)
$Input1 = GUICtrlCreateInput("", 104, 80, 185, 21)
$Input2 = GUICtrlCreateInput("", 104, 128, 185, 21)
$Button1 = GUICtrlCreateButton("转换", 304, 80, 65, 25)
GUICtrlSetOnEvent(-1, "button1")
$Button2 = GUICtrlCreateButton("复制", 304, 128, 65, 25)
GUICtrlSetOnEvent(-1, "button2")
$Label4 = GUICtrlCreateLabel("Code By  ", 178, 184, 136, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

Local $AccelKeys[2][2] = [["{Enter}", $Button1],['{esc}', $Button2]]
GUISetAccelerators($AccelKeys)
        
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
 
While 1
        Sleep(10)
WEnd
 
Func button1()
        
        GUICtrlSetData($Input2, "")
        $oid = StringStripWS(StringStripCR(GUICtrlRead($Input1)), 8)    
        $l5 = Hex(StringRight($oid, 5), 4)      
        $ok = StringRight($l5, 2) & StringLeft($l5, 2) & Hex(StringLeft($oid, 3), 2)    
        GUICtrlSetData($Input2, $ok)
        
 
        
EndFunc   ;==>button1
 
 
 
Func button2()
        ClipPut(StringStripWS(StringStripCR(GUICtrlRead($Input2)), 8))
        MsgBox(64, "", "卡号已经复制到剪贴板")
EndFunc   ;==>button2
 
Func close()
        Exit
EndFunc   ;==>close
 楼主| 发表于 2015-7-18 15:03:25 | 显示全部楼层
回复 5# Alam


非常感谢,就是这样!!

但是昨天看帮助文件没搞明白,

GUISetAccelerators() 不用数组,能不能单独设置一个button的快捷键?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-27 12:08 , Processed in 0.078015 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表