send input at program starts
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
send input at program starts
Hello everyone, I'm not an expert, I'm learning and I have serached as best as I can to find a solution but nothing seems to work properly. My problem is that I have to automatize the pressure of alt+enter when a program starts and opens his window. I need this to set the window in fullscreen and the only way to do that is by pressing alt+enter when this program (demul.exe) starts. Tried a lot of combinations but noyhing..... any solution please? Thanks
Re: send input at program starts
Can you post the script you have so far?
Re: send input at program starts
I would write script that run this exe (if possible) then wait for it to finish launching, then send your keys, then close script. ALl this behave like lnk windows shortcut but would be ahk script
Have you tried WinMove to resize app window?
Have you tried WinMove to resize app window?
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Thanks for the answers, this is the last script i tried:
if Process, Exist, demul.exe
If ErrorLevel <> 0
SendInput, !enter
I have tried even with winactive but nothing. When i launch the programm demul.exe it stand windowed.
if Process, Exist, demul.exe
If ErrorLevel <> 0
SendInput, !enter
I have tried even with winactive but nothing. When i launch the programm demul.exe it stand windowed.
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Yes but it doesn't solve the problem. The program need alt+enter to go completely fullscreen and hide the gui and the mouse cursor tooBriHecato wrote:I would write script that run this exe (if possible) then wait for it to finish launching, then send your keys, then close script. ALl this behave like lnk windows shortcut but would be ahk script
Have you tried WinMove to resize app window?
Re: send input at program starts
Why If proces exist?
Why sendinput?
That wouldn't work?
Why sendinput?
That wouldn't work?
Code: Select all
RunWait, your_path\demul.exe
IfWinActive, ahk_exe demul.exe ;;;just to be sure
Send, {Alt}{Enter}
ExitApp
Re: send input at program starts
This won't work, because RunWait waits for the exe to run and stop. I don't believe you tested this code.BriHecato wrote:That wouldn't work?Code: Select all
RunWait, your_path\demul.exe IfWinActive, ahk_exe demul.exe ;;;just to be sure Send, {Alt}{Enter} ExitApp
Here's a general idea to get you started.
Code: Select all
; run the exe
Run, demul.exe ; you'll have to specify the path
; Wait for the window to appear
WinWait, ahk_exe demul.exe
; Activate the window
WinActivate, ahk_exe demul.exe
; Send Alt+Enter
; if this happens to soon, i.e. the program doesn't accept this keypress because it's still starting, you could specify a sleep long enough to allow the program to finish loading
; Sleep, (a little longer than required to ensure consistent behaviour)
SendInput, !{Enter} ; Use SendInput just in case SendMode isn't input
try it and see
...
...
Re: send input at program starts
I'm not familiar with this emulator shadyknight is using, if it use splashscreen, or is titlebarless or busy loading subcomponents after launch (like apps that they little more time after the exe is loaded and displayed and do not response to any actions yet).derz00 wrote: This won't work, because RunWait waits for the exe to run and stop. I don't believe you tested this code.
That's why I asked why he use SendInput in this situation, why is he checking for process with less popular If, Exist, Process.
Let's wait what shady has to say.
Maybe he need to recheck exe, class, controls, whole behaviour of this software, maybe need put some if/else, some forced sleep. Maybe he forget about {} for enter
I use everyday code with Run - WinWait - WinMove to place and resize some stubborn app. But Run+WinWait = RunWait, true?
Re: send input at program starts
You might know further (referring to the AFAIK modifier) by reading the documentation. According to https://autohotkey.com/docs/commands/Run.htm RunWait wait until the program exits not finishes loading.BriHecato wrote:AFAIK RunWait waits for finish loading then continue the script
Another part about your code that wouldn't have worked is {Alt}{Enter}. That will not send the keyboard combination Alt+Enter. It will be the same as pressing and releasing {Alt} and then pressing and releasing {Enter}.
Not big issues, but just remember to test any code before posting (or at least say it has not been tested) to make sure that the code is right and the result is right.
3 Cheers for all your helpfulness in this forum.
try it and see
...
...
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Thank you guys, I appreciate so much your help. This one works fine but with only one problem....
Run, C:\demul07_111117\demul.exe
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
SendInput, !{Enter}
If i launch the ahk script demul starts by itself. I would the script simulate the pressure of alt+enter when I open demul (i do it launching directly roms from frontend program).
What do i have to change in this script? Thank you very much
Run, C:\demul07_111117\demul.exe
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
SendInput, !{Enter}
If i launch the ahk script demul starts by itself. I would the script simulate the pressure of alt+enter when I open demul (i do it launching directly roms from frontend program).
What do i have to change in this script? Thank you very much
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Tried to change the script but nothing works better than that, i should just not launch demul.exe with the run of the script. And another little problem that i noticed trying lot of times the script, somethimes, not always the script simulate the pressure of alt+enter before of window launch so that appear the demul.exe properties window instead of send the demul window in fullscreen so i think i have to set a wait time before the sendinput line just as derz00 suggested but don't know how to do.
That's all because i'm building an arcade cabinet with all the emulators inside and i have this problem with demul. with the frontend program i shuold choice the rom and it automatically launch the emulator. all of them works fine but demul doesn't go fullscreen, that's why i need to do it with this script. thank you for help.
That's all because i'm building an arcade cabinet with all the emulators inside and i have this problem with demul. with the frontend program i shuold choice the rom and it automatically launch the emulator. all of them works fine but demul doesn't go fullscreen, that's why i need to do it with this script. thank you for help.
Re: send input at program starts
@Shady - just put some
Sleep, xxx
between winwait and winactivate (and if necessary) between winactivate and sendinput.
Check behavior of the app and tune those sleeps.
Try also winactivate precise ahk_class (check with winspy) not emulator exe.
@derz00 - sorry for my rush language towards you. My observations were just mine from perspective of my code that (maybe wrong, and with wrong fundamentals) works in the end. Not mean to offend anyone.
Sleep, xxx
between winwait and winactivate (and if necessary) between winactivate and sendinput.
Check behavior of the app and tune those sleeps.
Try also winactivate precise ahk_class (check with winspy) not emulator exe.
@derz00 - sorry for my rush language towards you. My observations were just mine from perspective of my code that (maybe wrong, and with wrong fundamentals) works in the end. Not mean to offend anyone.
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Ok, thank you bri, thanks to all your suggestion and some attempts i'm almost on goal, this is the script i'm running now:
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
Sleep, 3000
SendInput, !{Enter}
it works fine but just with one problem (i hope this is the last one).... it works fine just the firs time demul.exe is launched. if i close it and launch again it doesn't work anymore. if i close the script, run the script again and launch demul.exe it works again but always just for the first time.
i've tried yet with
loop {
....
}
and easily with
{
....
}
but nothing, the first press repetetly alt+enter and goes fullscrre/windowed/fullscreen/windowed, the second doesn't change anything. thank you
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
Sleep, 3000
SendInput, !{Enter}
it works fine but just with one problem (i hope this is the last one).... it works fine just the firs time demul.exe is launched. if i close it and launch again it doesn't work anymore. if i close the script, run the script again and launch demul.exe it works again but always just for the first time.
i've tried yet with
loop {
....
}
and easily with
{
....
}
but nothing, the first press repetetly alt+enter and goes fullscrre/windowed/fullscreen/windowed, the second doesn't change anything. thank you
Re: send input at program starts
Use this script as your "*.lnk" to launch this app everytime - do not click app shortcunt on desktop - but click your "script launcher-shortcut"
(add ExitApp on the end of script to self-close it after succesfull launch)
You wrote -
"i should just not launch demul.exe with the run of the script"
- why ?? Any problems with it ?
Otherwise you need to create settimer that check in some intervals if your emulator window (or exe or class) exist and isn't full screen - then make it full screen.
(add ExitApp on the end of script to self-close it after succesfull launch)
You wrote -
"i should just not launch demul.exe with the run of the script"
- why ?? Any problems with it ?
Otherwise you need to create settimer that check in some intervals if your emulator window (or exe or class) exist and isn't full screen - then make it full screen.
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Thank you again. I have a script that have to be always working because it has some command that i need to use with the frontedn program. i have to run the script at windows start and never close it. now i have edited it like this....
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
Sleep, 3000
SendInput, !{Enter}
ExitApp
(after that i have severl command that are working fine.....)
so the script closes itself when demul got fullscreen, i need that it stays always running and do his function of pressing alt+enter everytime demul is runned by the frontend. selecting different roms the frontend open demul, close demul, open demul and close it again lot of times, once for every rom i want to play. that's why i do not launch demul but the frontend does it when i select a rom for demul. i'm sorry if i don't explain myself so good, english is not even my language, i'm from italy.
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
Sleep, 3000
SendInput, !{Enter}
ExitApp
(after that i have severl command that are working fine.....)
so the script closes itself when demul got fullscreen, i need that it stays always running and do his function of pressing alt+enter everytime demul is runned by the frontend. selecting different roms the frontend open demul, close demul, open demul and close it again lot of times, once for every rom i want to play. that's why i do not launch demul but the frontend does it when i select a rom for demul. i'm sorry if i don't explain myself so good, english is not even my language, i'm from italy.
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
I'm crushing the head on the floor, I can't find a solution, the better script is
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
Sleep, 3000
SendInput, !{Enter}
but it works just for the first time, if i esc demul and open it again doesn't work anymore. Please help......... thank you.
WinWait, ahk_exe demul.exe
WinActivate, ahk_exe demul.exe
Sleep, 3000
SendInput, !{Enter}
but it works just for the first time, if i esc demul and open it again doesn't work anymore. Please help......... thank you.
-
- Posts: 9
- Joined: 12 Apr 2018, 11:30
Re: send input at program starts
Thank you guys, problem solved with a frontend trick using the script above. Thank you for help.
Re: send input at program starts
Hello,
Did you finally find a way to do this perfectly without frontend ?
I'm searching exactly the same thing with Higan.exe emulator. I need to press a key every time higan start to enter in fullscreen mode.
Did you finally find a way to do this perfectly without frontend ?
I'm searching exactly the same thing with Higan.exe emulator. I need to press a key every time higan start to enter in fullscreen mode.
Re: send input at program starts
How about putting a loop around that?
Code: Select all
Loop
{
WinWaitActive, ahk_exe Higan.exe
Sleep, 1000 ; if you have to
Send, whatever_you_need
WinWaitClose, ahk_exe Higan.exe
}
Re: send input at program starts
Hello, thanks very much for your help, very appreciated.
Sadly nothing happen
This is what i was doing :
#Persistent
#If WinActive, "G:\Higan\higan.exe"
If WinExist, "G:\Higan\higan.exe"
WinWait,, Seek
Sleep, 1000
Send, {R}
Sadly nothing happen
This is what i was doing :
#Persistent
#If WinActive, "G:\Higan\higan.exe"
If WinExist, "G:\Higan\higan.exe"
WinWait,, Seek
Sleep, 1000
Send, {R}
Who is online
Users browsing this forum: No registered users and 92 guests