如何在窗口执行任务的过程中,响应其他命令?
本帖最后由 gtalee 于 2023-12-23 23:12 编辑例如
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
$From1 = GUICreate("From1",300,300,-1,-1)
$Start_1 = GUICtrlCreateButton("Start",120,250,60,30)
$Label1 = GUICtrlCreateLabel("测试信息",80,140,140,20,$SS_CENTER)
$Progress1 = GUICtrlCreateProgress(80,180,140,20)
GUISetState(@SW_SHOW,$From1)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Start_1
main()
EndSwitch
WEnd
###################################################################################################################################################################################
Func main()
Local $sec = 10
Local $P_State = 0
While $sec >= 0
GUICtrlSetData($Label1,"将在" & $sec & "秒后完成!")
GUICtrlSetData($Progress1,$P_State)
$sec -= 1
$P_State += 10
Sleep(1000)
WEnd
GUICtrlSetData($Label1,"已完成!")
GUICtrlSetData($Progress1,0)
EndFunc
在点击按钮后,循环的过程中,响应关闭窗口的命令,如何实现,不知道调用Windows api函数创建新的进程这个方向是否正确,又或者有其他方法
试试用hotkeyset anythinging 发表于 2023-12-24 10:03
试试用hotkeyset
使用hotkeyset确实可以实现我所提到的功能,请问还有其他方式吗,是否可以通过点击窗口的关闭按钮来响应 注册 WM_SYSCOMMAND 消息来处理点击窗口的关闭按钮来响应 afan 发表于 2023-12-24 13:17
注册 WM_SYSCOMMAND 消息来处理点击窗口的关闭按钮来响应
感谢,已解决
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$From1 = GUICreate("From1",300,300,-1,-1)
$Start_1 = GUICtrlCreateButton("Start",120,250,60,30)
$Label1 = GUICtrlCreateLabel("测试信息",80,140,140,20,$SS_CENTER)
$Progress1 = GUICtrlCreateProgress(80,180,140,20)
GUISetState(@SW_SHOW,$From1)
;HotKeySet("^c","Window_Event")
GUIRegisterMsg($WM_SYSCOMMAND, "Window_Event")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Start_1
main()
EndSwitch
WEnd
###################################################################################################################################################################################
Func main()
Local $sec = 10
Local $P_State = 0
While $sec >= 0
GUICtrlSetData($Label1,"将在" & $sec & "秒后完成!")
GUICtrlSetData($Progress1,$P_State)
$sec -= 1
$P_State += 10
Sleep(1000)
WEnd
GUICtrlSetData($Label1,"已完成!")
GUICtrlSetData($Progress1,0)
EndFunc
Func Window_Event($hWnd, $iMsg, $wParam, $lParam)
Switch $wParam
Case 0xF060
If MsgBox($MB_YESNO,"Info","确认退出?") = 6 Then
Exit
else
EndIf
EndSwitch
EndFunc
页:
[1]