I'm using autoit for this.
By pushing SELECT + START + DPAD DOWN + L + R on a snes pad, the process OpenBOR.exe will be closed. (
see section OPENBor here)
Source as follows here: ($coord[7] == "240" means the sum of L + R + START + SELECT together / simultaneously pressed (16 + 32 + 128 + 64 = 240 )
(
thanks to Ejoc and Adam1213 for original and customized sourcecode and
thanks to osrevad for Ascii-Art:
; 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
;____________________________________________________________________
; Original program by Ejoc ;
; Improved by Adam1213 (autoit 3.2 compatiblity + improved labels ;
;____________________________________________________________________
#include <GUIConstants.au3>
#include <Misc.au3>
;_________________ SETUP_____________________________________
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]
;__________ CONFIG ____________________________________________
;---------- Find the max length of the longest label --------------
$label_len=0
for $text in $labels_text
$len=stringlen($text)
if $len>$label_len then
$label_len=$len
endif
next
$label_len*=6
;_____________ GUI _______________________________________________
;~ 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)
;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
;~ If $coord[7] == "16" Then
;~ msgbox(0, "", "L")
;~ ;R
;~ ElseIf $coord[7] == "32" Then
;~ msgbox(0, "", "R")
;~ ;Y
;~ ElseIf $coord[7] == "4" Then
;~ msgbox(0, "", "Y")
;~ ;X
;~ ElseIf $coord[7] == "8" Then
;~ msgbox(0, "", "X")
;~ ;B
;~ ElseIf $coord[7] == "1" Then
;~ msgbox(0, "", "B")
;~ ;A
;~ ElseIf $coord[7] == "2" Then
;~ msgbox(0, "", "A")
;~ ;START
;~ ElseIf $coord[7] == "64" Then
;~ msgbox(0, "", "START")
;~ ;SELECT
;~ ElseIf $coord[7] == "128" Then
;~ msgbox(0, "", "SELECT")
;~ ; DPAD UP
;~ ElseIf $coord[6] == "0" Then
;~ msgbox(0, "", "U")
;~ ; DPAD UP / RIGHT
;~ ElseIf $coord[6] == "4500" Then
;~ msgbox(0, "", "UR")
;~ ; DPAD RIGHT
;~ ElseIf $coord[6] == "9000" Then
;~ msgbox(0, "", "R")
;~ ; DPAD DOWN / RIGHT
;~ ElseIf $coord[6] == "13500" Then
;~ msgbox(0, "", "DR")
;~ ; DPAD DOWN
;~ ElseIf $coord[6] == "18000" Then
;~ msgbox(0, "", "D")
;~ ; DPAD DOWN / LEFT
;~ ElseIf $coord[6] == "22500" Then
;~ msgbox(0, "", "DL")
;~ ;DPAD LEFT
;~ ElseIf $coord[6] == "27000" Then
;~ msgbox(0, "", "L")
;~ ;DPAD UP / LEFT
;~ ElseIf $coord[6] == "31500" Then
;~ msgbox(0, "", "UL")
;~ ;START + SELECT
;~ ElseIf $coord[7] == "192" Then
;~ msgbox(0, "", "START + SELECT")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;START + SELECT + L + R + DPAD DOWN
If $coord[7] == "240" AND $coord[6] = "18000" Then
;msgbox(0, "", "EXIT")
ProcessClose("OpenBOR.exe")
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndIf
$msg =GUIGetMSG()
if $msg = $GUI_EVENT_CLOSE Then Exitloop
WEnd
$lpJoy=0 ; Joyclose
;======================================
; _JoyInit()
;======================================
Func _JoyInit()
Local $joy
Global $JOYINFOEX_struct = "dword[13]"
$joy=DllStructCreate($JOYINFOEX_struct)
if @error Then Return 0
DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct)
DllStructSetData($joy, 1, 255, 2) ;dwFlags = GetAll
return $joy
EndFunc
;======================================
; _GetJoy($lpJoy,$iJoy)
; $lpJoy Return from _JoyInit()
; $iJoy Joystick # 0-15
; Return Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
; Buttons down
;
; *POV This is a digital game pad, not analog joystick
; 65535 = Not pressed
; 0 = U
; 4500 = UR
; 9000 = R
; Goes around clockwise increasing 4500 for each position
;======================================
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
If you want to edit & customize, see section ;;; EDIT HERE ;;; at line #148:
If you want loop script, simply set Exit to comment:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;START + SELECT + L + R + DPAD DOWN
If $coord[7] == "240" AND $coord[6] = "18000" Then
;msgbox(0, "", "EXIT")
ProcessClose("OpenBOR.exe")
;Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If you want to send ALT + F4, if a specific windows is in front / focus (for example Windows Notepad / Editor):
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;START + SELECT + L + R + DPAD DOWN
If $coord[7] == "240" AND $coord[6] = "18000" Then
;msgbox(0, "", "EXIT")
WinWaitActive("Untitled - Notepad","")
WinWait("Untitled - Notepad","")
Send("!+{F4}",0)
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If you want to close a collection of emulator systems / more than one application:
create a file called : emulators.txt
fill it with the names of tasks from taskmanager. for example:
vlc.exe
zsnes.exe
scummvm.exe
notepad.exe
calc.exe
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;START + SELECT + L + R + DPAD DOWN
If $coord[7] == "240" AND $coord[6] = "18000" Then
;msgbox(0, "", "EXIT")
$file = FileOpen("emulators.txt", 0)
While 1
Local $line = FileReadLine($file)
If @error = -1 Then ExitLoop
; MsgBox(0, "", $line)
ProcessClose ( $line )
WEnd
FileClose($file)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
all the enclosed tasks will be closed at the same time