Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array.au3>
- #include <file.au3>
- OnAutoItExitRegister("CLEANUP")
- Opt("SendKeyDelay", 0)
- Opt("SendKeyDownDelay", 0)
- Global $qdown = false, $edown = False
- Global $stream = Run(@ComSpec & " /c c:\androidsdk\platform-tools\", @SystemDir, @SW_HIDE, $STDERR_MERGED + $STDIN_CHILD)
- ; The purpose of this initial loop is just to wait until adb.exe begins to send XSENSOR messages
- while 1
- $lines = StdoutRead($stream)
- if StringInStr($lines, "XSENSOR") Then
- sleep(50)
- ExitLoop
- EndIf
- WEnd
- ; Main loop
- while 1
- $lines = StdoutRead($stream)
- local $str = StringRight($lines, 85)
- Local $Match = StringRegExp($lines, "[,]HIGH[,]([^,]+)[,]([^,]+)[,]([\d.-]+)$", 3)
- If IsArray($Match) Then
- ; I have it checking for either PUBG or for Notepad, that way you can open notepad to test. It should type Q's and E's as you rotate your phone.
- if ( WinActive("[TITLE:PLAYERUNKNOWN'S BATTLEGROUNDS;CLASS:UnrealWindow]") or WinActive("Untitled - Notepad") ) Then
- $x = Number($Match[0])
- ; Change -1 and 1 below to adjust the range which is required for Q or E to be released when you stop leaning.
- if ($x > -1) and $edown Then
- $edown = False
- Send("{e Up}")
- sleep(20)
- ElseIf ($x < 1) and $qdown Then
- $qdown = False
- Send("{q Up}")
- sleep(20)
- EndIf
- ; Change -3 and 3 below to adjust the threshold required to trigger pressing down Q and E
- if ($x > 3) and not $qdown Then
- $qdown = True
- Send("{q Down}")
- ElseIf ( $x < -3) and not $edown Then
- $edown = True
- Send("{e Down}")
- EndIf
- EndIf
- EndIf
- sleep(20) ;you can try removing this 20ms sleep to experiment with responsiveness, it is here for CPU usage considerations
- WEnd
- Func CLEANUP() ;adb.exe has troulbe shutting down sometimes, this function is called when you exit this script.
- while ProcessExists("adb.exe")
- ProcessClose("adb.exe")
- WEnd
- Exit
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement