sraasch wrote: Sorry to dredge up an old post...
I'm wondering if anyone has translated this to the new syntax?
What do you mean by new syntax? And what would that accomplish? The script is working great for me in Windows 10 as well as Windows 11.
Isn't it working for you? Or do you just want to make it shorter?
Edit:
New YouTube video link:
MedBooster wrote: I changed the script to use the display in which the selected window is
The issue with using the cursor "Point" position is that the mouse position gets repositioned to the main display once you rotate a display,
so I recommend using the script that rotates the display the active/selected window is in. It is also more stable
(the "Point" one does not always work on other displays than the primary display)
[Mod edit: Replaced quote tags with [code][/code] tags.]Code: Select all
#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. ;help received by [+] https://www.autohotkey.com/boards/viewtopic.php?f=76&t=87453&p=492976&sid=643f7444d745cc540978272aece7091f#p492976 #singleInstance force #noEnv ;put together by MedBooster thank you to everyone that helped! ;the rotation code by masonjar13 ChangeDisplaySettingsExW down below edited in get active monitor down below lookup:={"^!down":[0,0],"^!right":[1,1],"^!up":[2,0],"^!left":[3,1]} return ^!down:: ^!right:: ^!up:: ^!left:: display := GetMonitorName("Window") if (lookup[a_thisHotkey][2]){ ; rotating to portrait sRes:=strSplit((cRes:=screenRes_Get(display)),["x","@"]) if (sRes[2] < sRes[1]) { cRes:=sRes[2] "x" sRes[1] "@" sRes[3] } } else { ; rotating to landscape sRes:=strSplit((cRes:=screenRes_Get(display)),["x","@"]) if (sRes[2] > sRes[1]) { cRes:=sRes[2] "x" sRes[1] "@" sRes[3] } } screenRes_Set(cRes,display,lookup[a_thisHotkey][1]) return screenRes_Set(WxHaF, Disp:=0, orient:=0) { ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution ; edited orientation in by Masonjar13 Local DM, N:=VarSetCapacity(DM,220,0), F:=StrSplit(WxHaF,["x","@"],A_Space) Return DllCall("ChangeDisplaySettingsExW",(Disp=0 ? "Ptr" : "WStr"),Disp,"Ptr",NumPut(F[3],NumPut(F[2],NumPut(F[1] ,NumPut(32,NumPut(0x5C0080,NumPut(220,NumPut(orient,DM,84,"UInt")-20,"UShort")+2,"UInt")+92,"UInt"),"UInt") ,"UInt")+4,"UInt")-188, "Ptr",0, "Int",0, "Int",0) } screenRes_Get(Disp:=0) { ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution Local DM, N:=VarSetCapacity(DM,220,0) Return DllCall("EnumDisplaySettingsW", (Disp=0 ? "Ptr" : "WStr"),Disp, "Int",-1, "Ptr",&DM)=0 ? "" : Format("{:}x{:}@{:}", NumGet(DM,172,"UInt"),NumGet(DM,176,"UInt"),NumGet(DM,184,"UInt")) } ;Usage instructions below start of Vieira GetMonitorName ;GetMonitorName("Point") -> Uses the mouse location ;GetMonitorName("Window") -> Uses the active window ;GetMonitorName("Rect", [1921, 1, 1951, 10]) -> Uses the provided rectangle coordinates ;Get monitor cursor by Vieira GetMonitorName(method := "Window", coords := "", default_to := "Nearest") { static default := {"Null": MONITOR_DEFAULTTONULL := 0x0, "Primary": MONITOR_DEFAULTTOPRIMARY := 0x1, "Nearest": MONITOR_DEFAULTTONEAREST := 0x2} If (method = "Window") hMonitor := DllCall("MonitorFromWindow", "UInt", WinExist("A"), "UInt", default[default_to], "Ptr") Else if (method = "Point") { if coords x := coords[1], y := coords[2] Else MouseGetPos, x, y hMonitor := DllCall("MonitorFromPoint", "Int64", (x&0xFFFFFFFF) | (y<<32), "Int", default[default_to], "Ptr") } Else if (method = "Rect") { if !coords Throw % "Rect method requires coordinates" VarSetCapacity(RECT, 16, 0) NumPut(coords[4], NumPut(coords[3], NumPut(coords[2], NumPut(coords[1], &RECT, "UInt"), "UInt"), "UInt"), "UInt") hMonitor := DllCall("MonitorFromRect", "Ptr", &RECT, "UInt", default[default_to], "Ptr") } Else Throw % "Invalid method" NumPut(VarSetCapacity(MONITORINFOEX, 40 + (32 << !!A_IsUnicode)), MONITORINFOEX, 0, "UInt") DllCall("GetMonitorInfoW", "Ptr", hMonitor, "Ptr", &MONITORINFOEX) return StrGet(&MONITORINFOEX + 40, 32) }