Attract-Mode Support Forum
Attract-Mode Support => General => Topic started by: Nosfé on November 05, 2019, 02:38:25 PM
-
Hello,
I have add some windows games, and when I exit them, I go back on attract mode, but the game is still running.
I thought it was and admin right issue, but I've disabled UAC and run AM with admin privilege, and same thing happens.
No problem with emulators.
Any idea?
Thanks!
-
Is this happening when you have setup an exit key in emulator.cfg? If so you can either use the actual game exit key as AM exit key (use secondary emulator settings) or use something like a bashscript or autoit to send a kill signal to game process when exiting.
-
Yes, I have setup an exit key, the same for all emulators and windows games.
I think not all games have an exit key, so the bash should be better.
Do you know how can I run a bash on exit key press?
-
When I run windows games I actually run everything through an AutoHot key Script. When I get home I will post some example code here. I just have the script monitor for the button press and it forces the windows game closed. Main reason I did this is for certain games needed some additional keyboard inputs at launch and set all my games the same way.
-
Yes please, it would help me a lot! :)
Does your script works with usb joystick key ? Or it's only for keyboard ?
-
My script simply is designed to run the software and wait for a push from a button, in my case its mapped to exit button I have through my joystick controller. I apologize for not posting it last night. I honestly forgot after working a 12 hour shift. I made a note to myself and will try again this afternoon to send you a copy of that script.
For the controls I often times use JoytoKey to assign specific Joystick movements and buttons to keyboard inputs since some of my computer games don't support my boards that I use for my arcade joysticks and buttons.
-
@ myriadgamers
Looking forward to your Autohotkey script too.
I'm using Autoit and found a joystick script here (https://www.autoitscript.com/forum/topic/10953-joystick-udf/?tab=comments#comment-323294) (thanks to original script by Ejoc and customized by Adam1213):#include <GUIConstants.au3>
Local $joy,$coor,$h,$s,$msg
$joy = _JoyInit()
dim $labels_text[8]=['X', 'Y', 'Z', 'R', 'U', 'V', 'POV', 'Buttons']
dim $labels_no=UBound($labels_text)
dim $labels[$labels_no]
dim $labels_value[$labels_no]
$label_len=0
for $text in $labels_text
$len=stringlen($text)
if $len>$label_len then
$label_len=$len
endif
next
$label_len*=6
GUICreate('Joystick Test', 200, 200)
GUICtrlCreateLabel('Joystick', 40, 20, 100, 20)
for $i=0 to $labels_no-1
GuiCtrlCreatelabel($labels_text[$i]&':', 10, 60+$i*12, $label_len, 12)
$labels[$i]=GuiCtrlCreatelabel('', 10+$label_len, 60+$i*12, 70, 12)
$labels_value[$i]=''
next
GUISetState()
while 1
$coord=_GetJoy($joy,0)
for $i=0 to UBound($coord)-1
if $coord[$i]<>$labels_value[$i] then
GUICtrlSetData($labels[$i], $coord[$i])
$labels_value[$i]=$coord[$i]
endif
next
sleep(10)
$msg =GUIGetMSG()
if $msg = $GUI_EVENT_CLOSE Then Exitloop
WEnd
$lpJoy=0
Func _JoyInit()
Local $joy
Global $JOYINFOEX_struct = "dword[13]"
$joy=DllStructCreate($JOYINFOEX_struct)
if @error Then Return 0
DllStructSetData($joy, 1, DllStructGetSize($joy), 1)
DllStructSetData($joy, 1, 255, 2)
return $joy
EndFunc
Func _GetJoy($lpJoy,$iJoy)
Local $coor,$ret
Dim $coor[8]
DllCall("Winmm.dll","int","joyGetPosEx", _
"int",$iJoy, _
"ptr",DllStructGetPtr($lpJoy))
if Not @error Then
$coor[0] = DllStructGetData($lpJoy,1,3)
$coor[1] = DllStructGetData($lpJoy,1,4)
$coor[2] = DllStructGetData($lpJoy,1,5)
$coor[3] = DllStructGetData($lpJoy,1,6)
$coor[4] = DllStructGetData($lpJoy,1,7)
$coor[5] = DllStructGetData($lpJoy,1,8)
$coor[6] = DllStructGetData($lpJoy,1,11)
$coor[7] = DllStructGetData($lpJoy,1,9)
EndIf
return $coor
EndFunc
the script shows a value, if a button is pressed. Several buttons together makes a sum. For examle a Super Nintendo USB-Gamepad (Ascii Art from here (http://osrevad.westopia.net/asciicontrollers.php). Thanks to osrevad):SNES PAD
L __ | | __ R
\ ___________________|_|_____________________ /
_,-' ____ '-._
,' S U P E R N I T E N D O _,-' `-._ `.
,' ___ -ENTERTAINMENT SYSTEM- ,' __ X `. `.
/ | | / / \ \ \
/ ___| |___ / __ \__/ __ A \ \
| | | ,. ,. | / \ / \ | !
! |___ ___| ,',' ,',' | \__/ __ \__/ | |
\ | | ',' '.' \ Y / \ / /
\ |___| SELECT START \ \__/ / /
`. ___________________ `._ B _,' ,'
`-._ _.'` `-._`'~-.,-~'`_.'`
`'~-.,-~'` `'~-.,-~'`
DPAD
U
___
UL | | UR
___| |___
L | | R
|___ ___|
DL | | DR
|___|
D
L 16
R 32
Y 4
X 8
B 1
A 2
START 64
SELECT 128
DPAD UP 0
DPAD UP / RIGHT 4500
DPAD RIGHT 9000
DPAD DOWN / RIGHT 13500
DPAD DOWN 18000
DPAD DOWN / LEFT 22500
DPAD LEFT 27000
DPAD UP / LEFT 31500
START + SELECT 192
-If you press Select Button, you get a Button value of 128.
-If you press Start Button, a Button value of 64
-Select and Start Button pressed together, a Button Value of 192 (128 + 64 = 192)
-If you press D-Pad Down a DPad value of 18000
(https://s12.directupload.net/images/200817/8ceupzb4.gif)
I've changed the script to my system. I'm using a textfile called systems.txt
this file contains different processes, that can be killed in taskmanager.
If you press a specific button combination, the script kills all processes from systems.txt.
start taskmanager and see, how process is called.
For example MyGame.exe *32
=> enter MyGame.exe (without *32) to txtfile:calc.exe
notepad.exe
mame64.exe
zsnesw.exe
FlatOut2.exe
UT2004.exe
scummvm.exe
MyGame.exe
If you want to press L + R + Select + Start + D-PAD Down
you have to set $coord[7] == "240" AND $coord[6] = "18000"
START + SELECT + L + R + DPAD DOWN
=> 64 + 128 + 16 + 32 = 240 AND 18000
(https://s12.directupload.net/images/200817/7xafr4um.gif)
; from here :
; https://www.autoitscript.com/forum/topic/10953-joystick-udf/?tab=comments#comment-323294
; original script from POST#1 doesnt works. tooked script from POST#4
#include <GUIConstants.au3>
#include <Misc.au3>
#include <File.au3>
Local $joy,$coor,$h,$s,$msg
$joy = _JoyInit()
dim $labels_text[8]=['X', 'Y', 'Z', 'R', 'U', 'V', 'POV', 'Buttons']
dim $labels_no=UBound($labels_text)
dim $labels[$labels_no]
dim $labels_value[$labels_no]
$label_len=0
for $text in $labels_text
$len=stringlen($text)
if $len>$label_len then
$label_len=$len
endif
next
$label_len*=6
while 1
$coord=_GetJoy($joy,0)
for $i=0 to UBound($coord)-1
if $coord[$i]<>$labels_value[$i] then
GUICtrlSetData($labels[$i], $coord[$i])
$labels_value[$i]=$coord[$i]
endif
next
sleep(10)
; ASCII ART from http://osrevad.westopia.net/asciicontrollers.php
;SNES PAD
; L __ | | __ R
; \ ___________________|_|_____________________ /
; _,-' ____ '-._
; ,' S U P E R N I T E N D O _,-' `-._ `.
; ,' ___ -ENTERTAINMENT SYSTEM- ,' __ X `. `.
; / | | / / \ \ \
; / ___| |___ / __ \__/ __ A \ \
; | | | ,. ,. | / \ / \ | !
; ! |___ ___| ,',' ,',' | \__/ __ \__/ | |
; \ | | ',' '.' \ Y / \ / /
; \ |___| SELECT START \ \__/ / /
; `. ___________________ `._ B _,' ,'
; `-._ _.'` `-._`'~-.,-~'`_.'`
; `'~-.,-~'` `'~-.,-~'`
;
;DPAD
; U
; ___
; UL | | UR
; ___| |___
; L | | R
; |___ ___|
; DL | | DR
; |___|
; D
;L 16
;R 32
;Y 4
;X 8
;B 1
;A 2
;START 64
;SELECT 128
;DPAD UP 0
;DPAD UP / RIGHT 4500
;DPAD RIGHT 9000
;DPAD DOWN / RIGHT 13500
;DPAD DOWN 18000
;DPAD DOWN / LEFT 22500
;DPAD LEFT 27000
;DPAD UP / LEFT 31500
;START + SELECT 192
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;START + SELECT + L + R + DPAD DOWN = 64 + 128 + 16 + 32 = 240 & 18000
If $coord[7] == "240" AND $coord[6] = "18000" Then
Dim $aTextlines
_FileReadToArray("systems.txt",$aTextlines)
For $i = 1 To UBound($aTextlines)-1
ProcessClose($aTextlines[$i])
Next
;set this exit as a comment : script loops
;Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndIf
$msg =GUIGetMSG()
if $msg = $GUI_EVENT_CLOSE Then Exitloop
WEnd
$lpJoy=0
Func _JoyInit()
Local $joy
Global $JOYINFOEX_struct = "dword[13]"
$joy=DllStructCreate($JOYINFOEX_struct)
if @error Then Return 0
DllStructSetData($joy, 1, DllStructGetSize($joy), 1)
DllStructSetData($joy, 1, 255, 2)
return $joy
EndFunc
Func _GetJoy($lpJoy,$iJoy)
Local $coor,$ret
Dim $coor[8]
DllCall("Winmm.dll","int","joyGetPosEx", _
"int",$iJoy, _
"ptr",DllStructGetPtr($lpJoy))
if Not @error Then
$coor[0] = DllStructGetData($lpJoy,1,3)
$coor[1] = DllStructGetData($lpJoy,1,4)
$coor[2] = DllStructGetData($lpJoy,1,5)
$coor[3] = DllStructGetData($lpJoy,1,6)
$coor[4] = DllStructGetData($lpJoy,1,7)
$coor[5] = DllStructGetData($lpJoy,1,8)
$coor[6] = DllStructGetData($lpJoy,1,11)
$coor[7] = DllStructGetData($lpJoy,1,9)
EndIf
return $coor
EndFunc
-
It's honestly nothing to complicated but this is how I handle each PC game
Run, BloodstainedRotN.exe, E:\GOG\Bloodstained Ritual of the Night, max
KeyWait, Joy12, D
WinClose, ahk_exe BloodstainedRotN-Win64-Shipping.exe
Here is another example
Run, UNDERTALE.exe, E:\New folder\Undertale, max
sleep, 5000
Send {F4}
KeyWait, Joy12, D
WinClose, ahk_exe UNDERTALE.exe
-
So note that my "emulator" is AutoHotkey and the roms are all .ahk files
-
Thanks to both of you !
So I've tried to use autohotkey to launch a game, it's perfect:
Run, ROTK.exe, C:\PC Games\LSDA Le Retour du Roi tm\, max
KeyWait, 3Joy7, D
WinClose, ahk_exe ROTK.exe
But I want to launch and exit "JoyToKey" in same time, only for this game, and it's not working correctly.
I've tried that:
Run, JoyToKey.exe, C:\JoyToKey\, min
sleep, 1000
Run, ROTK.exe, C:\PC Games\LSDA Le Retour du Roi tm\, max
KeyWait, 3Joy7, D
WinClose, ahk_exe ROTK.exe JoyToKey.exe
And when I press my hotkey, only the script ahk_exe close....
Am I doing something wrong ?
EDIT : it works now, joytokey start minimized so I think my script has no windows to close. I use Processclose so:
Run, JoyToKey.exe, C:\JoyToKey\, min
sleep, 1000
Run, ROTK.exe, C:\PC Games\LSDA Le Retour du Roi tm\, max
KeyWait, 3Joy7, D
Process,Close,JoyToKey.exe
WinClose, ahk_exe ROTK.exe
-
autohotkey looks interesting too.
If there is a free minute, then I'll have a look at it ^-^
to complete, same with autoit:#include <Misc.au3>
;Start Calculator
run("C:\Windows\System32\calc.exe")
;Start Notepad in Fullscreen
run("C:\Windows\System32\notepad","",@SW_MAXIMIZE)
;Start commandline
run("cmd.exe")
;Keylist for ispressed here : https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm
While 1
If _IsPressed ("41") AND ("53") AND ("44") AND ("46") Then
ProcessClose("Calc.exe")
ProcessClose("Notepad.exe")
;removing the semicolon, and the script stops loop / script goes to Exit
;Exit
EndIf
WEnd
By pressing a + s + d + f , calc and notepad closes