Code: Select all
DetectHiddenWindows On
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min ;
ControlSend,, {ALTDOWN}{F4}{ALTUP}, Genius Gaming Keyboard LuxeMate 525;
#NoTrayIcon
Code: Select all
DetectHiddenWindows On
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min ;
ControlSend,, {ALTDOWN}{F4}{ALTUP}, Genius Gaming Keyboard LuxeMate 525;
#NoTrayIcon
Code: Select all
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min, pid
WinWait ahk_pid %pid%
ControlSend,ahk_parent, {ALT DOWN}{F4}{ALT UP}, ahk_pid %pid%
#NoTrayIcon
I created this but it didn't send keystrokes.thinkRand wrote: ↑01 Sep 2022, 07:38This should work
Code: Select all
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min, pid WinWait ahk_pid %pid% ControlSend,ahk_parent, {ALT DOWN}{F4}{ALT UP}, ahk_pid %pid% #NoTrayIcon
Code: Select all
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min, 1548
WinWait ahk_1548 %pid%
ControlSend,ahk_parent, {ALT DOWN}{F4}{ALT UP}, ahk_1548 %pid%
#NoTrayIcon
Code: Select all
#NoTrayIcon ; if you don't want a related to this script icon on your desktop tray
exeApp := "C:\Program Files\KYE\LuxeMate525\LuxeMate525.exe"
string := "{ALTDOWN}{F4}{ALTUP}"
Run % exeApp,, min, exeAppPId ; run application and get process id to the variable "exeAppPId"
ControlSend,, % string, % "ahk_pid " . exeAppPId ; send the "string" variable to the program binded by PID
The code doesn' work, it only minimize, can't close the app.pto wrote: ↑01 Sep 2022, 20:38; is for only commenting in code. Every character afterwards until the end of the line is mostly for readability and understanding of code execution.
Since your goal is a minimized window (hence not hidden) you don't need DetectHiddenWindows OnCode: Select all
#NoTrayIcon ; if you don't want a related to this script icon on your desktop tray exeApp := "C:\Program Files\KYE\LuxeMate525\LuxeMate525.exe" string := "{ALTDOWN}{F4}{ALTUP}" Run % exeApp,, min, exeAppPId ; run application and get process id to the variable "exeAppPId" ControlSend,, % string, % "ahk_pid " . exeAppPId ; send the "string" variable to the program binded by PID
seamoon wrote: ↑01 Sep 2022, 10:17I created this but it didn't send keystrokes.thinkRand wrote: ↑01 Sep 2022, 07:38This should work
Code: Select all
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min, pid WinWait ahk_pid %pid% ControlSend,ahk_parent, {ALT DOWN}{F4}{ALT UP}, ahk_pid %pid% #NoTrayIcon
Code: Select all
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min, 1548 WinWait ahk_1548 %pid% ControlSend,ahk_parent, {ALT DOWN}{F4}{ALT UP}, ahk_1548 %pid% #NoTrayIcon
Code: Select all
Run, "c:\Program Files\KYE\LuxeMate525\LuxeMate525.exe",,min, pid ;pid is the name of the variable in which to store the newly launched program's unique Process ID (PID).
;After the Run command retrieves a PID, any windows to be created by the process might not exist yet. To wait for at least one window to be created, use
;WinWait ahk_pid %OutputVarPID%.
WinWait ahk_pid %pid%
ControlSend, ahk_parent, {ALT DOWN}{F4}{ALT UP}, ahk_pid %pid% ;Use ahk_pid PID in WinTitle to identify a window belonging to a specific process
#NoTrayIcon
You don't need ControlSend to close an application if you have its process id, wich you can easely get when you use Run command to launch:seamoon wrote: The code doesn' work, it only minimize, can't close the app.
Code: Select all
exeApp := "C:\Program Files\KYE\LuxeMate525\LuxeMate525.exe"
Run, % exeApp,, min, exeAppPId ; run application and get process id to the variable "exeAppPId"
WinClose, % "ahk_pid " . exeAppPId ; sends a close message to a window by providing its process id
I've pasted your code as it is (without any change) but didn't close the app.pto wrote: ↑02 Sep 2022, 09:54You don't need ControlSend to close an application if you have its process id, wich you can easely get when you use Run command to launch:seamoon wrote: The code doesn' work, it only minimize, can't close the app.
Code: Select all
exeApp := "C:\Program Files\KYE\LuxeMate525\LuxeMate525.exe" Run, % exeApp,, min, exeAppPId ; run application and get process id to the variable "exeAppPId" WinClose, % "ahk_pid " . exeAppPId ; sends a close message to a window by providing its process id
But how can I add winwait command.
Code: Select all
GroupAdd, np, ahk_exe notepad.exe
WinMinimize, ahk_group np
Run, notepad
WinWaitActive, ahk_group np,, 5
If ErrorLevel
MsgBox, 48, Error, An error occurred while waiting for the window.
hWnd := WinActive()
SoundBeep, 1500
Sleep, 500
WinClose, ahk_id %hWnd%
SoundBeep, 1000
But in your code, the application window visible for a half-second. I want to launch it minimized to tray then without seeing the window close it.mikeyww wrote: ↑06 Sep 2022, 10:54Code: Select all
GroupAdd, np, ahk_exe notepad.exe WinMinimize, ahk_group np Run, notepad WinWaitActive, ahk_group np,, 5 If ErrorLevel MsgBox, 48, Error, An error occurred while waiting for the window. hWnd := WinActive() SoundBeep, 1500 Sleep, 500 WinClose, ahk_id %hWnd% SoundBeep, 1000
Code: Select all
winTitle = ahk_exe notepad.exe
WinGet, before, List, %winTitle%
Run, notepad,, Min
Loop {
Sleep, 50
WinGet, after, List, %winTitle%
} Until (after > before)
newest := after1
SoundBeep, 1500
Sleep, 500
; F3::
WinClose, ahk_id %newest%
SoundBeep, 1000
Return
Thank you very much mikeyww. It worked great.mikeyww wrote: ↑07 Sep 2022, 05:11Windows TASKKILL is another way to end a process (broadly). Also: Process.Code: Select all
winTitle = ahk_exe notepad.exe WinGet, before, List, %winTitle% Run, notepad,, Min Loop { Sleep, 50 WinGet, after, List, %winTitle% } Until (after > before) newest := after1 SoundBeep, 1500 Sleep, 500 ; F3:: WinClose, ahk_id %newest% SoundBeep, 1000 Return
Users browsing this forum: Google [Bot], Kodakku and 359 guests