Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance, Force
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Warn ; Recommended for catching common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- CoordMode, Mouse, Screen
- SetBatchLines, -1
- SetWinDelay, -1
- FirefoxClass := "MozillaWindowClass"
- FirefoxLocation := "C:\Program Files (x86)\Aurora\firefox.exe"
- FirefoxWorkingDir := ""
- X := 50
- Y := 50
- W := 300
- H := 300
- !f::
- WinGet, WinId,, % "ahk_class" . FirefoxClass
- IfWinActive, % "ahk_id" . WinId
- {
- WinGet, NextWinId, IDLast, % "ahk_class" . FirefoxClass
- If (WinId = NextWinId) ; Only one window is active
- {
- WinMove, % "ahk_id" . RunAndWait(FirefoxLocation, FirefoxWorkingDir, "ahk_class" . FirefoxClass),, % X, % Y, % W, % H
- Return
- }
- Else
- {
- WinActivate, % "ahk_id" . NextWinId
- Return
- }
- }
- Else
- {
- IfWinExist, % "ahk_id" . WinId
- {
- WinActivate, % "ahk_id" . WinId
- Return
- }
- Else
- {
- Run, % FirefoxLocation, % FirefoxWorkingDir
- Return
- }
- }
- Return
- RunAndWait(Location, WorkingDir, WinTitle)
- {
- WinGet, CurrWinCount, Count, % WinTitle
- TargetWinCount := CurrWinCount + 1
- Run, % Location, % WorkingDir
- Count := 0
- While (CurrWinCount < TargetWinCount)
- {
- Sleep, 100
- WinGet, CurrWinCount, Count, % WinTitle
- Count := Count + 1
- If (Count > 600) ; One minute has passed
- {
- Return 0
- }
- }
- WinGet, NewWinId,, % WinTitle
- Return NewWinId
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement