[SOLVED] Process launch -> automatically press key Space

Get help with using AutoHotkey and its commands and hotkeys
Trymado
Posts: 24
Joined: 04 Oct 2019, 02:30

[SOLVED] Process launch -> automatically press key Space

08 Apr 2020, 19:34

Hi everyone,

I would like when a process is detected (Game Loader Installer.exe), a press on space keyboard is done.
I tried this script but it work only one time

Code: Select all

 
Run, "G:\Arcana Heart 3\Game Loader Installer.exe"
Run, "G:\Sims4\Game Loader Installer.exe"
WinWait, ahk_exe Game Loader Installer.exe
Send {Space}
Return  
Thx :)
Last edited by Trymado on 11 Apr 2020, 18:51, edited 4 times in total.
User avatar
Cuadrix
Posts: 224
Joined: 07 May 2017, 08:26

Re: Pb If process exist > press key keyboard

08 Apr 2020, 19:58

- Process is a command.
- If is a statement that evaluates expressions.
- Commands are not expressions.
- The If statement won't recognize a command as an expression because it isn't a value and it does not return a value like an expression does.

For your script to work, you have to separate them in a way that the If statement can evaluate the condition. You can for example wrap your Process command in a function and have it return a value to be evaluated in your If statement.

Code: Select all

Run, "G:\Arcana Heart 3\Game Loader Installer.exe"
If (MyProcessExist("Game Loader Installer.exe")) {
	Send {space}
}

MyProcessExist(process) {
	Process, Exist, %process%
	return ErrorLevel
}
----
Trymado
Posts: 24
Joined: 04 Oct 2019, 02:30

Re: Pb If process exist > press key keyboard

09 Apr 2020, 03:55

Thx for precious info.
I test your script but doesn't work for me.
I have uploaded the file for text
https drive.google.com /file/d/1ZUytq_Imw9aBDeLtYPU0JnvjhCa7JEYM/view?usp=sharing Broken Link for safety

Thx a lot for help
vsub
Posts: 476
Joined: 29 Sep 2015, 03:39

Re: Pb If process exist > press key keyboard

10 Apr 2020, 04:41

So ummm...

You want when you run the script to check if that process exist and if it does,send space
What if it doesn't,do you want to run it or what

Or you want to run the process if it doesn't exist and press space when that program window appear

Or if it exist but not active,activate it and send space

Or maybe something else
Trymado
Posts: 24
Joined: 04 Oct 2019, 02:30

Re: Pb If process exist > press key keyboard

10 Apr 2020, 09:28

I try this and it work but only one time.
I would like that each time that the window appear the command is launched.
Maybe loop or SetTimer command or sleep

Code: Select all

 
Run, "G:\Arcana Heart 3\Game Loader Installer.exe"
Run, "G:\Sims4\Game Loader Installer.exe"
WinWait, ahk_exe Game Loader Installer.exe
Send {Space}
Return   
vsub
Posts: 476
Joined: 29 Sep 2015, 03:39

Re: WinWait, ahk_exe -> automatically press key Space

10 Apr 2020, 10:22

You didn't actually answer my question and that code makes it even more confusing.
You are running a program with the same name from different folders at the same time and then wait for that window to appear
Trymado
Posts: 24
Joined: 04 Oct 2019, 02:30

Re: WinWait, ahk_exe -> automatically press key Space

10 Apr 2020, 11:06

Sorry, it is quite complicated to explain it in english i hope google trad will do its job well.

In fact in each games folder, there is a "Game Loader Installer.exe" (I have 31 games) When each "Game Loader Installer.exe" of each game folder is launched one after the other, I need to press the space key when the window appears.
vsub
Posts: 476
Joined: 29 Sep 2015, 03:39

Re: WinWait, ahk_exe -> automatically press key Space

10 Apr 2020, 14:50

Ok but what do you want to happen if the window exist...activate it and then send space or what
And so umm,you want to start all those 31 "Game Loader Installer.exe" at the same time,one after another?
That's kinda asking for problems like windows crashing or something else

Code: Select all

; Place all of your "Game Loader Installer.exe" paths in that variable(no quotes)
Games =
(
G:\Arcana Heart 3\Game Loader Installer.exe
G:\Sims4\Game Loader Installer.exe
)


Loop,Parse,Games,`n,`r
{
If A_LoopField =
Break
IfWinExist,ahk_exe %A_LoopField%
{
WinActivate
WinWaitActive
Send,{Space Down}
Sleep,50
Send,{Space Up}
Continue
}
Else
{
SplitPath,A_LoopField,,WDir
Run,% A_LoopField,% WDir,,PID
WinWaitActive,ahk_pid %PID%
Send,{Space Down}
Sleep,50
Send,{Space Up}
}
}
Trymado
Posts: 24
Joined: 04 Oct 2019, 02:30

Re: WinWait, ahk_exe -> automatically press key Space

10 Apr 2020, 17:26

Thank you very much for help, really.

In fact every time I have to update my 31 games I have to launch "Game Loader Installer.exe" in each folder.
When I launch "Game Loader Installer.exe", I can press the "installation" button by pressing Space. This is why I would like this to be done all by myself so that I no longer press space 31 times.

I write for test
Games = G:\Arcana Heart 3\Game Loader Installer.exe G:\Sims4\Game Loader Installer.exe

but when i run the script, the first exe will be installed perfeclty but after i have a curious black windows CS Emulation

https zupimages.net /up/20/15/cp46.jpg Broken Link for safety

Thx for hard work.
vsub
Posts: 476
Joined: 29 Sep 2015, 03:39

Re: WinWait, ahk_exe -> automatically press key Space

10 Apr 2020, 18:00

Look at the "Games" variable
All paths are in separate line...not like that
Games = G:\Arcana Heart 3\Game Loader Installer.exe G:\Sims4\Game Loader Installer.exe
but like this
Games =
(
G:\Arcana Heart 3\Game Loader Installer.exe
G:\Sims4\Game Loader Installer.exe
)

Does that program auto closes when the update is done?
Trymado
Posts: 24
Joined: 04 Oct 2019, 02:30

Re: WinWait, ahk_exe -> automatically press key Space

11 Apr 2020, 18:41

Work Great !!!

Thank you very very very x10 much !!

Return to “Ask For Help”

Who is online

Users browsing this forum: Haan, jongyun24, mikagenic, Recrix, takenbythedesert and 38 guests