Pulover / PuloversMacroCreator

Automation Utility - Recorder & Script Generator
http://www.macrocreator.com
Other
1.59k stars 231 forks source link

How to judge whether the process exists? #246

Open songdianxue opened 1 year ago

songdianxue commented 1 year ago

`; This script was created using Pulover's Macro Creator ; www.macrocreator.com

NoEnv

SetWorkingDir %A_ScriptDir% CoordMode, Mouse, Window SendMode Input

SingleInstance Force

SetTitleMatchMode 2

WinActivateForce

SetControlDelay 1 SetWinDelay 0 SetKeyDelay -1 SetMouseDelay -1 SetBatchLines -1

F3:: Macro1:

IfExist, C:\Program Files\Anyi\Anyiqw.exe { IfWinExist, anyi { IfWinActive, anyi { WinSet, AlwaysOnTop, Toggle, Anyi Sleep, 333 Sleep, 2078 Click, 625, 301 Left, Down Sleep, 78 Click, 625, 301 Left, Up Sleep, 4094 WinSet, AlwaysOnTop, Toggle, anyi Sleep, 333 Sleep, 1 WinMinimize, anyi Sleep, 333 } Else { WinActivate, anyi Sleep, 333 WinSet, AlwaysOnTop, Toggle, Anyi Sleep, 333 Sleep, 2078 Click, 625, 301 Left, Down Sleep, 78 Click, 625, 301 Left, Up Sleep, 4094 WinSet, AlwaysOnTop, Toggle, anyi Sleep, 333 Sleep, 1 WinMinimize, anyi Sleep, 333 } } Else { WinShow, Anyi Sleep, 333 WinActivate, anyi Sleep, 333 WinSet, AlwaysOnTop, Toggle, Anyi Sleep, 333 Sleep, 2078 Click, 625, 301 Left, Down Sleep, 78 Click, 625, 301 Left, Up Sleep, 4094 WinActivate, anyi ahk_class Window Class Sleep, 333 WinSet, AlwaysOnTop, Toggle, Anyi Sleep, 333 Sleep, 1563 WinMinimize, anyi Sleep, 333 } } Else { Run, C:\Program Files\Anyi\Anyiqw.exe WinShow, Anyi Sleep, 333 WinActivate, Anyi ahk_class Window Class Sleep, 333 WinSet, AlwaysOnTop, Toggle, Anyi Sleep, 333 Sleep, 4250 Click, 997, 562 Left, Down Sleep, 282 Click, 997, 562 Left, Up Sleep, 890 Click, 1072, 418 Left, Down Sleep, 125 Click, 1072, 418 Left, Up Sleep, 235 Click, 1072, 418 Left, Down Sleep, 125 Click, 1072, 418 Left, Up Sleep, 1703 Click, 619, 273 Left, Down Sleep, 78 Click, 619, 273 Left, Up Sleep, 4734 WinMinimize, anyi Sleep, 333 } Return To determine if a program is running or to check if a process exists?

TirOFlanc commented 1 year ago

Hi,

Depending on the context or the need, you can use :

  1. The 'Process' command :

    Process

  2. The internal function 'WinExist()' :

    WinExist()

  3. For a 'Hotkeys' and 'Hotstrings' :

    #IfWinExist

  4. Between 2. and 3., the #If Expression, where Expression is the internal function 'WinExist()' :

    #If Expression

Kiss