Build Your Own Arcade Controls Forum

Main => Software Forum => Topic started by: telliouze on March 23, 2011, 04:06:59 am

Title: Black screen after exiting AutoHotKey script
Post by: telliouze on March 23, 2011, 04:06:59 am
Hi,

I'm running this scrip on my cab to launch SF IV :
Code: [Select]
#NoEnv
SendMode Input
SetWorkingDir C:\Program Files\CAPCOM\STREETFIGHTERIV\
Blockinput on
SetBatchLines -1
Gui +AlwaysOnTop -Caption +ToolWindow
Gui Color, 0
;Gui Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%, HSHIDE
Run, SF4Launcher.exe, , Max
WinWait, STREET FIGHTER IV LAUNCHER
IfWinNotActive, STREET FIGHTER IV LAUNCHER
WinWaitActive, STREET FIGHTER IV LAUNCHER
Send, {enter}
Blockinput off
Process, WaitClose, StreetFighterIV.exe
return
ESC::
Process, Close, StreetFighterIV.exe
ExitAPP
return

But every time I exit the game, I find myself stuck on a black screen with my AHK script running in the background with no intention to stop by himself : I mus use the task manager to quit ...

Any ideas ?...
Title: Re: Black screen after exiting AutoHotKey script
Post by: BadMouth on March 23, 2011, 02:08:10 pm
Add:

Gui Destroy

after the line to close the exe

That will get rid of the black box that was drawn by the earlier Gui lines.
Title: Re: Black screen after exiting AutoHotKey script
Post by: BadMouth on March 23, 2011, 02:42:25 pm
also not sure what the first "return" is for.  That might be why the script isn't exiting.
Title: Re: Black screen after exiting AutoHotKey script
Post by: telliouze on March 30, 2011, 04:18:08 am
Ok, I tried "GUI Destroy" and it works ... kind of ... In fact, I don't get the black screen anymore but the script doesn't exit, the icon is still in the tray and I have to right click on it to close it ...
Title: Re: Black screen after exiting AutoHotKey script
Post by: BadMouth on March 30, 2011, 12:11:13 pm
Ok, I tried "GUI Destroy" and it works ... kind of ... In fact, I don't get the black screen anymore but the script doesn't exit, the icon is still in the tray and I have to right click on it to close it ...
also not sure what the first "return" is for.  That might be why the script isn't exiting.

Title: Re: Black screen after exiting AutoHotKey script
Post by: Howard_Casto on March 30, 2011, 01:42:39 pm
You are using a waitclose for the exe for no reason.  That is probably why it isn't exiting.  Hotkey events like your ESC event can occur when you are waiting, but if they alter what you are waiting for the wait function doesn't get updated data.  You actually don't need it anyway so long as you exit with escape. 

Btw, why do you have that escape in there anyway?  You can exit sfiv via the menu with a gamepad/keyboard.

Also here's a tip about ahk scripts..... Doing a process close can be messy because that isn't how you properly shut down an application.  Instead try having the script press alt+F4.  All windows applications are supposed to safely close when you press alt+f4. 
Title: Re: Black screen after exiting AutoHotKey script
Post by: telliouze on March 30, 2011, 03:38:45 pm
I thought I said it in my first post ... but I didn't  :'( : I got this script from another post of this forum so I'm not sure how everything is supposed to work (it's my first attempt at an AHK script, so I figured I'd start by using an existing one).

To answer your question, I exit SFIV using the menu ... so, if I get you, I should delete the first "Return", delete the escape command, and replace (or totally delete, since the script is useless as SFIV starts succesfuly ...) the process close by an Alt+F4 command ("!F4" ?..)
Title: Re: Black screen after exiting AutoHotKey script
Post by: Howard_Casto on March 30, 2011, 05:46:33 pm
No you should just delete from the first return down.  The process clsoe it happening upon pressing escape.  Since you don't press escape you don't need it.  You can then keep the process WaitClose in there as the ESC part won't be interfering with it.

When using the WaitClose command, ahk isn't closing anything, it is waiting until something has closed before going any further. 

After the WaitClose put a ExitApp.... no return. 
Title: Re: Black screen after exiting AutoHotKey script
Post by: telliouze on April 02, 2011, 01:09:17 pm
Hi, here's my final code after your advice :
Code: [Select]
#NoEnv
SendMode Input
SetWorkingDir C:\Program Files\CAPCOM\STREETFIGHTERIV\
Blockinput on
SetBatchLines -1
Gui +AlwaysOnTop -Caption +ToolWindow
Gui Color, 0
;Gui Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%, HSHIDE
Run, SF4Launcher.exe, , Max
WinWait, STREET FIGHTER IV LAUNCHER
IfWinNotActive, STREET FIGHTER IV LAUNCHER
WinWaitActive, STREET FIGHTER IV LAUNCHER
Send, {enter}
Blockinput off
Process, WaitClose, StreetFighterIV.exe
ExitAPP
return

The compiled AHK script works OK (it quits OK and the tray icon disappears as wanted ...) but when I try to make it work in MaLa, the game launches but it looks like it losses the focus immediately : my pad doesn't respond and I must use the task manager to get it in the front ...