Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Fantasy Ground right-click scroll + pointers
- ; v1.03
- #NoEnv
- #SingleInstance
- SendMode Input
- SetMouseDelay 0
- ; FG long right-click delay timeout in ms
- rc_timeout := 350
- ; FG right-click sensitivity to movement in pixels, higher = less sensitive
- rc_sens := 1
- ; Key bindings
- #If MouseIsOver("Fantasy Grounds") and !GetKeyState("LButton","P")
- MouseIsOver(WinTitle) {
- MouseGetPos,,, Win
- return WinExist(WinTitle . " ahk_id " . Win)
- }
- RButton:: Goto FGrclick
- !RButton:: Goto FGrclick
- ^RButton:: Goto FGrclick
- +RButton:: Goto FGrclick
- FGrclick:
- MouseGetPos, original_X, original_Y, this_id
- SetTimer, LongClick, % -rc_timeout ; long right-click?
- Loop, {
- If (!GetKeyState("Alt","P") and !GetKeyState("Ctrl","P") and !GetKeyState("Shift","P")) { ; check for modifiers keys
- ToolTip,
- fgmodifier:="none"
- }
- If (GetKeyState("Alt","P")) {
- SetTimer, LongClick, Off
- ToolTip, Cone
- fgmodifier := "Alt"
- }
- If (GetKeyState("Ctrl","P")) {
- SetTimer, LongClick, Off
- ToolTip, Circle
- fgmodifier := "Ctrl"
- }
- If (GetKeyState("Shift","P")) {
- SetTimer, LongClick, Off
- ToolTip, Square
- fgmodifier := "Shift"
- }
- MouseGetPos, new_X, new_Y ; check for mouse-position change
- If ((new_X < original_X-rc_sens) or (new_X > original_X+rc_sens) or (new_Y < original_Y-rc_sens) or (new_Y > original_Y+rc_sens)) {
- switch fgmodifier {
- Case "Alt": ; Square Pointer
- MouseMove original_X, original_Y
- Send, {AltDown}{RButton Down}{LButton Down}
- KeyWait, RButton
- Send, {AltUp}{RButton Up}{LButton Up}
- Break
- Case "Ctrl": ; Circle Pointer
- MouseMove original_X, original_Y
- Send, {CtrlDown}{RButton Down}{LButton Down}
- KeyWait, RButton
- Send, {CtrlUp}{RButton Up}{LButton Up}
- Break
- Case "Shift": ; Cone Pointer
- MouseMove original_X, original_Y
- Send, {ShiftDown}{RButton Down}{LButton Down}
- KeyWait, RButton
- Send, {ShiftUp}{RButton Up}{LButton Up}
- Break
- Case "none": ; Scroll via right-click drag
- MouseMove original_X, original_Y
- SetTimer, LongClick, Off
- Send, {MButton Down}
- KeyWait, RButton
- Send, {MButton Up}
- Break
- }
- } else { ; open right-click menu if no mouse-position change
- Sleep 10 ; delay to detect button release
- if (!GetKeyState("RButton","P") and (new_X <= original_X+rc_sens) and (new_Y <= original_Y+rc_sens)) {
- SetTimer, LongClick, Off
- ToolTip,
- Send, {RButton Down}{RButton Up}
- Break
- }
- }
- } Until !GetKeyState("RButton", "P")
- ToolTip,
- Return
- ; On long right-click:
- LongClick:
- ToolTip, Arrow
- Loop, {
- MouseGetPos, new_X, new_Y
- if ((new_X < original_X-rc_sens) or (new_X > original_X+rc_sens) or (new_Y < original_Y-rc_sens) or (new_Y > original_Y+rc_sens)) {
- MouseMove original_X, original_Y
- Send, {LButton Down}{RButton Down}
- KeyWait, RButton
- Send, {LButton Up}Mode Input
- ToolTip,
- Exit
- } else {
- If (GetKeyState("Alt","P") or GetKeyState("Ctrl","P") or GetKeyState("Shift","P")) { ; modifiers keys exit long-click
- Break
- }
- }
- } Until !GetKeyState("RButton", "P")
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement