本帖最后由 cashiba 于 2016-9-24 22:15 编辑
最近学习热键,练习代码如下。
发现有问题:按热键F12后,毫无反应,是咋回事?
其它热键都能正常反应。Global $g_bPaused = False
HotKeySet("{PAUSE}", "HotKeyPressed")
HotKeySet("{ESC}", "HotKeyPressed")
HotKeySet("{F10}", "HotKeyPressed")
HotKeySet("{F12}", "HotKeyPressed")
While 1
Sleep(100)
WEnd
Func HotKeyPressed()
Switch @HotKeyPressed
Case "{PAUSE}"
$g_bPaused = Not $g_bPaused
While $g_bPaused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
Case "{ESC}"
Exit
Case "{F10}"
runnote()
Case "{F12}"
endnote()
EndSwitch
EndFunc ;==>HotKeyPressed
Func runnote()
Send("#r")
WinWait("Run", "", 0)
Send("notepad.exe {Enter}")
Local $hWnd = WinWait("[CLASS:Notepad]", "", 0)
Send("现在的日期/时间: {F5}")
EndFunc
Func endnote()
local $hwnd=WinWaitActive("[TITLE:无标题 - 记事本;CLASS:notepad]")
Sleep(500)
WinClose($hWnd)
WinWaitActive("[CLASS:#32770]")
Sleep(500)
Send("{TAB}{ENTER}")
EndFunc
|