redi_ban

Priffins TallMacro

Feb 23rd, 2024
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. #SingleInstance force
  2. #MaxHotkeysPerInterval 600
  3. SetKeyDelay, 0
  4. SetWinDelay, 0
  5.  
  6. ; Zoom Settings
  7.  
  8. global hotkey := "*Numpad9" ; https://www.autohotkey.com/docs/v1/Hotkeys.htm
  9.  
  10. global zoom := "Thin"
  11.  
  12. /*
  13. "Default" - 3600 tall, best for normal measuring without boat ~ 0.004 standard deviation
  14. "BoatEye" - 16384 tall ~ 0.0007 standard deviation with boat eye
  15. "Thin" ~ Same as above but smaller width for less GPU usage, recommended if using an OBS Projector
  16. Custom ~ format WxH e.g. "320x8192"
  17. */
  18.  
  19. ; Projector Settings
  20. global useProjector := True ; Ignore other settings if set to false
  21. global projectorName := "Windowed Projector (Scene) - Mag"
  22. global projectorWidth := -1 ; (-1 = default)
  23.  
  24. ; Sensitivity Settings
  25. global zoomSensitivity := 1 ; Change windows sens to this value when zooming in. Set to 0 to disable.
  26.  
  27. ; Window Settings (-1 = default)
  28. global zoomXPos := -1
  29. global zoomYPos := -1
  30. global projectorXPos := -1
  31. global projectorYPos := -1
  32.  
  33. ; Do Not Edit
  34.  
  35.  
  36. global zoomWidth := 0
  37. global zoomHeight := 0
  38.  
  39. if (zoom=="Default") {
  40. zoomWidth := A_ScreenWidth
  41. zoomHeight := 3600
  42. }
  43. else if (zoom=="BoatEye") {
  44. zoomWidth := A_ScreenWidth
  45. zoomHeight := 16384
  46. }
  47.  
  48. else if (zoom=="Thin") {
  49. zoomWidth := 384
  50. zoomHeight := 16384
  51. }
  52.  
  53. else if (InStr(zoom, "x")) {
  54. zoom := StrSplit(zoom, "x")
  55. zoomWidth := zoom[1]
  56. zoomHeight := zoom[2]
  57. }
  58.  
  59. else {
  60. MsgBox, Invalid zoom setting
  61. ExitApp
  62. }
  63.  
  64. global projectorWidth := (projectorWidth == -1) ? Floor((A_ScreenWidth - zoomWidth) / 2) : projectorWidth
  65. global projectorHeight := A_ScreenHeight / (A_ScreenWidth / projectorWidth)
  66.  
  67. global zoomXPos := (zoomXPos == -1) ? Floor((A_ScreenWidth - zoomWidth) / 2) : zoomXPos
  68. global zoomYPos := (zoomYPos == -1) ? Floor((A_ScreenHeight - zoomHeight) / 2) : zoomYPos
  69. global projectorXPos := (projectorXPos == -1) ? 0 : projectorXPos
  70. global projectorYPos := (projectorYPos == -1) ? ((A_ScreenHeight - projectorHeight) / 2) : projectorYPos
  71.  
  72.  
  73. global ix := 0
  74. global iy := 0
  75. global iw := 0
  76. global ih := 0
  77.  
  78.  
  79. global initialStyle := 0
  80. global initialExStyle := 0
  81.  
  82. global initialSens := 0
  83. DllCall("SystemParametersInfo", "UInt", 0x70, "UInt", 0, "UIntP", initialSens, "UInt", 0)
  84.  
  85. checkProjector() {
  86. if (WinExist(projectorName) == "0x0")
  87. Msgbox, Windowed Projector not found, check projectorName is set correctly
  88. WinGet, state, MinMax, %projectorName%
  89. if (state==-1)
  90. WinRestore, %projectorName%
  91. WinSet, Style, -0xC40000, %projectorName%
  92. WinSet, AlwaysOnTop, On, %projectorName%
  93.  
  94. }
  95.  
  96. getActiveHwnd() {
  97. WinGet, hwnd, ID, A
  98. WinGet, name, ProcessName, % "ahk_id " hwnd
  99. if (name == "javaw.exe" || name == "java.exe")
  100. return hwnd
  101. else
  102. return False
  103. }
  104.  
  105. Zoom() {
  106. WinGetPos,x,y,w,h,A
  107. if (h != zoomHeight){
  108. ix := x
  109. iy := y
  110. iw := w
  111. ih := h
  112. WinGet, initialStyle, Style, A
  113. WinGet, initialExStyle, ExStyle, A
  114. WinSet, Style, -0xC40000, A
  115. activeWindow := getActiveHwnd()
  116. DllCall("SetWindowPos", "Ptr", activeWindow, "UInt", 0, "Int", zoomXPos, "Int", zoomYPos, "Int", zoomWidth, "Int", zoomHeight, "UInt", 0x0400)
  117. if (useProjector) {
  118. checkProjector()
  119. DllCall("SetWindowPos", "Ptr", WinExist(projectorName), "UInt", 0, "Int", projectorXPos, "Int", projectorYPos, "Int", projectorWidth, "Int", projectorHeight, "UInt", 0x0400)
  120. }
  121.  
  122. if (zoomSensitivity != 0)
  123. DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, zoomSensitivity, UInt, 0)
  124. }
  125. else {
  126. WinSet, Style, %initialStyle%, A
  127. WinSet, ExStyle, %initialExStyle%, A
  128. activeWindow := getActiveHwnd()
  129. DllCall("SetWindowPos", "Ptr", activeWindow, "UInt", 0, "Int", ix, "Int", iy, "Int", iw, "Int", ih, "UInt", 0x0400)
  130. if (useProjector)
  131. DllCall("SetWindowPos", "Ptr", WinExist(projectorName), "UInt", 0, "Int", 0, "Int", -A_ScreenHeight, "Int", 1, "Int", 1, "UInt", 0x0400)
  132. DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, UInt, initialSens, UInt, 0)
  133. }
  134. return
  135. }
  136.  
  137. ResetWindowPosition() {
  138. WinGetPos,x,y,w,h,A
  139. activeWindow := getActiveHwnd()
  140. x := 0, y := 0
  141. DllCall("SetWindowPos", "Ptr", activeWindow, "UInt", 0, "Int", x, "Int", y, "Int", w, "Int", h, "UInt", 0x0400)
  142. }
  143.  
  144. if (zoomXPos + zoomWidth > projectorXPos and zoomXPos < projectorXPos + projectorWidth and useProjector)
  145. MsgBox, The projector and game window overlap, either reduce zoomWidth or projectorWidth and then reload
  146. if (useProjector) {
  147. if (WinExist(projectorName) = "0x0")
  148. MsgBox, Windowed Projector not found. Check if projectorName is set correctly.
  149. else
  150. DllCall("SetWindowPos", "Ptr", WinExist(projectorName), "UInt", 0, "Int", 0, "Int", -A_ScreenHeight, "Int", 1, "Int", 1, "UInt", 0x0400)
  151. }
  152. #If WinActive("Minecraft") && (WinActive("ahk_exe javaw.exe") || WinActive("ahk_exe java.exe"))
  153. Hotkey, %hotkey%, Zoom
  154. ; Hotkey, !%hotkey%, ResetWindowPosition ; Remove semi colon to add reset window position hotkey (alt + zoom hotkey), in case the window gets stuck off screen.
  155.  
  156.  
Advertisement
Add Comment
Please, Sign In to add comment