找回密码
 加入
搜索
查看: 387|回复: 6

[网络通信] [已解决]谁能分享下AU3自带的暂停/退出源码?感谢大家热心回复!

[复制链接]
发表于 2023-5-2 07:33:18 | 显示全部楼层 |阅读模式
本帖最后由 fybhwsx 于 2023-5-2 19:48 编辑

想在暂停期间执行一些操作,比如:增加计时退出或解除暂停……



Local $g_bPaused = False
HotKeySet('{PAUSE}', 'TogglePause') ;按pause/break 暂停/恢复 快捷键
Func TogglePause()
    $g_bPaused = Not $g_bPaused
    Local $js = 0
    While $g_bPaused
        TraySetState(4);闪烁托盘图标
        $js += 1
        Sleep(250)
        If $js > 40 Then
            TraySetState(8);停止闪烁托盘图标
            $g_bPaused = False
        EndIf
    WEnd
EndFunc

发表于 2023-5-2 11:14:21 | 显示全部楼层
本帖最后由 anythinging 于 2023-5-2 11:15 编辑

中途使用
while 1
条件......exitloop
wend

发表于 2023-5-2 11:43:34 | 显示全部楼层
$hTimer = TimerInit()
while 1
If TimerDiff($hTimer) >= 5000 Then exitloop  ;超过5秒退出循环
wend
发表于 2023-5-2 11:44:35 | 显示全部楼层
https://www.autoitx.com/thread-55168-1-1.html
可以看看这个 控制循环中的状态

评分

参与人数 1金钱 +40 收起 理由
fybhwsx + 40 感谢!

查看全部评分

发表于 2023-5-2 14:42:58 | 显示全部楼层
为什么要用自带的,自己模拟一个不好吗。自己写逻辑就可以添加操作了
发表于 2023-5-2 18:28:14 来自手机 | 显示全部楼层
托盘菜单中的暂停退出是调试程序用的。是解释器带的功能,无法利用。如果想使用,可以自己写代码重现功能。

评分

参与人数 1金钱 +40 收起 理由
fybhwsx + 40 明白了,谢谢。

查看全部评分

发表于 2023-5-2 19:04:17 | 显示全部楼层
本帖最后由 zghwelcome 于 2023-5-2 19:07 编辑



#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 360, 179)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$Button_start = GUICtrlCreateButton("运行", 24, 64, 73, 41)
$Button_stop = GUICtrlCreateButton("停止", 102, 64, 73, 41)
$Button_pause = GUICtrlCreateButton("暂停", 182, 64, 73, 41)
$Button_Exit = GUICtrlCreateButton("退出", 260, 64, 73, 41)
GUICtrlSetState($Button_stop, 128)
GUICtrlSetState($Button_pause, 128)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $_g_stop = False, $_g_pause = False
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button_start
                        GUICtrlSetState($Button_start, 128)
                        GUICtrlSetState($Button_stop, 64)
                        GUICtrlSetState($Button_pause, 64)
                        _Run()
                        GUICtrlSetState($Button_start, 64)
                        GUICtrlSetState($Button_stop, 128)
                        GUICtrlSetState($Button_pause, 128)
        EndSwitch
WEnd

Func _Run()
        $_g_stop = False
        _GUICtrlStatusBar_SetText($StatusBar1, ' 运行...')
        While $_g_stop = False
                Sleep(100)
                _Pause()
        WEnd
        _GUICtrlStatusBar_SetText($StatusBar1, ' 已停止.')
EndFunc   ;==>_Run

Func _Pause()
        While $_g_pause And $_g_stop = False
                Sleep(10)
        WEnd
EndFunc   ;==>_Pause

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
        Local $iCtrlID = BitAND($iwParam, 0x0000FFFF)
        Local $nNotifyCode = BitShift($iwParam, 16)
        Switch $iCtrlID
                Case $Button_Exit
                        Exit
                Case $Button_stop
                        $_g_stop = True
                Case $Button_pause
                        $_g_pause = Not $_g_pause
                        If $_g_pause Then
                                _GUICtrlStatusBar_SetText($StatusBar1, ' 已暂停.')
                                GUICtrlSetData($iCtrlID, '恢复')
                        Else
                                _GUICtrlStatusBar_SetText($StatusBar1, ' 运行...')
                                GUICtrlSetData($iCtrlID, '暂停')
                        EndIf
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


评分

参与人数 1金钱 +20 收起 理由
fybhwsx + 20 感谢,评分只剩20了。

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-24 13:27 , Processed in 0.081697 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表