#Persistent #NoEnv ; ----- xtravar's Gamepad helper autohotkey script ; Version: 2011.3.31 ; Author: xtravar@yahoo.com ; License: GPLv2 (http://www.gnu.org/licenses/gpl-2.0.html) ; Requires: Autohotkey - perhaps autohotkey_l? http://www.autohotkey.net ; Notes: I'm new at autohotkey so this probably isn't perfect. ; See my Dragon Age 2 script for examples. ; Disclaimer: There is no warranty. ; ------------------------------------------------------------------------ JP_Init() { SendMode Play SetFormat, FloatFast, 0.5 SetMouseDelay, -1 SetKeyDelay, -1 SetBatchLines -1 ListLines Off } JP_Wheel(direction) { if(direction > 0) { Send {WheelUp} } else if(direction < 0) { Send {WheelDown} } } JP_NegClamp(val,threshold,small,large) { if(val == 0) { } else if(val < -threshold) { val := -large } else if(val < 0) { val := -small } else if(val <= threshold) { val := small } else { val := large } return val } JP_Clamp(val,threshold,small,large) { if(val == 0) { } else if(val < -threshold) { val := large } else if(val < 0) { val := small } else if(val <= threshold) { val := small } else { val := large } return val } JP_KeyXY(byref curKeyX, byref curKeyY, valueX, valueY, negX, negY, posX, posY) { JP_KeyAxis(curKeyX, valueX, negX, posX) JP_KeyAxis(curKeyY, valueY, negY, posY) } JP_KeyAxis(byref curKey, direction, negKey, posKey) { if(direction > 0) { newKey := posKey } else if(direction < 0) { newKey := negKey } else { newKey := "" } if(curKey != newKey) { if(curKey != "") { Send, {%curKey% Up} } if(newKey != "") { Send, {%newKey% Down} } curKey := newKey } } JP_MouseMove(state,x,y,button = "") { if(state == 0) { if(button != "") { JP_Click(state,button) } } else if(state == 1) { DllCall("mouse_event", "UInt", 0x01, "UInt", x, "UInt", y, "UInt", 0, "ptr", 0) } else { if(button != "") { JP_Click(state,button) } } } JP_Click(state,button) { if(state == 0) { val := button == "Left" ? 0x02 : 0x08 DllCall("mouse_event", "UInt", val, "UInt", 0, "UInt", 0, "UInt", 0, "ptr", 0) } else if(state == 2) { val := button == "Left" ? 0x04 : 0x10 DllCall("mouse_event", "UInt", val, "UInt", 0, "UInt", 0, "UInt", 0, "ptr", 0) } } JP_RepeatKey(state,key) { if(state == 0) { Send {%key% Down} } else if(state == 1) { Send {%key% Up} Send {%key% Down} } else { Send {%key% Up} } } JP_PressKey(state,key) { if(state != 1) { dir := state ? "Up" : "Down" Send {%key% %dir%} } } JP_PressNow(state,key) { if(state == 0) { Send {%key%} } } JP_Tooltip(state, text) { if(state == 0) { Tooltip %text% } else if(state == 2) { Tooltip } } JP_DebugTooltip(state) { global local str if(state != 2) { str := XIX_DebugString() Tooltip %str% } else { Tooltip } }