1

我有一个用于在我们的系统中输入记录的脚本,该脚本最初可以使用 MsgBox 正常工作,但我添加了一个 GUI 来显示记录条目。现在脚本在第一条记录后停止。

在下面的示例中,我删除了所有操作和记录行以帮助使其更易于解析,但我保留了所有重要内容并测试了此版本的脚本。

Loop, read, C:\_AutoHotKey\AA_test.txt
{
    StringSplit, LineArray, A_LoopReadLine, %A_Tab%

    aaduedate   := LineArray1
    aauniqueid  := LineArray2
    aaprefix    := LineArray3
    aasequence  := LineArray4
    aadescript  := LineArray5
    aaelig      := LineArray6

;-------------------------------------------------------------------------------------
;Use these to test the file match in the Input File.
;Remove surrounding comments and surround the rest of the script up to the last brace.
    SendInput, Prefix: %aaprefix% {enter}
    SendInput, Sequence: %aasequence% {enter}
    SendInput, Description: %aadescript% {enter}
    SendInput, Eligibility: %aaelig% {enter}
    SendInput, ID Card: %aaidcard% {enter}
;---------------------------------------------------------------------------------------

;Pop-up validation menu
Gui, Add, Button, x22 y380 w100 h30 , &Submit
Gui, Add, Button, x362 y380 w100 h30 , &Cancel
Gui, Font, S14 CDefault, Verdana
Gui, Add, Text, x152 y10 w210 h30 +Center, Is the entry correct?
Gui, Font, S10 CDefault, Verdana
Gui, Add, Text, x102 y40 w90 h20 , %aaprefix%
Gui, Add, Text, x102 y70 w130 h20 , %aaelig%
Gui, Add, Text, x312 y70 w30 h20 , %aadescript%
Gui, Add, Text, x432 y70 w30 h20 , %aaidcard%
Gui, Font, S8 CDefault, Verdana
Gui, Add, Text, x132 y380 w230 h40 +Center, Click Submit/press S to continue. Click cancel to stop script.
; Generated using SmartGUI Creator 4.0
Gui, Show, x9 y250 h428 w480, Auto Action Validation
Return

ButtonCancel: 
ExitApp

ButtonSubmit: 
Gui, Submit ; 
    MouseMove, 630,55
    Sleep, 100
    SendInput, {Click 630,55}
    SendInput ^S

Return

}

按钮确实有效,单击提交将发送 MouseMove 和 SendInput。但在那之后它只是停止并且不加载文本文件中的下一条记录。

提前致谢!

4

2 回答 2

0

我可以通过从 GUI 中删除提交按钮并将其移动到 MsgBox 来实现此功能。

GUI 基本相同,但已删除提交和取消行以及返回和其后的所有逻辑。

接下来,添加了一个 MsgBox 来确认数据。这现在使用 GUI 来显示记录的内容,并使用 MsgBox 来确认并移动到下一条记录。

此外,我偷了一些代码(并且不太理解)移动 MsgBox,这样它就不会阻塞接收应用程序中的数据输入屏幕。

这是替换 Gui、Show、x9 之后所有内容的新代码...

OnMessage(0x44, "WM_COMMNOTIFY")
MsgBox 4, AA Entry, Would you like to continue? (press Yes or No)

WM_COMMNOTIFY(wParam) {
    if (wParam = 1027) { ; AHK_DIALOG
        Process, Exist
                DetectHiddenWindows, On
        if WinExist("ahk_class #32770 ahk_pid " . ErrorLevel) {
            WinGetPos,,, w
            WinMove, 90, 650
        }
    }
    }
;If the user responds yes, then close the Gui (Destroy) and enter the record
IfMsgBox Yes
    {
        Gui destroy
        Sleep, 100
}
    else
        ExitApp

}

谢谢,我希望这对某人有帮助。

于 2013-09-01T06:11:46.743 回答
0

您在循环中有一个返回命令。

这退出程序

请参阅此示例。此循环应运行 5 次,但 return 命令在第一次运行后将其停止。

Loop, 5
{
  msgbox, %A_Index%
  return
}
于 2013-08-31T06:14:22.167 回答