Advertisement
Einistein

Fantasy Ground right-click scroll + pointers

Dec 9th, 2020 (edited)
1,913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Fantasy Ground right-click scroll + pointers
  2. ; v1.03
  3.  
  4. #NoEnv
  5. #SingleInstance
  6.  
  7. SendMode Input
  8. SetMouseDelay 0
  9.  
  10. ; FG long right-click delay timeout in ms
  11. rc_timeout := 350
  12.  
  13. ; FG right-click sensitivity to movement in pixels, higher = less sensitive
  14. rc_sens := 1
  15.  
  16. ; Key bindings
  17. #If MouseIsOver("Fantasy Grounds") and !GetKeyState("LButton","P")
  18. MouseIsOver(WinTitle) {
  19.     MouseGetPos,,, Win
  20.     return WinExist(WinTitle . " ahk_id " . Win)
  21. }
  22.  
  23. RButton:: Goto FGrclick
  24. !RButton:: Goto FGrclick
  25. ^RButton:: Goto FGrclick
  26. +RButton:: Goto FGrclick
  27.  
  28. FGrclick:
  29. MouseGetPos, original_X, original_Y, this_id
  30. SetTimer, LongClick, % -rc_timeout ; long right-click?
  31.  
  32. Loop, {
  33.     If (!GetKeyState("Alt","P") and !GetKeyState("Ctrl","P") and !GetKeyState("Shift","P")) { ; check for modifiers keys
  34.         ToolTip,
  35.         fgmodifier:="none"
  36.     }
  37.     If (GetKeyState("Alt","P")) {
  38.         SetTimer, LongClick, Off
  39.         ToolTip, Cone
  40.         fgmodifier := "Alt"
  41.     }
  42.     If (GetKeyState("Ctrl","P")) {
  43.         SetTimer, LongClick, Off
  44.         ToolTip, Circle
  45.         fgmodifier := "Ctrl"
  46.     }
  47.     If (GetKeyState("Shift","P")) {
  48.         SetTimer, LongClick, Off
  49.         ToolTip, Square
  50.         fgmodifier := "Shift"
  51.     }
  52.  
  53.     MouseGetPos, new_X, new_Y ; check for mouse-position change
  54.     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)) {
  55.         switch fgmodifier {
  56.         Case "Alt": ; Square Pointer
  57.             MouseMove original_X, original_Y
  58.             Send, {AltDown}{RButton Down}{LButton Down}
  59.             KeyWait, RButton
  60.             Send, {AltUp}{RButton Up}{LButton Up}
  61.             Break
  62.         Case "Ctrl": ; Circle Pointer
  63.             MouseMove original_X, original_Y
  64.             Send, {CtrlDown}{RButton Down}{LButton Down}
  65.             KeyWait, RButton
  66.             Send, {CtrlUp}{RButton Up}{LButton Up}
  67.             Break
  68.         Case "Shift": ; Cone Pointer
  69.             MouseMove original_X, original_Y
  70.             Send, {ShiftDown}{RButton Down}{LButton Down}
  71.             KeyWait, RButton
  72.             Send, {ShiftUp}{RButton Up}{LButton Up}
  73.             Break
  74.         Case "none": ; Scroll via right-click drag
  75.             MouseMove original_X, original_Y
  76.             SetTimer, LongClick, Off
  77.             Send, {MButton Down}
  78.             KeyWait, RButton
  79.             Send, {MButton Up}
  80.             Break
  81.         }
  82.     } else { ; open right-click menu if no mouse-position change
  83.         Sleep 10 ; delay to detect button release
  84.         if (!GetKeyState("RButton","P") and (new_X <= original_X+rc_sens) and (new_Y <= original_Y+rc_sens)) {
  85.             SetTimer, LongClick, Off
  86.             ToolTip,
  87.             Send, {RButton Down}{RButton Up}
  88.             Break
  89.         }
  90.     }
  91. } Until !GetKeyState("RButton", "P")
  92. ToolTip,
  93. Return
  94.  
  95. ; On long right-click:
  96. LongClick:
  97. ToolTip, Arrow
  98. Loop, {
  99.     MouseGetPos, new_X, new_Y
  100.     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)) {
  101.         MouseMove original_X, original_Y
  102.         Send, {LButton Down}{RButton Down}
  103.         KeyWait, RButton
  104.         Send, {LButton Up}Mode Input
  105.         ToolTip,
  106.         Exit
  107.     } else {
  108.         If (GetKeyState("Alt","P") or GetKeyState("Ctrl","P") or GetKeyState("Shift","P")) { ; modifiers keys exit long-click
  109.             Break
  110.         }
  111.     }
  112. } Until !GetKeyState("RButton", "P")
  113. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement