无忧启动论坛

标题: 求助,au3脚本写代码时如何调用运行qq.exe的同时最小化运行 [打印本页]

作者: 2011ziyouren    时间: 2013-12-3 20:53
标题: 求助,au3脚本写代码时如何调用运行qq.exe的同时最小化运行
本帖最后由 2011ziyouren 于 2013-12-7 07:40 编辑

au3脚本写代码时如何调用运行qq.exe的同时最小化运行qq.exe,不让看到窗口,关闭脚本同时关闭qq.exe
谢谢!

作者: xulinghai    时间: 2013-12-3 21:58
不知道这样行不:
  1. #include <GUIConstantsEx.au3>

  2. Opt("MustDeclareVars", 1)
  3. Opt("GUIOnEventMode", 1)

  4. Global $Main = GUICreate("运行QQ", 400, 100, -1, -1)
  5. Global $Btn1 = GUICtrlCreateButton("运行", 120, 40, 72, 24)
  6. Global $Btn2 = GUICtrlCreateButton("退出", 220, 40, 72, 24)

  7. GUISetOnEvent($GUI_EVENT_CLOSE, "GUICtrlMsg")
  8. GUICtrlSetOnEvent($Btn1, "GUICtrlMsg")
  9. GUICtrlSetOnEvent($Btn2, "GUICtrlMsg")

  10. GUISetState(@SW_SHOW)

  11. While 1
  12.         Sleep(1000)
  13. WEnd

  14. Func GUICtrlMsg()
  15.         Switch @GUI_CtrlId
  16.                 Case $GUI_EVENT_CLOSE
  17.                         _Quit()
  18.                 Case $Btn1
  19.                         _RunQQ()
  20.                 Case $Btn2
  21.                         _Quit()
  22.         EndSwitch
  23. EndFunc   ;==>GUICtrlMsg

  24. Func _RunQQ()
  25.         If FileExists(@ScriptDir & "\qq.exe") Then
  26.                 Run(@ScriptDir & "\qq.exe", "", @SW_MINIMIZE)
  27.         Else
  28.                 MsgBox(64, "提示", "程序目录未发现qq.exe文件.     ")
  29.         EndIf
  30. EndFunc   ;==>_RunQQ

  31. Func _Quit()
  32.         If ProcessExists("qq.exe") Then ProcessClose("qq.exe")
  33.         GUIDelete($Main)
  34.         Exit
  35. EndFunc   ;==>_Quit
复制代码

作者: 2011ziyouren    时间: 2013-12-4 07:47
谢谢大哥!帮了我的帮大忙。
作者: 2011ziyouren    时间: 2013-12-4 08:18
大哥:我要把运行按钮取消直接运行qq.exe,代码怎么改谢谢!
作者: 2011ziyouren    时间: 2013-12-4 22:07
谢谢xulinghai大哥的代码让我学习了很多,我原本是想这样运行。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("运行QQ", 265, 265, -1, -1)
$Button1 = GUICtrlCreateButton("退出", 80, 96, 105, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Run(@ScriptDir &"\qq.exe","",@SW_MINIMIZE)
While 1
        $nMsg = GUIGetMsg()
       
        Switch $nMsg
               
                Case $GUI_EVENT_CLOSE, $Form1
                       
                        _Quit()
                       
                Case $Button1
                       
                        _Quit()
                       
                        Exit

        EndSwitch
WEnd
Func _Quit()

        If ProcessExists("qq.exe") Then ProcessClose("qq.exe")

        GUIDelete($Form1)

        Exit

EndFunc   ;==>_Quit





欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/) Powered by Discuz! X3.3