Is there really no way to set screen orientation in modern Windows 10? Topic is solved
Is there really no way to set screen orientation in modern Windows 10?
Hi, trying to write a script that will toggle my display between portrait and landscape, but it seems like all the old methods don't work anymore on my Win 10 Home? Using AHK_L v1.1.33.02.
The old fashioned Ctrl+Alt+Arrow hotkeys don't work anymore.
This code didn't work for me. It's apparently NVIDIA only, but it didn't work on my Nvidia device either. (The device I'm targeting has Intel IRIS Plus graphics, though.)
https://autohotkey.com/board/topic/20851-changedisplayorientation/
The other methods rely on a windows API call to "User32.dll\ChangeDisplaySettings".
https://www.autohotkey.com/boards/viewtopic.php?t=51447
However, looking at MS's docs, display orientation is not an available field?
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsa
Any help would be much appreciated, thanks!
The old fashioned Ctrl+Alt+Arrow hotkeys don't work anymore.
This code didn't work for me. It's apparently NVIDIA only, but it didn't work on my Nvidia device either. (The device I'm targeting has Intel IRIS Plus graphics, though.)
https://autohotkey.com/board/topic/20851-changedisplayorientation/
The other methods rely on a windows API call to "User32.dll\ChangeDisplaySettings".
https://www.autohotkey.com/boards/viewtopic.php?t=51447
However, looking at MS's docs, display orientation is not an available field?
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsa
Any help would be much appreciated, thanks!
Re: Is there really no way to set screen orientation in modern Windows 10? Topic is solved
All works like it should.
Code: Select all
VarSetCapacity(DEVMODE, 220, 0)
NumPut(220, DEVMODE, 68, "short") ; dmSize
DllCall("EnumDisplaySettingsW", "ptr", 0, "int", -1, "ptr", &DEVMODE)
width := NumGet(DEVMODE, 172, "uint")
height := NumGet(DEVMODE, 176, "uint")
NumPut(width, DEVMODE, 176, "int")
NumPut(height, DEVMODE, 172, "int")
NumPut(DMDO_90 := 1, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 172, "int")
NumPut(height, DEVMODE, 176, "int")
NumPut(DMDO_DEFAULT := 0, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
Re: Is there really no way to set screen orientation in modern Windows 10?
@malcev - Any idea why I can't make it rotating 180°/270°, while with 90° it isn't rotating clockwise but counter-clockwise??
Code edited after @malcev's advise below. Tested.
Code: Select all
; 'scr(een)Rotate'-function based on code kindly provided by malcev:
; https://www.autohotkey.com/boards/viewtopic.php?p=384743#p384743
; Params ...
; clock mode: 3/6/9/12
; angle degree: 0/90/180/270/360
; direction: t/r/b/l
F1::scrRotate(3) ; rotating to 3 o'clock
F2::scrRotate(180) ; rotating 180°
F3::scrRotate(9) ; rotating to 9 o'clock
F4::scrRotate(360) ; rotating 360° (default)
F5::scrRotate("b") ; rotating towards the bottom of the screen
F6::scrRotate("default") ; rotating to default position (12 o'clock AKA 360°/0° AKA 'top')
F7::scrRotate("d") ; rotating to d(efault) position (12 o'clock AKA 360°/0° AKA 'top')
F8::scrRotate() ; throwing 'parameter advise'-message.
scrRotate(param:="") {
if param not in 0,3,6,9,12,90,180,270,360,default,d,t,r,b,l
MsgBox % "Valid parameters are: 0,3/6/9/12/90/180/270/360/default/d/t/r/b/l"
else {
mode:= (param=0) || (param=12) || (param=360) || (param=t)? DMDO_DEFAULT:=0
: (param=9) || (param=90) || (param=r) ? DMDO_90 :=1
: (param=6) || (param=180) || (param=b) ? DMDO_180 :=2
: (param=3) || (param=270) || (param=l) ? DMDO_270 :=3
: (param=default) ? DMDO_DEFAULT:=0
: (param=d) ? DMDO_DEFAULT:=0
VarSetCapacity(DEVMODE, 220, 0)
NumPut(220, DEVMODE, 68, "short") ; dmSize
DllCall("EnumDisplaySettingsW", "ptr", 0, "int", -1, "ptr", &DEVMODE)
width := NumGet(DEVMODE, 172, "uint")
height := NumGet(DEVMODE, 176, "uint")
NumPut(width, DEVMODE, 176, "int")
NumPut(height, DEVMODE, 172, "int")
NumPut(mode, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
}
}
Re: Is there really no way to set screen orientation in modern Windows 10?
I dont understand Your code, but it should be like this:
Code: Select all
VarSetCapacity(DEVMODE, 220, 0)
NumPut(220, DEVMODE, 68, "short") ; dmSize
DllCall("EnumDisplaySettingsW", "ptr", 0, "int", -1, "ptr", &DEVMODE)
width := NumGet(DEVMODE, 172, "uint")
height := NumGet(DEVMODE, 176, "uint")
NumPut(width, DEVMODE, 176, "int")
NumPut(height, DEVMODE, 172, "int")
NumPut(DMDO_90 := 1, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 172, "int")
NumPut(height, DEVMODE, 176, "int")
NumPut(DMDO_180 := 2, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 176, "int")
NumPut(height, DEVMODE, 172, "int")
NumPut(DMDO_270 := 3, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 172, "int")
NumPut(height, DEVMODE, 176, "int")
NumPut(DMDO_DEFAULT := 0, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
Re: Is there really no way to set screen orientation in modern Windows 10?
Thx mate Much appreciated
Re: Is there really no way to set screen orientation in modern Windows 10?
I'm asking for alot, but is there a way to set parameters for rotating 2nd display with this?
Re: Is there really no way to set screen orientation in modern Windows 10?
I too would be very grateful for guidance on how to modify this script so it changed the secondary monitor's display settings (and not the first).
-
- Posts: 1
- Joined: 21 May 2022, 15:16
Re: Is there really no way to set screen orientation in modern Windows 10?
For some reason when I use these they set my screen brightness really low. Does anyone know how to fix that?
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
Any ideas on how to maybe make this script work on multiple displays? Perhaps working in the display the cursor is in (instead of the current way it only affects the main (primary) display)
Here's some ideas
to perhaps get the monitor the cursor is in
maybe this as a function
but I have no idea how to run the script, or use the one that is already here – I just can't see where the display is specified in the script
Here's some ideas
Code: Select all
MWAGetMonitorMouseIsIn() { ; By "Maestr0" ~ https://www.autohotkey.com/boards/viewtopic.php?t=54557
Coordmode, Mouse, Screen
MouseGetPos, Mx, My
SysGet, MonitorCount, 80
Loop, %MonitorCount% {
SysGet, mon%A_Index%, Monitor, %A_Index%
if (Mx >= mon%A_Index%left) && (Mx < mon%A_Index%right)
&& (My >= mon%A_Index%top) && (My < mon%A_Index%bottom) {
ActiveMon := A_Index
break
}
}
Return ActiveMon
}
maybe this as a function
Code: Select all
ScreenResolution_Set(WxHaF, Disp:=0, orientation:=0) { ; v0.90 By SKAN on D36I/D36M @ tiny.cc/screenresolution ; edited orientation in by Masonjar13 and CloakerSmoker
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(orientation,DM,84,"UInt")-20,"UShort")+2,"UInt")+92,"UInt"),"UInt"),"UInt")+4,"UInt")-188, "Ptr",0, "Int",0, "Int",0)
}
but I have no idea how to run the script, or use the one that is already here – I just can't see where the display is specified in the script
Re: Is there really no way to set screen orientation in modern Windows 10?
@Kitsoon
@katrielf
@MedBooster
Use this script and tweak the Disp variable for alternate displays.
viewtopic.php?t=85527
https://github.com/Masonjar13/RotateScreen/blob/main/screen%20rotate.ahk
Identify display number for Disp w/ ScreenResolution_List:
viewtopic.php?t=77664
@katrielf
@MedBooster
Use this script and tweak the Disp variable for alternate displays.
viewtopic.php?t=85527
https://github.com/Masonjar13/RotateScreen/blob/main/screen%20rotate.ahk
Identify display number for Disp w/ ScreenResolution_List:
viewtopic.php?t=77664
Re: Is there really no way to set screen orientation in modern Windows 10?
Sorry. Identify MonitorName for Disp via SysGet as specified in the same linked thread:[+] wrote: ↑24 Nov 2022, 20:37Identify display number for Disp w/ ScreenResolution_List:
viewtopic.php?t=77664
https://www.autohotkey.com/docs/commands/SysGet.htm#MonitorName
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
@[+]
change the disp as in the ``Disp:=0``''s or
the script you shared also works well, BUT I switched out "\.\DISPLAY1" with ".\DISPLAY" MWAGetMonitorMouseIsIn() and it did nothing.
At this point I'm just using both scripts, since for some reason the script you shared always changes the rotation of my laptop screen (even if it is not the primary display)
and the original one of this post changes the primary screen orientation montitor
So I'm just using both with slightly different keyboard shortcuts.
change the disp as in the ``Disp:=0``''s or
the script you shared also works well, BUT I switched out "\.\DISPLAY1" with ".\DISPLAY" MWAGetMonitorMouseIsIn() and it did nothing.
At this point I'm just using both scripts, since for some reason the script you shared always changes the rotation of my laptop screen (even if it is not the primary display)
and the original one of this post changes the primary screen orientation montitor
So I'm just using both with slightly different keyboard shortcuts.
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
vieira on the autohotkey discord came up with this, so maybe it helps if anyone sees how to add it if it actually is as simple as replacing the ".\DISPLAY1" .
This is what I got so far, but it is not working . Might have something to do with function outputs before adding a string prefix
Here I compare it to the actually working code *see attachment 1
This is what I got so far, but it is not working . Might have something to do with function outputs before adding a string prefix
Code: Select all
#singleInstance force
#noEnv
;Usage instructions below
;GetActiveMonitorName("Point") -> Uses the mouse location
;GetActiveMonitorName("Point", [1921, 1]) -> Uses the provided coordinates
;GetActiveMonitorName("Window") -> Uses the active window
;GetActiveMonitorName("Rect", [1921, 1, 1951, 10]) -> Uses the provided rectangle coordinates
;By Vieira se usage instructions above
GetActiveMonitorName(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 | y << 32, "UInt", 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)
}
display := "\.\"GetActiveMonitorName("Window")
lookup:={"^!down":[0,0],"^!right":[1,1],"^!up":[2,0],"^!left":[3,1]}
return
^!down::
^!right::
^!up::
^!left::
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"))
}
Re: Is there really no way to set screen orientation in modern Windows 10?
Yep, that's the difference between WinAPI function each script calls. @malcev's script uses ChangeDisplaySettingsW while @Masonjar13's script uses ChangeDisplaySettingsExW. The W variant only changes the settings of the default display device while the ExW variant allows a specific display device to be chosen via lpszDeviceName.MedBooster wrote: ↑25 Nov 2022, 10:54@[+]
for some reason the script you shared always changes the rotation of my laptop screen (even if it is not the primary display)
and the original one of this post changes the primary screen orientation montitor
If you unfurl the condensed code in ExW version's functions, you'll get something like the following:
Code: Select all
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)
NumPut(orient,DM,84,"UInt")
NumPut(220,DM,68,"UShort")
NumPut(0x5C0080,DM,72,"UInt")
NumPut(32,DM,168,"UInt")
NumPut(F[1],DM,172,"UInt")
NumPut(F[2],DM,176,"UInt")
NumPut(F[3],DM,184,"UInt")
Return DllCall("ChangeDisplaySettingsExW",(Disp=0 ? "Ptr" : "WStr"),Disp,"Ptr",&DM, "Ptr",0, "Int",0, "Int",0)
}
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
I have no idea how to "pass that as Disp into screenRes_Set"
I get that we should be using Masonjar13's ChangeDisplaySettingsExW script, but not how we could input the display := "\.\"GetActiveMonitorName("Window")
(if that is even valid formatting)
I get that we should be using Masonjar13's ChangeDisplaySettingsExW script, but not how we could input the display := "\.\"GetActiveMonitorName("Window")
(if that is even valid formatting)
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
as an alternative, we could maybe also tweak one of the scripts to have two different keyboard shortcuts for let's say Display1 vs. Display 2, if they are just named according to the number they have in the windows display settings.
(To those of you interested in this kind of script)
(To those of you interested in this kind of script)
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
FINALLY FINALLY FINALLY, this has been bugging me for months.
Here you go guys, the script rotates the display your cursor is currently in.
Here you go guys, the script rotates the display your cursor is currently in.
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("Point")
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("Point", [1921, 1]) -> Uses the provided coordinates
;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)
}
-
- Posts: 54
- Joined: 24 Nov 2022, 12:33
Re: Is there really no way to set screen orientation in modern Windows 10?
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.]
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)
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)
}
Re: Is there really no way to set screen orientation in modern Windows 10?
Sorry to dredge up an old post...
I'm wondering if anyone has translated this to the new syntax?
I'm wondering if anyone has translated this to the new syntax?