TheNoobPolice

TheNoobPolice's Sensitivity Measuring Script

Dec 26th, 2020 (edited)
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*=
  2.  
  3. Turn script to test for sensitivity and accel by TheNoobPolice.
  4. This script leverages the AHI library for AutoHotKey to work with games that reject synthetic input (such as with Kovaak's Sensitivity matcher)
  5. Download links from here https://github.com/evilC/AutoHotInterception). RTFM before downloading.
  6. After installing Interception, copy the AHI lib folder into %USERFOLDER%/Documents/AutoHotKey (make the folder if it doesn't exist)
  7. Select all in this tab, paste into Notepad and save as somefilename.ahk, then run.
  8.  
  9. Keybinds:
  10.  
  11.  - Scrolllock to Enable/Disable hotkeys.
  12.  
  13.  - Press/hold ] to send a turn / hold for many turns
  14.  
  15.  - Press [ to halt mid-turn.
  16.  
  17.  - < > to nudge 1 count left and right (w/ shift for up and down)
  18.  
  19.  - Left/Right arrow keys, increase or decrease the number of packets sent every turn.
  20.  
  21.  - Up/Down arrow keys, alters the number of counts sent per packet.
  22.  
  23.  - Shift & Left/Right arrow keys, adjusts overall speed of turn:
  24.     (Setting to 1ms can result in dropped packets in some games (negative accel) Min/max is 1-15.)
  25.    
  26.  - Shift & Up/Down arrow keys, makes fine (decimal) adjustment of counts. Hold Ctrl also for larger adjustments
  27.  
  28.  - p to manually enter a number of packets
  29.  
  30.  - Ctrl & Alt & Insert, copies the counts distance value to clipboard
  31.  
  32.  - Backspace, can be used to measure FOV (alternates back and forth while held)
  33.  
  34.  - Ctrl & Alt & Home, resets the script to default values
  35.  
  36.  - Ctrl & S, reloads the script
  37.  
  38.  - Ctrl & Esc, closes the script and saves values
  39.  
  40. It is usually easier to get an accurate yaw value with the in-game sens at a low value.
  41. Run the turn many times to ensure it is accurate (i.e no drift).
  42. Once you have a perfect 360 turn, you can enter the total counts value in the spreadsheet linked here for more information and / or calculation of game sensitivity:
  43. https://docs.google.com/spreadsheets/d/e/2PACX-1vTOMMEEIGpBaiUqclmNQ-rTH-KE92iGJaecR8EZ22Rzbw-ByJgwBgOlgT7Zjz34jUsom1cuJ7U9PvpS/pubhtml#
  44.  
  45. */
  46. ; ------------------------------------------------------------------------------------------------------------------------------------------------------------------
  47.  
  48. ListLines Off
  49. #KeyHistory 0
  50. #SingleInstance force
  51. #include <AutoHotInterception>
  52. #NoEnv
  53. #MaxHotKeysPerInterval 200
  54. SetBatchlines, -1
  55. CoordMode, ToolTip, Screen
  56. SetScrollLockState, On
  57. OnExit("WriteValues")
  58. AHI := new AutoHotInterception()
  59. /*
  60. [SavedVariables]
  61. */
  62. packets=500
  63. counts=10
  64. fractional=500000
  65. ms=1
  66. Math := {newX :0, roundedX :0, carryX :0}
  67. BacknForth := 0
  68. directionTog := 0
  69. FOVMove := 0
  70. lastpackets := packets
  71. MenuView()
  72. Return
  73.    
  74. #if GetKeyState("Scrolllock", "T")
  75.    
  76.     left::
  77.     right::
  78.     +left::
  79.     +right::
  80.     up::
  81.     down::
  82.     *+up::
  83.     *+down::Fn(A_ThisHotkey)
  84.        
  85.     +down Up::
  86.     +up Up::adjust(0, 0)
  87.  
  88.     [::halt := 1
  89.  
  90.     ]::Startloop(0)
  91.     BS::Startloop(1)   
  92.    
  93.     .::nudger(1, 0)
  94.     +.::nudger(0, 1)
  95.     ,::nudger(-1, 0)
  96.     +,::nudger(0, -1)
  97.    
  98.     p Up::GoSub packetentry
  99.  
  100. #if
  101.  
  102. ^!insert::
  103.     Clipboard := RTrim(k, "0")
  104.     Msgbox,,, % "Counts distance value copied to Clipboard", 1.5
  105.     return
  106.    
  107. ^!home::
  108.     Msgbox, 4,, Are you sure you want set values to defaults?
  109.     IfMsgBox Yes
  110.         {
  111.         packets=500
  112.         counts=10
  113.         fractional=500000
  114.         ms=2
  115.         MenuView()
  116.         MsgBox, Values set to defaults
  117.         }
  118.     else
  119.         MsgBox, Overwrite cancelled. No changes made
  120.     return
  121.  
  122. ~^s up::Reload
  123.  
  124. ^Esc::ExitApp
  125.  
  126. packetentry:
  127.     lastpackets := packets
  128.     Inputbox, packets, Enter manual packets value below
  129.         if Errorlevel {
  130.             Msgbox, No value entered, previous value unaltered
  131.             packets := lastpackets
  132.         }
  133.     if packets is not integer
  134.         {
  135.         Msgbox, The value must be a whole number
  136.         packets := lastpackets
  137.         Goto packetentry
  138.         }
  139.     MenuView()
  140.     return 
  141.  
  142. SleepFunc(value){
  143.     DllCall("Sleep", "UInt", value)
  144. }
  145.  
  146. Fn(key){
  147.     global
  148.     if InStr(key,"+") {
  149.         (InStr(key,"left")&&(ms > 1))?(ms--):(InStr(key,"right")&&(ms < 15))?ms++:
  150.         (InStr(key,"up")&&(fractional < 999999))?adjust(1):
  151.         (InStr(key,"down")&&(fractional > 1))?adjust(0):("")
  152.     }
  153.     else {
  154.         (InStr(key,"left")&&(packets > 10))?packets--:InStr(key,"right")?packets++:
  155.         InStr(key,"up")?counts++:InStr(key,"down")?(counts > 1)?counts--:counts:= 1
  156.     }
  157.     MenuView()
  158. }
  159.    
  160. adjust(increase, state := 1){
  161.     global fractional
  162.     static counter
  163.    
  164.     if !state {
  165.         (fractional>999999)?fractional:=999999:(fractional<1)?fractional:=0:fractional:=fractional
  166.         counter := 0
  167.         MenuView()         
  168.         return
  169.     }
  170.     counter++
  171.     if GetKeyState("RCtrl", "P")
  172.         increase ? fractional+=9897 : fractional-=9897 
  173.     else if (counter < 10)
  174.         increase ? fractional++ : fractional--
  175.     else if (counter > 10)
  176.         increase ? fractional+=29 : fractional-=29
  177.     else if (counter > 100)
  178.         increase ? fractional+=159 : fractional-=159
  179. }
  180.  
  181. nudger(hor, vert){
  182.     global
  183.     AHI.Instance.SendMouseMoveRelative(11, hor, vert)
  184. }
  185.  
  186. Startloop(opt){
  187.     global
  188.     Math.carryX := 0
  189.     BacknForth := opt ? 1 : 0
  190.     if halt
  191.         halt := 0
  192.     loop
  193.         {
  194.         loop % packets
  195.             MouseMover()
  196.         Until halt
  197.         if BacknForth
  198.             directionTog := !directionTog
  199.         }
  200.     Until !GetKeyState((BacknForth ? "Backspace" : "]" ),"P")
  201. }
  202.  
  203. MouseMover(){
  204.     global
  205.     Math.newX := (counts + (fractional * 0.000001)) + Math.carryX, Math.roundedX := round(Math.newX)
  206.     if BacknForth
  207.         FOVMove := directionTog ? (Math.roundedX * -1) : Math.roundedX
  208.     AHI.Instance.SendMouseMoveRelative(11, (BacknForth ? FOVMove : Math.roundedX), 0)
  209.     Math.carryX := (Math.newX - Math.roundedX)
  210.     SleepFunc(ms)
  211. }
  212.  
  213. MenuView(){
  214.     global
  215.     f := (fractional * 0.000001)
  216.     k := packets * (counts + f)
  217.     tooltip, % "Left/Right to adjust number of packets`n`nUp/Down to adjust"
  218.      . " counts`n`nShift+Left/Right to change rate`n`nShift+Up/Down to fine"
  219.      . " tune`n`npackets = " packets "`ncounts = " counts "`nrate = " ms "ms`nfractional = " f "`nTotal"
  220.      . " Counts Per Turn = " RTrim(k, "0"), 1900, 30
  221. }
  222.  
  223. WriteValues(){
  224.     global
  225.     IniWrite, %packets%, %A_ScriptFullPath%, SavedVariables, packets
  226.     IniWrite, %counts%, %A_ScriptFullPath%, SavedVariables, counts
  227.     IniWrite, %fractional%, %A_ScriptFullPath%, SavedVariables, fractional
  228.     IniWrite, %ms%, %A_ScriptFullPath%, SavedVariables, ms
  229. }
  230.  
  231.  
Add Comment
Please, Sign In to add comment