本帖最后由 xiehuahere 于 2011-3-11 09:52 编辑
修改后的:#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
Opt("GUIOnEventMode", 1)
; Declare a flag
$fInterrupt = 0
#Region ### START Koda GUI section ###
$Form1 = GUICreate("Form1", 252, 327, 192, 124, $WS_CAPTION)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 233, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetData(-1, "This is the default text.")
$Button1 = GUICtrlCreateButton("Start", 16, 280, 113, 33)
GUICtrlSetOnEvent(-1, "FillEvent")
$Button2 = GUICtrlCreateButton("Exit", 168, 280, 65, 33)
GUICtrlSetOnEvent(-1, "ExitEvent")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
; Intercept Windows command messages with out own handler
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
While 1
Sleep(10)
WEnd
Func FillEvent()
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetData($Edit1, "")
While 1
_GUICtrlEdit_AppendText($Edit1, "看我成功退出吧, oh yeah~~" & @CRLF)
If $fInterrupt <> 0 Then Return
Sleep(60)
WEnd
GUICtrlSetState($Button1, $GUI_ENABLE)
EndFunc ;==>ConnectEvent
Func ExitEvent()
Exit 0
EndFunc ;==>ExitEvent
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
; Button2 was pressed so set the flag
If BitAND($wParam, 0x0000FFFF) = $Button2 Then $fInterrupt = 1
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_COMMAND
终于可以言归正题了。
现在ctrl+c不需要了,因为远程执行脚本的函数在返回前自己会关闭 TCP connection,这样通过远程用户登录得到运行的脚本也随着用户环境的退出而终止。
就先这样结贴吧。 |