; Joystick Launch ; 8/22/2011 Travis Smith ; http://SensoriumEmbedded.com ; Derived from: Joystick Test Script ; http://www.autohotkey.com ;Below are some sample code lines you can cut/paste below the ";button number X function" ; locations at the bottom of this file to assign that function to the selected input /* Run, Notepad.exe ;starts the notepad application Send !{Tab} ;ALT-Tab to select different application Send 12{Enter} ;send the JS but # as kbd strokes (12 shown, followed by Enter key) Send {Media_Play_Pause} ;pause/play the media player */ ;Of course, these are only a couple samples, see these links for more on the AutoHotKey language: ; http://www.autohotkey.com/docs/Tutorial.htm ; http://www.autohotkey.com/docs/commands.htm ; http://www.autohotkey.com/docs/commands/Send.htm ; http://www.autohotkey.com/docs/commands/Run.htm ; If you want to unconditionally use a specific joystick number, change ; the following value from 0 to the number of the joystick (1-16). ; A value of 0 causes the joystick number to be auto-detected: JoystickNumber = 0 ; END OF CONFIG SECTION. Do not make changes below this point unless ; you wish to alter the basic functionality of the script. ; Auto-detect the joystick number if called for: if JoystickNumber <= 0 { Loop 16 ; Query each joystick number to find out which ones exist. { GetKeyState, JoyName, %A_Index%JoyName if JoyName <> { JoystickNumber = %A_Index% break } } if JoystickNumber <= 0 { MsgBox The system does not appear to have any joysticks. ExitApp } } #SingleInstance SetFormat, float, 03 ; Omit decimal point from axis position percentages. GetKeyState, joy_buttons, %JoystickNumber%JoyButtons GetKeyState, joy_name, %JoystickNumber%JoyName GetKeyState, joy_info, %JoystickNumber%JoyInfo Loop { Loop, %joy_buttons% { GetKeyState, joy%a_index%, %JoystickNumber%joy%a_index% ;execute on button press down edge only if joy%a_index% = D if prev_joy%a_index% = U { if a_index = 1 { ;button number 1 function Send {Media_Play_Pause} } else if a_index = 2 { ;button number 2 function } else if a_index = 3 { ;button number 3 function } else if a_index = 4 { ;button number 4 function } else if a_index = 5 { ;button number 5 function } else if a_index = 6 { ;button number 6 function } else if a_index = 7 { ;button number 7 function } else if a_index = 8 { ;button number 8 function } else if a_index = 9 { ;button number 9 function } else if a_index = 10 { ;button number 10 function } else if a_index = 11 { ;button number 11 function } else if a_index = 12 { ;button number 12 function } else if a_index = 13 { ;button number 13 function } else if a_index = 14 { ;button number 14 function } else if a_index = 15 { ;button number 15 function } else if a_index = 16 { ;button number 16 function } else if a_index = 17 { ;button number 17 function } else if a_index = 18 { ;button number 18 function } else if a_index = 19 { ;button number 19 function } else if a_index = 20 { ;button number 20 function } } prev_joy%a_index% = % joy%a_index% ;store latest value } Sleep, 10 } return