QQ386263723 发表于 2013-12-20 22:24:37

[已解决]:求助,运行QQ的同时怎么关闭《运行程序集》窗口附上源码

本帖最后由 QQ386263723 于 2013-12-21 21:09 编辑

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("运行程序集", 502, 238, 244, 143)
$Button1 = GUICtrlCreateButton("运行QQ", 56, 104, 105, 41)
$Button2 = GUICtrlCreateButton("运行迅雷", 196, 102, 105, 41)
$Button3 = GUICtrlCreateButton("运行酷狗", 336, 104, 105, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
      Case $Button1
                        RunWait(@ScriptDir & "\QQ.exe")
        EndSwitch
WEnd

afan 发表于 2013-12-20 23:27:21

Case $Button1
                        RunWait(@ScriptDir & "\QQ.exe")
改为
      Case $Button1
                        Run(@ScriptDir & "\QQ.exe")
                         Exit

QQ386263723 发表于 2013-12-21 08:01:43

本帖最后由 QQ386263723 于 2013-12-21 08:02 编辑

太感谢afan版主了,我还想冒昧的问一下,退出运行QQ后还能在打开运行程序集的窗口吗?本人刚刚学习au3就被它吸引了,就是互相调用。

xlj310 发表于 2013-12-21 08:31:34

本帖最后由 xlj310 于 2013-12-21 08:33 编辑

回复 3# QQ386263723


    你可以用WinSetState("运行程序集","运行QQ",@SW_HIDE)函数设置主程序隐藏,然后再通过判断QQ.exe这个进程是否有变化,将运行程序集设置显示即可。
如果你只有一个QQ,那只需if not ProcessExists("QQ.exe") then WinSetState("运行程序集","运行QQ",@SW_SHOW)即可。

如果你有多个QQ,那就用ProcessList("qq.exe")得到所有QQ进程列表(具体的自己看帮助程序),然后判断QQ进程的变化再显示运行程序集

QQ386263723 发表于 2013-12-21 15:29:16

本帖最后由 QQ386263723 于 2013-12-21 15:31 编辑

Run(@ScriptDir & "\QQ.exe")
                        WinSetState("运行程序集","运行QQ",@SW_HIDE)
这样可以隐藏主程序(如果不要判断QQ.exe这个进程是否有变化,)就是直接退出QQ.exe如何在把主程序显示出来。具体能用代码演示一下吗?谢谢!
还要用这个if not ProcessExists 定义吗?

afan 发表于 2013-12-21 16:33:10

GUICreate('运行程序集', 502, 238)
$Button1 = GUICtrlCreateButton('运行QQ', 56, 104, 105, 41)
$Button2 = GUICtrlCreateButton('运行迅雷', 196, 102, 105, 41)
$Button3 = GUICtrlCreateButton('运行酷狗', 336, 104, 105, 41)
GUISetState()
Local $Pid, $ExeFlag

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Button1
                        $Pid = _RunMyExe(@ScriptDir & '\QQ.exe')
                Case $Button2
                        $Pid = _RunMyExe('Thunder.exe 实际路径')
                Case $Button3
                        $Pid = _RunMyExe('KuGou.exe 实际路径')
        EndSwitch

        If $ExeFlag And Not ProcessExists($Pid) Then
                GUISetState()
                $ExeFlag = 0
        EndIf
WEnd

Func _RunMyExe($Exe)
        Local $Pid = Run($Exe)
        If Not $Pid Then Return MsgBox(48, '', $Exe & ' 运行失败,请确认路径')
        GUISetState(@SW_HIDE)
        $ExeFlag = 1
        Return $Pid
EndFunc   ;==>_RunMyExe

QQ386263723 发表于 2013-12-21 21:08:01

afan版主我太崇拜您了,谢谢您耐心的解答,没有白来,一直支持下去,加油……
页: [1]
查看完整版本: [已解决]:求助,运行QQ的同时怎么关闭《运行程序集》窗口附上源码