Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Black screen after exiting AutoHotKey script  (Read 2645 times)

0 Members and 1 Guest are viewing this topic.

telliouze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 13
  • Last login:January 30, 2013, 06:14:27 am
Black screen after exiting AutoHotKey script
« 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 ?...

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Today at 07:12:41 am
  • ...
Re: Black screen after exiting AutoHotKey script
« Reply #1 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.
« Last Edit: March 23, 2011, 02:11:00 pm by BadMouth »

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Today at 07:12:41 am
  • ...
Re: Black screen after exiting AutoHotKey script
« Reply #2 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.

telliouze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 13
  • Last login:January 30, 2013, 06:14:27 am
Re: Black screen after exiting AutoHotKey script
« Reply #3 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 ...

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Today at 07:12:41 am
  • ...
Re: Black screen after exiting AutoHotKey script
« Reply #4 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.


Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Yesterday at 08:25:56 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Black screen after exiting AutoHotKey script
« Reply #5 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. 

telliouze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 13
  • Last login:January 30, 2013, 06:14:27 am
Re: Black screen after exiting AutoHotKey script
« Reply #6 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" ?..)

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Yesterday at 08:25:56 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Black screen after exiting AutoHotKey script
« Reply #7 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. 

telliouze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 13
  • Last login:January 30, 2013, 06:14:27 am
Re: Black screen after exiting AutoHotKey script
« Reply #8 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 ...