nMagmaDude151n

AHK Fullscreen

Oct 16th, 2025 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | Source Code | 0 0
  1. #SingleInstance force
  2. SetTitleMatchMode, 2
  3. Sleep, 50 ; initial pause
  4.  
  5. ; Version 1.9.0 as of 16.10.2025 DD/MM/YY format
  6. ; ==============================
  7. ; USER CONFIGURATION
  8. ; ==============================
  9. WaitTime := 50 ; ms to wait after activating window and between key presses
  10.  
  11. ; ------------------------------
  12. ; APP LIST CONFIGURATION
  13. ; ------------------------------
  14. ; PartialWindowNameX: static part of the window title
  15. ; MethodsX: F11, WSE, AE (F11 WIN SHIFT ENTER ALT ENTER)
  16.  
  17. PartialWindowName1 := "Netflix"
  18. Methods1 := "F11"
  19.  
  20. PartialWindowName2 := "Calculator"
  21. Methods2 := "WSE"
  22.  
  23. PartialWindowName3 := "Edge"
  24. Methods3 := "WSE,F11,AE"
  25.  
  26. ; ==============================
  27. ; SCRIPT LOGIC
  28. ; ==============================
  29.  
  30. ; Detect how many apps are defined automatically
  31. MaxApps := 100 ; upper limit to check
  32. AppCount := 0 ; do not change this cuz stuff might break
  33. Loop, %MaxApps%
  34. {
  35. VarName := "PartialWindowName" . A_Index
  36. if !IsSet(%VarName%)
  37. break
  38. AppCount := A_Index
  39. }
  40.  
  41. ; Get all windows in Z-order
  42. WinGet, id, List
  43.  
  44. MostRecentHwnd := ""
  45. MostRecentMethods := ""
  46. MostRecentName := ""
  47.  
  48. ; Loop through windows topmost first to find the most recent app in the list
  49. Loop, %id%
  50. {
  51. hwnd := id%A_Index%
  52. WinGetTitle, title, ahk_id %hwnd%
  53. if (title = "")
  54. continue
  55.  
  56. ; Loop through apps
  57. Loop, %AppCount%
  58. {
  59. VarName := "PartialWindowName" . A_Index
  60. MethodVar := "Methods" . A_Index
  61. CurrName := %VarName%
  62. if InStr(title, CurrName)
  63. {
  64. MostRecentHwnd := hwnd
  65. MostRecentMethods := %MethodVar%
  66. MostRecentName := CurrName
  67. break 2
  68. }
  69. }
  70. }
  71.  
  72. ; --- Fullscreen the most recent app ---
  73. if (MostRecentHwnd != "")
  74. {
  75. WinRestore, ahk_id %MostRecentHwnd%
  76. WinActivate, ahk_id %MostRecentHwnd%
  77. Sleep, %WaitTime%
  78.  
  79. StringSplit, MethodArray, MostRecentMethods, `,
  80. Loop, %MethodArray0%
  81. {
  82. method := MethodArray%A_Index%
  83. if (method = "WSE")
  84. Send, #+{Enter}
  85. else if (method = "F11")
  86. Send, {F11}
  87. else if (method = "AE")
  88. Send, !{Enter}
  89. Sleep, %WaitTime%
  90. }
  91.  
  92. ; Minimize other apps in the list
  93. Loop, %AppCount%
  94. {
  95. VarName := "PartialWindowName" . A_Index
  96. CurrName := %VarName%
  97. if (CurrName != MostRecentName)
  98. {
  99. WinGet, hwndOther, ID, %CurrName%
  100. if hwndOther
  101. WinMinimize, ahk_id %hwndOther%
  102. }
  103. }
  104. }
  105.  
Advertisement
Add Comment
Please, Sign In to add comment