【发布时间】:2014-07-27 08:03:55
【问题描述】:
我正在使用此 AutoIt 代码在按下按钮时将文本发送到记事本:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form = GUICreate("Replicate text to notepad", 615, 50, 190, 122)
$Input = GUICtrlCreateInput("Placeholder text", 0, 0, 609, 21)
$Button = GUICtrlCreateButton("Send to notepad", 0, 24, 609, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button
Example(GUICtrlRead($Input))
EndSwitch
WEnd
Func Example($text)
Run("notepad.exe")
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
ControlSend($hWnd, "", "Edit1", $text)
EndFunc
效果很好。但是现在我想在按下按键后立即发送按键。 AutoIt 中有类似 OnKeyDown 的东西吗?所以我不必每次输入字符时都按发送按钮将其发送到记事本。
【问题讨论】:
-
没有重复,因为他要求任何可能的解决方案。对于这种情况,IsPressed 不是一个好的解决方案。