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

hermine.potter

  • Sr. Member
  • ****
  • Posts: 369
    • 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.



current:
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




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



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



03)
close bsnes.exe



04)
get and install autoit



05)
goto folder of autoit and look for Au3Info.exe



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



07)
click on tab : Visible Text




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



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



10)
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




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



12)
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




13)
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

 


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



15)
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")
WinWaitActive("SuperRoadBlaster")

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

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

;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 : https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm )
While 1
If _IsPressed ("1B") Then
ProcessClose("bsnes.exe")
Exit
EndIf
WEnd



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



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



18)
start superroadblaster.exe



19)
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




NOTE:
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

akafox

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

I find that this program works very well for me as well http://lustark.com/closemul

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

jedione

  • Sr. Member
  • ****
  • Posts: 434
  • 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.
--------------------------------------------------------------

RButton::esc

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




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

rsn8887

  • 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!