找回密码
 加入
搜索
楼主: gyhhi

[AU3基础] 【已解决】如何检测大小写是否锁定?

  [复制链接]
发表于 2015-9-14 14:35:43 | 显示全部楼层
回复 15# gyhhi

11楼不是己经将代码贴上了。
按11楼的代码还不能运行吗?
发表于 2015-9-14 15:51:07 | 显示全部楼层
回复 14# gyhhi
代码如下:

#RequireAdmin
#NoTrayIcon
#region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=201.ico
#PRE_Outfile=键盘大小写状态.exe
#PRE_Outfile_x64=键盘大小写.exe
#PRE_Compression=4
#PRE_Res_Comment=键盘大小写
#PRE_Res_Description=键盘大小写功能
#PRE_Res_Fileversion=1.0.0.0
#PRE_Res_LegalCopyright=DIY:chzj589
#PRE_Res_requestedExecutionLevel=None
#PRE_Res_Field=脚本制作|2013-10-24
#PRE_Run_Tidy=y
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#region AutoIt3Wrapper 预编译参数(常用参数)
;#AutoIt3Wrapper_icon=C:\WINDOWS\system32\SHELL32.dll|-96
;#AutoIt3Wrapper_UseAnsi=N                                                                        ;编码
#endregion AutoIt3Wrapper 预编译参数(常用参数)
Opt("GUIOnEventMode", 1)
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
Global $Labela, $Label1, $Button1, $Button2, $result, $GForm1
;Global $result = DllCall("user32.dll", "Int", "GetKeyState", "int", 20)
;#cs
GUI()
While 1
        Sleep(100)
WEnd
Func GUI()
        $GForm1 = GUICreate("大写键盘灯:", @DesktopWidth - 804, @DesktopHeight - 694, -1, -1)
        GUISetOnEvent($GUI_EVENT_CLOSE, "GForm1Close")
        $Label1 = GUICtrlCreateLabel("键盘大小写状态:", 20, 20, 130, 17)
        GUICtrlSetFont(-1, 12, 400, 0, "微软雅黑")
        $Labela = GUICtrlCreateLabel("", 150, 20, 70, 21)
        GUICtrlSetFont(-1, 12, 600, 0, "微软雅黑")
        ;GUICtrlSetColor(-1, 0xFFFFFF)
        $Button1 = GUICtrlCreateButton("", 100, 45, 100, 22)
        GUICtrlSetOnEvent($Button1, "g_Button1")
        $Button2 = GUICtrlCreateButton("", 100, 45, 100, 22)
        GUICtrlSetOnEvent($Button2, "g_Button2")
        _result()
        GUISetState(@SW_SHOW)
EndFunc   ;==>GUI
Func _result()
        $result = DllCall("user32.dll", "Int", "GetKeyState", "int", 20)
        If @error = 1 Then
                MsgBox(0, "错误", "函数调用失败") ;基本上不会的 :)
                Exit
        Else
                If $result[0] = 1 Then
                        ;MsgBox(0,"大写键盘灯","大写键盘灯状态:  亮",10)
                        GUICtrlSetState($Button1, $GUI_HIDE)
                        GUICtrlSetState($Button2, $GUI_SHOW)
                        GUICtrlSetData($Labela, "大写")
                        GUICtrlSetData($Button2, "键盘状态:大写")
                        GUICtrlSetColor($Labela, 0x009900)
                        GUICtrlSetColor($Label1, 0x009900)
                Else
                        ;MsgBox(0,"大写键盘灯","大写键盘灯状态:  灭",10)
                        GUICtrlSetState($Button2, $GUI_HIDE)
                        GUICtrlSetState($Button1, $GUI_SHOW)
                        GUICtrlSetData($Labela, "小写")
                        GUICtrlSetData($Button1, "键盘状态:小写")
                        GUICtrlSetColor($Labela, 0xFF0000)
                        GUICtrlSetColor($Label1, 0xFF0000)
                EndIf
        EndIf
EndFunc   ;==>_result
Func g_Button1()
        GUISetState(@SW_HIDE, $GForm1)
        GUI()
        _result()
EndFunc   ;==>g_Button1
Func g_Button2()
        GUISetState(@SW_HIDE, $GForm1)
        GUI()
        _result()
EndFunc   ;==>g_Button2
Func GForm1Close()
        Exit
EndFunc   ;==>GForm1Close
 楼主| 发表于 2015-9-21 10:31:47 | 显示全部楼层
回复 17# chzj589


    11楼的不行,17楼的行。谢谢。没看出什么本质区别,真是奇怪
发表于 2015-9-21 10:41:22 | 显示全部楼层
学习学习。。。。。。。。。。
发表于 2015-9-21 11:10:48 | 显示全部楼层
本帖最后由 chzj589 于 2015-9-21 11:16 编辑

回复 18# gyhhi
11楼的代码前面加上:
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
Opt("GUIOnEventMode", 1)
Global $Labela, $Label1, $Button1, $Button2, $result, $GForm1
GUI()
后面加上:
Func g_Button1()
        GUISetState(@SW_HIDE, $GForm1)
        GUI()
        _result()
EndFunc   ;==>g_Button1
Func g_Button2()
        GUISetState(@SW_HIDE, $GForm1)
        GUI()
        _result()
EndFunc   ;==>g_Button2
Func GForm1Close()
        Exit
EndFunc   ;==>GForm1Close
这样就可以了
为什么呢?因为11楼还原我的代码。对比两个代码,是不是一样。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 20:13 , Processed in 0.086021 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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