Post by garry » 05 Jan 2018, 04:09
Beispiele zu process close
Code: Select all
;- F1 = run 2 programs
;- F2 = close active window
;- F3 = close notepad
;- F4 = close calc
#warn
#NoEnv
#SingleInstance Force
setworkingdir,%a_scriptdir%
DetectHiddenWindows, on
F1::
;- run notepad.exe and then calc.exe
pr1=notepad
sc1=ahk_exe Notepad.exe
IfWinNotExist,%sc1%
{
Run, %pr1%,,,pid1
WinWait,%SC1%
}
pr2=calc
sc2=ahk_exe calc.exe
IfWinNotExist,%sc2%
{
Run, %pr2%,,,pid2
WinWait,%SC2%
}
IfWinNotActive ,%SC1%,,WinActivate,%SC1%
WinWaitActive,%SC1%
;- now ready to send something to notepad
send,test send to notepad`r`n
return
;---------------------------------------------
;- processx close active window
F2::
WinGet, Path, ProcessPath, A
SplitPath, Path, ProcessName
If ProcessName = explorer.exe
return
msgbox, 262436,CLOSE PROCESS %processname%,Want you really close ? =`n%Path%`n%ProcessName%
ifmsgbox,NO
return
Process, Close, %ProcessName%
return
F3::
xx=notepad.exe
process,exist,%xx%
pid:=errorlevel
if pid<>0
{
msgbox, 262208, ,Process %xx% with errorlevel=%pid% will close in 5 seconds,5
Process, Close, %pid%
return
}
msgbox, 262208, ,%xx% ist not running
return
F4::
xx=calc.exe
process,exist,%xx%
pid:=errorlevel
if pid<>0
{
msgbox, 262208, ,Process %xx% with errorlevel=%pid% will close in 5 seconds,5
winget,list,list,ahk_pid %pid%
loop % list
{
hwnd:=list%A_Index%
winclose ahk_id %hwnd%
}
return
}
msgbox, 262208, ,%xx% ist not running
return
Beispiele zu process close
[code];- F1 = run 2 programs
;- F2 = close active window
;- F3 = close notepad
;- F4 = close calc
#warn
#NoEnv
#SingleInstance Force
setworkingdir,%a_scriptdir%
DetectHiddenWindows, on
F1::
;- run notepad.exe and then calc.exe
pr1=notepad
sc1=ahk_exe Notepad.exe
IfWinNotExist,%sc1%
{
Run, %pr1%,,,pid1
WinWait,%SC1%
}
pr2=calc
sc2=ahk_exe calc.exe
IfWinNotExist,%sc2%
{
Run, %pr2%,,,pid2
WinWait,%SC2%
}
IfWinNotActive ,%SC1%,,WinActivate,%SC1%
WinWaitActive,%SC1%
;- now ready to send something to notepad
send,test send to notepad`r`n
return
;---------------------------------------------
;- processx close active window
F2::
WinGet, Path, ProcessPath, A
SplitPath, Path, ProcessName
If ProcessName = explorer.exe
return
msgbox, 262436,CLOSE PROCESS %processname%,Want you really close ? =`n%Path%`n%ProcessName%
ifmsgbox,NO
return
Process, Close, %ProcessName%
return
F3::
xx=notepad.exe
process,exist,%xx%
pid:=errorlevel
if pid<>0
{
msgbox, 262208, ,Process %xx% with errorlevel=%pid% will close in 5 seconds,5
Process, Close, %pid%
return
}
msgbox, 262208, ,%xx% ist not running
return
F4::
xx=calc.exe
process,exist,%xx%
pid:=errorlevel
if pid<>0
{
msgbox, 262208, ,Process %xx% with errorlevel=%pid% will close in 5 seconds,5
winget,list,list,ahk_pid %pid%
loop % list
{
hwnd:=list%A_Index%
winclose ahk_id %hwnd%
}
return
}
msgbox, 262208, ,%xx% ist not running
return
[/code]