Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance force
- SetTitleMatchMode, 2
- Sleep, 50 ; initial pause
- ; Version 1.9.0 as of 16.10.2025 DD/MM/YY format
- ; ==============================
- ; USER CONFIGURATION
- ; ==============================
- WaitTime := 50 ; ms to wait after activating window and between key presses
- ; ------------------------------
- ; APP LIST CONFIGURATION
- ; ------------------------------
- ; PartialWindowNameX: static part of the window title
- ; MethodsX: F11, WSE, AE (F11 WIN SHIFT ENTER ALT ENTER)
- PartialWindowName1 := "Netflix"
- Methods1 := "F11"
- PartialWindowName2 := "Calculator"
- Methods2 := "WSE"
- PartialWindowName3 := "Edge"
- Methods3 := "WSE,F11,AE"
- ; ==============================
- ; SCRIPT LOGIC
- ; ==============================
- ; Detect how many apps are defined automatically
- MaxApps := 100 ; upper limit to check
- AppCount := 0 ; do not change this cuz stuff might break
- Loop, %MaxApps%
- {
- VarName := "PartialWindowName" . A_Index
- if !IsSet(%VarName%)
- break
- AppCount := A_Index
- }
- ; Get all windows in Z-order
- WinGet, id, List
- MostRecentHwnd := ""
- MostRecentMethods := ""
- MostRecentName := ""
- ; Loop through windows topmost first to find the most recent app in the list
- Loop, %id%
- {
- hwnd := id%A_Index%
- WinGetTitle, title, ahk_id %hwnd%
- if (title = "")
- continue
- ; Loop through apps
- Loop, %AppCount%
- {
- VarName := "PartialWindowName" . A_Index
- MethodVar := "Methods" . A_Index
- CurrName := %VarName%
- if InStr(title, CurrName)
- {
- MostRecentHwnd := hwnd
- MostRecentMethods := %MethodVar%
- MostRecentName := CurrName
- break 2
- }
- }
- }
- ; --- Fullscreen the most recent app ---
- if (MostRecentHwnd != "")
- {
- WinRestore, ahk_id %MostRecentHwnd%
- WinActivate, ahk_id %MostRecentHwnd%
- Sleep, %WaitTime%
- StringSplit, MethodArray, MostRecentMethods, `,
- Loop, %MethodArray0%
- {
- method := MethodArray%A_Index%
- if (method = "WSE")
- Send, #+{Enter}
- else if (method = "F11")
- Send, {F11}
- else if (method = "AE")
- Send, !{Enter}
- Sleep, %WaitTime%
- }
- ; Minimize other apps in the list
- Loop, %AppCount%
- {
- VarName := "PartialWindowName" . A_Index
- CurrName := %VarName%
- if (CurrName != MostRecentName)
- {
- WinGet, hwndOther, ID, %CurrName%
- if hwndOther
- WinMinimize, ahk_id %hwndOther%
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment