Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- SLACK_PATH := "path\to\slack\slack.exe"
- SLACK_EXE_NAM := "slack.exe"
- #MaxThreadsPerHotkey 3
- #z:: ; Win+Z
- IfWinExist, ahk_exe %SLACK_EXE_NAM%
- {
- WinActivate
- }
- Else
- {
- Run, %SLACK_PATH%
- Sleep, 5000
- WinActivate
- }
- WinGetPos, X, Y, W, H, ahk_exe %SLACK_EXE_NAM%
- w_coord := 0
- h_coord := 0
- if KeepWinZRunning ; This means an underlying thread is already running the loop below.
- {
- KeepWinZRunning := false ; Signal that thread's loop to stop.
- return ; End this thread
- }
- KeepWinZRunning := true
- Loop
- {
- Random, w_coord, 1, W - 5
- Random, h_coord, 1, H - 5
- MouseMove, w_coord, h_coord, SLACK_GLOBAL_MOUSE_SPEED
- Sleep, 2000
- if not KeepWinZRunning
- break
- }
- KeepWinZRunning := false ; Reset
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement