#1
|
|||
|
|||
Help with an AutoHotKey Script I\'m using
Hi I have a script that is working fine for me and am trying to add some new funtionality using a gamepad controller I bought.
<font class="small">Code:</font><hr /><pre>;;;;;;;;;;;;;;Here is what I have in my old script working fine: ;;;;;;;;;;;;;;This is the functionality I am trying to get using my gamepad ; WindowLeft Numpad4:: CoordMode, Mouse, Relative MouseMove,-400,300 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% return ; WindowDown Numpad2:: CoordMode, Mouse, Relative MouseMove,400,900 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% return ; WindowRight Numpad6:: CoordMode, Mouse, Relative MouseMove,1200,300 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% return ; WindowUp Numpad8:: CoordMode, Mouse, Relative MouseMove,400,-300 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% return ;;;;;;;;;;;;;;;;;Here is some script I am using currently to do something else with the POV controls of my gamepad GetKeyState, JoyPOV, %JoystickNumber%JoyPOV if JoyPOV = -1 ; No angle. return if JoyPOV=0 ; Forward { ;MouseClick, left, 240, 474 ;Sleep, 100 MouseClick, left, 240, 474 Sleep, 100 } else if JoyPOV between 5000 and 9500 ; Forward { ;MouseClick, left, 550, 474 ;Sleep, 100 MouseClick, left, 550, 474 Sleep, 100 } else if JoyPOV between 20000 and 27500 ; Forward { ;MouseClick, left, 240, 474 ;Sleep, 100 MouseClick, left, 240, 474 Sleep, 100 } else if JoyPOV between 12000 and 18500 ; Back { ;MouseClick, left, 385, 474 ;Sleep, 100 MouseClick, left, 385, 474 Sleep, 100 } return ;;;;;;;;;;I cut and paste resulting in this and its doesn't do anything GetKeyState, JoyPOV, %JoystickNumber%JoyPOV if JoyPOV = -1 ; No angle. return if JoyPOV=0 { CoordMode, Mouse, Relative MouseMove,400,-300 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% } else if JoyPOV between 5000 and 9500 { CoordMode, Mouse, Relative MouseMove,1200,300 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% } else if JoyPOV between 20000 and 27500 { CoordMode, Mouse, Relative MouseMove,-400,300 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% } else if JoyPOV between 12000 and 18500 { CoordMode, Mouse, Relative MouseMove,400,900 MouseGetPos, curPosX, curPosY, curWin WinGetTitle, title, ahk_id %curWin% WinActivate, %title% } return</pre><hr /> any ideas why my "if else" function doesn't seem to be able to use the POV controls of my gamepad to move the mouse and change the active table for me? Thanks --climber [/ QUOTE ] |
#2
|
|||
|
|||
Re: Help with an AutoHotKey Script I\'m using
You basically need to have an endless loop which continually queries 1JoyV. Use GetKeyState.
There is sample code in the .chm help file for using a joystick. I think it's under sample scripts or something like that. Run that code and you'll see how a joystick is controlled. If you want, send me a PM and I'll send my joystick script when I get home. |
#3
|
|||
|
|||
Re: Help with an AutoHotKey Script I\'m using
I had trouble with this too when I tried to get my gamepad working.
Here's bits of from my script (these are my Will Hill settings) Put this bit of code at the top of your script, before any hotkey assignments like Joypad buttons. <font color="green"> <font class="small">Code:</font><hr /><pre> SetTimer, WatchPOV, 50 return </pre><hr /></font> This sets up the timer to check the state of the POV button. You can then put in any hotkey assignments. After your hotkey assignments, you have the function that is triggered by the timer. <font color="green"> <font class="small">Code:</font><hr /><pre> WatchPOV: GetKeyState, POV, JoyPOV ; Get position of the POV control. if POV < 0 ; No angle to report KeyToHoldDown = else if POV between 0 and 4500 ; 0 to 45 degrees: Up - Check/Call { MouseClick, left, 588, 548 Sleep, 100 } else if POV between 4501 and 13500 ; 45 to 135 degrees: Right - Raise { MouseClick, left, 712, 559 Sleep, 100 } else if POV between 13501 and 22500 ; 135 to 225 degrees: Down - Post Blinds { MouseClick, left, 446, 541 Sleep, 100 } else ; 225 to 315 degrees: Left - Fold { MouseClick, left, 447, 580 Sleep, 100 } return </pre><hr /> </font> Hope that helps SwingSwingSwing |
|
|