Advertisement
lalonso97

antisleeper_standalone.ahk

Oct 23rd, 2024 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 1.05 KB | Software | 0 0
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6. SLACK_PATH := "path\to\slack\slack.exe"
  7. SLACK_EXE_NAM := "slack.exe"
  8.  
  9. #MaxThreadsPerHotkey 3
  10. #z:: ; Win+Z
  11.  
  12. IfWinExist, ahk_exe %SLACK_EXE_NAM%
  13. {
  14.   WinActivate
  15. }
  16. Else
  17. {
  18.   Run, %SLACK_PATH%
  19.   Sleep, 5000
  20.   WinActivate
  21. }
  22.  
  23. WinGetPos, X, Y, W, H, ahk_exe %SLACK_EXE_NAM%
  24.  
  25. w_coord :=  0
  26. h_coord :=  0
  27.  
  28. if KeepWinZRunning ; This means an underlying thread is already running the loop below.
  29. {
  30.   KeepWinZRunning := false ; Signal that thread's loop to stop.
  31.   return ; End this thread
  32. }
  33. KeepWinZRunning := true
  34. Loop
  35. {
  36.   Random, w_coord, 1, W - 5
  37.   Random, h_coord, 1, H - 5
  38.   MouseMove, w_coord, h_coord, SLACK_GLOBAL_MOUSE_SPEED
  39.   Sleep, 2000
  40.  
  41.   if not KeepWinZRunning
  42.     break
  43. }
  44. KeepWinZRunning := false ; Reset
  45. return
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement