Author Topic: simulate button input for FULLSCREEN and set ESC to close Windows application  (Read 3494 times)


  • Sr. Member
  • ****
  • Posts: 356
    • View Profile
This guide is quick & dirty and for windows-systems only:

Different emulator-systems, games and applications on Windows do not start in fullscreen mode by itself.
They need an input from keyboard,  pressing a hotkey or move and click mouse button to special position.
After finishing playing this Windows application, it's not possible to return back to AM by hitting ESC-button.

AutoIT offers an easy way to solve this problems. I'll show you how autoit works by playing Super Road Blaster.

For playing Super Road Blaster, use bsnes.exe v088 (because it supports the MSU-1-enhancement correct and perfect).
After starting the game, you need to push F11 for fullscreen. In the middle of screen you see the mouse cursor (so you have to move the mouse out of screen focus).
After finishing game, you can not exit Super Road Blaster or bsnes.exe by hitting ESC-button.

target (full automatic):
Super Road Blaster starts > get into fullscreen > move mouse cursor away from center > exit game/bsnes by pushing ESC-Button

get and install bsnes. Start bsnes.exe (e.g. C:\bsnes\bsnes.exe )

open taskmanager (ctrl + alt + del => taskmanager) and identify the current process/task of bsnes (in this case : bsnes.exe )

close bsnes.exe

get and install autoit

goto folder of autoit and look for Au3Info.exe

starts Au3Info.exe > Options > uncheck Freeze (so it's "unfreezed")

click on tab : Visible Text

goto folder of bsnes and starts bsnes.exe (e.g. : C:\bsnes\bsnes.exe )

click to title of bsnes.exe, to get bsnes as the current front window

Notice Au3Info.exe. View has been changed. You see:
RED : the current title of current front window : bsnes v088
GREEN : text, that gives the current front window : No cartridge loaded

Now load Super Road Blaster by loading dialog into bsnes.exe

Notice Au3Info.exe. View has been changed. You see:
RED : the current title of current front window : SuperRoadBlaster
GREEN : text, that gives the current front window : Loaded SuperRoadBlaster

Wait a moment. Notice Au3Info.exe. View has been changed. You see:
RED : the current title of current front window : SuperRoadBlaster
GREEN : text, that gives the current front window : FPS: and_the_frames_per_second


With this Infos, we are now able to generate a suitable script. So, right mouse on desktop > create > autoit v3 script > superroadblaster.au3

use this code:

Code: [Select]
#include <Misc.au3>

;starts bsnes with parameter to load superroadblaster; like this : "C:\bsnes\bsnes.exe" "C:\bsnes\SuperRoadBlaster.sfc\SuperRoadBlaster.sfc"
run ('"' & @scriptdir & '\bsnes.exe"' & " " & @scriptdir & "\SuperRoadBlaster.sfc\SuperRoadBlaster.sfc")

;waits for bsnes, that superroadblaster is loaded
winwait("SuperRoadBlaster", "Loaded SuperRoadBlaster")

;holds on one second (1000 milliseconds = 1 second)

;waits for bsnes, that are the frames per second (FPS) are shown
winwait("SuperRoadBlaster", "FPS:")

;sends the F11 Button as hotkey for fullscreen ten times ( ten times because, depending of gamesize bsnes got some input lags loading a bigger game )
send("{F11 10}")

;moves mouse cursor away from focus to xy-position ; x = left,right ; y = up,down ; x=2000 ; y=308
MouseMove(2000, 308, 0)

;script waits for push ESC-button and close task/process bsnes.exe ( see 02) ); (1B is the hexadecimal value of ESC-Button ; further buttons see : )
While 1
If _IsPressed ("1B") Then

Ctrl + F7 (this compile the superroadblaster.au3 as superroadblaster.exe )

copy your compiled superroadblaster.exe to your bsnes-folder (where bsnes.exe is found)

start superroadblaster.exe

bsnes.exe starts the game SuperRoadBlaster automatically in Fullscreen. Moves the mouse cursor away. Now It's possible to close bsnes.exe by hitting ESC

To complete the potential of autoit, it's possible to generate some kind of auto-installer. Please see picture.

e.g. you want to click OK-Button to continue an installation:

-starts Au3Info.exe > Options > uncheck Freeze
-click on tab : Visible Text
-starts installation file
-click in title bar of installation file to get it as current front window
-move mouse cursor over OK button

RED : the current title of current front window : Installer Language
GREEN : Class and Instances of Buttons and Controls : OK Button got the Class Button and Instance 1
Yellow : text, that gives the current front window : English, OK, Cancel, Please select a language

Code: [Select]
;waits for window with title : Installer Language, containing text : 'Please select a'. Is title and text correct, then script continue and clicks on Class Button with Instance 1 (OK-Button)
WinWaitActive("Installer Language","Please select a")
WinWait("Installer Language","Please select a")
ControlClick("Installer Language","Please select a", "[CLASS:Button; INSTANCE:1]")
« Last Edit: September 15, 2016, 06:45:48 AM by hermine.potter »
AM Version : 2.3.0
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : WindowsXP x86 SP3
System : Dell Precision T3500 ; Intel X5650 ; 4GB RAM
Emulators : zsnes; mame; dosbox; scummvm; bsnes; fusion; openbor; windows_games; winuae; video; flashgames; vice; visualboy


  • Moderator
  • Hero Member
  • *****
  • Posts: 758
    • View Profile
Awesome hermine.potter! :)

I find that this program works very well for me as well

you will call it before your emulator

That is on your executable line you put the path to closemul and then you put the path to your emulator

ex. C:\Windows\emulatorstuff\closemul\closemul.exe C:\mame\mame.exe
People want life easy..then complain about it


  • Sr. Member
  • ****
  • Posts: 414
  • punktoe
    • View Profile
I use AHK and make it the right mouse click for the red button on my cab
from the usb track ball..      "this works as a combo for esc & alt f4    to exit games.


;    ----= [ .Esc = Alt-F4 toggle ] =----
Hotkey, Esc, Toggle
;    =========================================

;    ----= [ .Esc = Alt-F4 ] =----
SetTitleMatchMode, 2
IfWinNotActive, Firefox
   Send !{F4}
   Click left 760, 65
   Send ^w
;    =========================================
help a friend....


  • Full Member
  • ***
  • Posts: 48
    • View Profile
Hmm I am having my fair share of problems with AHK. Sometimes it works, but for example in Mame it doesn't work at all. Also it does not work to send the exit key to AM using AHK.

By the way another very simple option for BSNES is the retroarch emulator just use the bsnes-mercury-balanced core. This runs BSNES/Higan 0.92 I believe. It has a very confusing GUI, too, but much less of a nonsensical nightmare than the BSNES gui!