KaFu Posted March 2, 2012 Posted March 2, 2012 Hiho Forum, I'm looking for a way to rotate the display by 270 degrees. I know my screen supports that (CTRL+ALT+{Arrow Right} works fine). The attached script rotates the display by 90 degrees only. Has anyone come accross this issue? When running the attached script, either run it a second time or press CTRL+ALT+{Arrow Up} to reset the orientation to default. expandcollapse popup$h_DLL_user32 = DllOpen("user32.dll") Global Const $DMDO_DEFAULT = 0 Global Const $DMDO_90 = 1 Global Const $DMDO_180 = 2 Global Const $DMDO_270 = 3 Global Const $_tag_DEVMODE = "CHAR dmDeviceName[32];WORD dmSpecVersion;WORD dmDriverVersion;" & _ "WORD dmSize;WORD dmDriverExtra;DWORD dmFields;LONG dmPositionx;LONG dmPositiony;DWORD dmDisplayOrientation;DWORD dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "CHAR dmFormName[32];WORD dmLogPixels;DWORD dmBitsPerPel;DWORD dmPelsWidth;DWORD dmPelsHeight;" & _ "DWORD dmDisplayFlags;DWORD dmDisplayFrequency;" $DEVMODE = DllStructCreate($_tag_DEVMODE) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) Global Const $ENUM_CURRENT_SETTINGS = -1 Global Const $ENUM_REGISTRY_SETTINGS = -2 Local $B = DllCall($h_DLL_user32, "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($DEVMODE), "dword", BitOR(0x00000002, 0x00000004)) ConsoleWrite(DllStructGetData($DEVMODE, "dmSize") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDriverExtra") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_DISPLAYORIENTATION = 0x00800000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 DllStructSetData($DEVMODE, "dmFields", BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_DISPLAYORIENTATION)) DllStructSetData($DEVMODE, "dmDisplayOrientation", $DMDO_270) Local $stmp = DllStructGetData($DEVMODE, "dmPelsWidth") DllStructSetData($DEVMODE, "dmPelsWidth", DllStructGetData($DEVMODE, "dmPelsHeight")) DllStructSetData($DEVMODE, "dmPelsHeight", $stmp) Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $CDS_RESET = 0x40000000 Local Const $CDS_ENABLE_UNSAFE_MODES = 0x00000100 ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) $B = DllCall($h_DLL_user32, "int", "ChangeDisplaySettingsEx", "ptr", 0, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "int", BitOR($CDS_RESET, $CDS_UPDATEREGISTRY), "ptr", 0) ConsoleWrite($B[0] & @TAB & @error & @CRLF) Local Const $HWND_BROADCAST = 0xffff Local Const $WM_DISPLAYCHANGE = 0x007E $i_BitsPP = DllStructGetData($DEVMODE, "dmBitsPerPel") $i_Width = DllStructGetData($DEVMODE, "dmPelsWidth") $i_Height = DllStructGetData($DEVMODE, "dmPelsHeight") DllCall($h_DLL_user32, "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) Best Regards OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
water Posted March 2, 2012 Posted March 2, 2012 (edited) Here your script doesn't do anything. I have two Acer B243HL displays and when I press Ctrl-Alt-arrow it changes the orientation of the screen where the cursor is located. Your consolewrites (I added the name of the variable) gives the following result: dmSize 124 dmDriverExtra 0 dmPelsWidth 1920 dmPelsHeight 1080 dmDisplayOrientation 0 dmPelsWidth 1080 dmPelsHeight 1920 dmDisplayOrientation 3 After ChangeDisplaySettingsEx -2 0 My environment: +>11:05:11 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0407 Keyboard:00000407 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64) >Running:(3.3.8.0) Edited March 2, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
KaFu Posted March 2, 2012 Author Posted March 2, 2012 (edited) DISP_CHANGE_BADMODE = -2 The reason might be that you have attached two displays and the key-combo does not use ChangeDisplaySettingsEx internally? Edited March 2, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
KaFu Posted March 2, 2012 Author Posted March 2, 2012 I think I found it . The old data in the dmFields element must not be delete. This line fixes that: DllStructSetData($DEVMODE, "dmFields", BitOR(DllStructGetData($DEVMODE, "dmFields"), $DM_DISPLAYORIENTATION)) expandcollapse popup$h_DLL_user32 = DllOpen("user32.dll") Global Const $DMDO_DEFAULT = 0 Global Const $DMDO_90 = 1 Global Const $DMDO_180 = 2 Global Const $DMDO_270 = 3 Global Const $_tag_DEVMODE = "CHAR dmDeviceName[32];WORD dmSpecVersion;WORD dmDriverVersion;" & _ "WORD dmSize;WORD dmDriverExtra;DWORD dmFields;LONG dmPositionx;LONG dmPositiony;DWORD dmDisplayOrientation;DWORD dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "CHAR dmFormName[32];WORD dmLogPixels;DWORD dmBitsPerPel;DWORD dmPelsWidth;DWORD dmPelsHeight;" & _ "DWORD dmDisplayFlags;DWORD dmDisplayFrequency;" $DEVMODE = DllStructCreate($_tag_DEVMODE) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) Global Const $ENUM_CURRENT_SETTINGS = -1 Global Const $ENUM_REGISTRY_SETTINGS = -2 Local $B = DllCall($h_DLL_user32, "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($DEVMODE), "dword", BitOR(0x00000002, 0x00000004)) ConsoleWrite(DllStructGetData($DEVMODE, "dmSize") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDriverExtra") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_DISPLAYQUERYORIENTATION = 0x01000000 Local Const $DM_DISPLAYORIENTATION = 0x00800000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 DllStructSetData($DEVMODE, "dmFields", BitOR(DllStructGetData($DEVMODE, "dmFields"), $DM_DISPLAYORIENTATION)) Local $iOrientation = $DMDO_270 DllStructSetData($DEVMODE, "dmDisplayOrientation", $iOrientation) If $iOrientation = $DMDO_90 Or $iOrientation = $DMDO_270 Then ; swap width & height Local $stmp = DllStructGetData($DEVMODE, "dmPelsWidth") DllStructSetData($DEVMODE, "dmPelsWidth", DllStructGetData($DEVMODE, "dmPelsHeight")) DllStructSetData($DEVMODE, "dmPelsHeight", $stmp) EndIf Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $CDS_RESET = 0x40000000 Local Const $CDS_ENABLE_UNSAFE_MODES = 0x00000100 ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) $B = DllCall($h_DLL_user32, "int", "ChangeDisplaySettingsEx", "ptr", 0, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "int", $CDS_UPDATEREGISTRY, "ptr", 0) ConsoleWrite($B[0] & @TAB & @error & @CRLF) Local Const $HWND_BROADCAST = 0xffff Local Const $WM_DISPLAYCHANGE = 0x007E $i_BitsPP = DllStructGetData($DEVMODE, "dmBitsPerPel") $i_Width = DllStructGetData($DEVMODE, "dmPelsWidth") $i_Height = DllStructGetData($DEVMODE, "dmPelsHeight") DllCall($h_DLL_user32, "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
water Posted March 2, 2012 Posted March 2, 2012 It's working here too now! At least for screen 1. Just as an info: Ctrl-Alt-arrow seems to change the orientation of the screen where the cursor is currently located. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
KaFu Posted March 2, 2012 Author Posted March 2, 2012 Perfect, thanks a lot for testing . Yeah, at this stage it only changes the orientation on the primary display, for other display the lpszDeviceName in the ChangeDisplaySettingsEx function needs to be set accordingly. I guess the hotkey does this automatically. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
AccountKiller Posted March 23, 2012 Posted March 23, 2012 Hello. I'm very sorry to resurrect this thread, but I couldn't really find anything anywhere else. So I run this script and it works flawlessly; it does exactly what I need it to do. However when I run it again it does not reset back to the orientation which it was in before the first run. Is there a way to make this script basically a "toggle" of sorts? Run it once and it flips; run it again and it flips back? Currently I have to go into the nVidia settings each time to set it back which is kind of a hassle (which is why I was looking for an AutoIt script like this in the fist place xD). Any help is appreciated. Thanks. TheMusiKid
KaFu Posted March 23, 2012 Author Posted March 23, 2012 I wouldn't consider posting to a three weeks old thread a resurrection ... expandcollapse popupGlobal Const $HWND_BROADCAST = 0xffff Global Const $WM_DISPLAYCHANGE = 0x007E Global Const $SMTO_ABORTIFHUNG = 0x0002 Global Const $MSG_TIMEOUT = 500 Global $h_DLL_user32 = DllOpen("user32.dll") Global Const $DMDO_DEFAULT = 0 Global Const $DMDO_90 = 1 Global Const $DMDO_180 = 2 Global Const $DMDO_270 = 3 Global Const $_tag_DEVMODE = "CHAR dmDeviceName[32];WORD dmSpecVersion;WORD dmDriverVersion;" & _ "WORD dmSize;WORD dmDriverExtra;DWORD dmFields;LONG dmPositionx;LONG dmPositiony;DWORD dmDisplayOrientation;DWORD dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "CHAR dmFormName[32];WORD dmLogPixels;DWORD dmBitsPerPel;DWORD dmPelsWidth;DWORD dmPelsHeight;" & _ "DWORD dmDisplayFlags;DWORD dmDisplayFrequency;" $DEVMODE = DllStructCreate($_tag_DEVMODE) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) Global Const $ENUM_CURRENT_SETTINGS = -1 Global Const $ENUM_REGISTRY_SETTINGS = -2 Local $B = DllCall($h_DLL_user32, "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($DEVMODE), "dword", BitOR(0x00000002, 0x00000004)) ConsoleWrite(DllStructGetData($DEVMODE, "dmSize") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDriverExtra") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_DISPLAYQUERYORIENTATION = 0x01000000 Local Const $DM_DISPLAYORIENTATION = 0x00800000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 DllStructSetData($DEVMODE, "dmFields", BitOR(DllStructGetData($DEVMODE, "dmFields"), $DM_DISPLAYORIENTATION)) Local $iOrientation_New = $DMDO_270 Local $iOrientation_Current = DllStructGetData($DEVMODE, "dmDisplayOrientation") If $iOrientation_Current <> $DMDO_DEFAULT Then DllStructSetData($DEVMODE, "dmDisplayOrientation", $DMDO_DEFAULT) Else DllStructSetData($DEVMODE, "dmDisplayOrientation", $iOrientation_New) EndIf Local $stmp = DllStructGetData($DEVMODE, "dmPelsWidth") ; ; swap width & height DllStructSetData($DEVMODE, "dmPelsWidth", DllStructGetData($DEVMODE, "dmPelsHeight")) DllStructSetData($DEVMODE, "dmPelsHeight", $stmp) Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $CDS_RESET = 0x40000000 Local Const $CDS_ENABLE_UNSAFE_MODES = 0x00000100 ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) $B = DllCall($h_DLL_user32, "int", "ChangeDisplaySettingsEx", "ptr", 0, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "int", $CDS_UPDATEREGISTRY, "ptr", 0) ConsoleWrite($B[0] & @TAB & @error & @CRLF) $i_BitsPP = DllStructGetData($DEVMODE, "dmBitsPerPel") $i_Width = DllStructGetData($DEVMODE, "dmPelsWidth") $i_Height = DllStructGetData($DEVMODE, "dmPelsHeight") _SendMessageTimeout_Ex($HWND_BROADCAST, $WM_DISPLAYCHANGE, $i_BitsPP, $i_Height * 2 ^ 16 + $i_Width) Func _SendMessageTimeout_Ex($hWnd, $iMsg, $wParam = 0, $lParam = 0) Local $iRet = DllCall($h_DLL_user32, "lresult", "SendMessageTimeout", _ "hwnd", $hWnd, _ "uint", $iMsg, _ "wparam", $wParam, _ "lParam", $lParam, _ "uint", $SMTO_ABORTIFHUNG, _ "uint", $MSG_TIMEOUT, _ "dword_ptr*", 0) Return $iRet[7] EndFunc ;==>_SendMessageTimeout_Ex OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
AccountKiller Posted March 27, 2012 Posted March 27, 2012 (edited) I wouldn't consider posting to a three weeks old thread a resurrection ...Well that's a relief.Also thank you! .Much appreciated. Saved me a bunches of troubles (my grammar is fine; say nothing).EDIT: Unfortunately this only works when rotating 90 and 270 degrees, not 180 which is what I need (of course).I know the thread is about 270 so I'm sorry to veer off to 180. It will switch to 90/270 and back just as it should, but it does nothing if $iOrientation_New is set to $DMDO_180.Since it will only flip when the script is run, I could have it create a "boolean" file (if file exists, true; else false, etc.) and check that when it is run, but I don't really even understand how this script works completely to know where this check would go xD. Edited March 27, 2012 by TheMusiKid
KaFu Posted March 27, 2012 Author Posted March 27, 2012 Set the var $iOrientation_New according to your needs. expandcollapse popupGlobal Const $DMDO_DEFAULT = 0 Global Const $DMDO_90 = 1 Global Const $DMDO_180 = 2 Global Const $DMDO_270 = 3 Global $iOrientation_New = $DMDO_180 Global Const $HWND_BROADCAST = 0xffff Global Const $WM_DISPLAYCHANGE = 0x007E Global Const $SMTO_ABORTIFHUNG = 0x0002 Global Const $MSG_TIMEOUT = 500 Global $h_DLL_user32 = DllOpen("user32.dll") Global Const $_tag_DEVMODE = "CHAR dmDeviceName[32];WORD dmSpecVersion;WORD dmDriverVersion;" & _ "WORD dmSize;WORD dmDriverExtra;DWORD dmFields;LONG dmPositionx;LONG dmPositiony;DWORD dmDisplayOrientation;DWORD dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "CHAR dmFormName[32];WORD dmLogPixels;DWORD dmBitsPerPel;DWORD dmPelsWidth;DWORD dmPelsHeight;" & _ "DWORD dmDisplayFlags;DWORD dmDisplayFrequency;" $DEVMODE = DllStructCreate($_tag_DEVMODE) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) Global Const $ENUM_CURRENT_SETTINGS = -1 Global Const $ENUM_REGISTRY_SETTINGS = -2 Local $B = DllCall($h_DLL_user32, "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($DEVMODE), "dword", BitOR(0x00000002, 0x00000004)) ConsoleWrite(DllStructGetData($DEVMODE, "dmSize") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDriverExtra") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_DISPLAYQUERYORIENTATION = 0x01000000 Local Const $DM_DISPLAYORIENTATION = 0x00800000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 DllStructSetData($DEVMODE, "dmFields", BitOR(DllStructGetData($DEVMODE, "dmFields"), $DM_DISPLAYORIENTATION)) Global $iOrientation_Current = DllStructGetData($DEVMODE, "dmDisplayOrientation") If $iOrientation_Current = $iOrientation_New Then $iOrientation_New = $DMDO_DEFAULT Global $bSwap Switch $iOrientation_Current Case $DMDO_DEFAULT, $DMDO_180 Switch $iOrientation_New Case $DMDO_90, $DMDO_270 $bSwap = True Case Else $bSwap = False EndSwitch Case Else Switch $iOrientation_New Case $DMDO_DEFAULT, $DMDO_180 $bSwap = True Case Else $bSwap = False EndSwitch EndSwitch DllStructSetData($DEVMODE, "dmDisplayOrientation", $iOrientation_New) If $bSwap Then Global $stmp = DllStructGetData($DEVMODE, "dmPelsWidth") ; ; swap width & height DllStructSetData($DEVMODE, "dmPelsWidth", DllStructGetData($DEVMODE, "dmPelsHeight")) DllStructSetData($DEVMODE, "dmPelsHeight", $stmp) EndIf Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $CDS_RESET = 0x40000000 Local Const $CDS_ENABLE_UNSAFE_MODES = 0x00000100 ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF) ConsoleWrite(DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF & @CRLF) $B = DllCall($h_DLL_user32, "int", "ChangeDisplaySettingsEx", "ptr", 0, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "int", $CDS_UPDATEREGISTRY, "ptr", 0) ConsoleWrite($B[0] & @TAB & @error & @CRLF) $i_BitsPP = DllStructGetData($DEVMODE, "dmBitsPerPel") $i_Width = DllStructGetData($DEVMODE, "dmPelsWidth") $i_Height = DllStructGetData($DEVMODE, "dmPelsHeight") _SendMessageTimeout_Ex($HWND_BROADCAST, $WM_DISPLAYCHANGE, $i_BitsPP, $i_Height * 2 ^ 16 + $i_Width) Func _SendMessageTimeout_Ex($hWnd, $iMsg, $wParam = 0, $lParam = 0) Local $iRet = DllCall($h_DLL_user32, "lresult", "SendMessageTimeout", _ "hwnd", $hWnd, _ "uint", $iMsg, _ "wparam", $wParam, _ "lParam", $lParam, _ "uint", $SMTO_ABORTIFHUNG, _ "uint", $MSG_TIMEOUT, _ "dword_ptr*", 0) Return $iRet[7] EndFunc ;==>_SendMessageTimeout_Ex OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
KaFu Posted March 27, 2012 Author Posted March 27, 2012 You also might want to check out my program ICU (sig) to save the Desktops Icon positions before rotating ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
AccountKiller Posted March 29, 2012 Posted March 29, 2012 Set the var $iOrientation_New according to your needs.Yes, I know. I appreciate the reply though.It does nothing if $iOrientation_New is set to $DMDO_180.Like I said before, it works when it is set for 270 and 90. Just not 180 (flipped).You also might want to check out my program ICU (sig) to save the Desktops Icon positions before rotating ...Actually even when I run the 270 and 90 rotation modes, my icons stay where they are. Then again, I only have like 8 icons on my desktop anyways. (I'm a bit of an organization freak; don't judge me! )Any more ideas?
KaFu Posted March 29, 2012 Author Posted March 29, 2012 Did you test-run the script in post #10? It rotates by 180 degrees forth and back on a second run and works fine for me... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
AccountKiller Posted March 30, 2012 Posted March 30, 2012 Did you test-run the script in post #10? It rotates by 180 degrees forth and back on a second run and works fine for me...Woops. Sorry.No I hadn't. I figured you were just telling me to change the variable in the previous ones xD... Sorry about that.Yes. The latest code works amazingly thank you very much. Perfect.
spudw2k Posted March 30, 2012 Posted March 30, 2012 There is also a that Hermano created. It's included in the attachment. It's a little tool he wrote called iRotate. It run's in the system tray and allow you to rotate (obviously right) your desktop(s) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Blue_Drache Posted March 30, 2012 Posted March 30, 2012 I just usually pick it up and re-mount the base. *Shrug* Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Rogue5099 Posted March 31, 2012 Posted March 31, 2012 Smartee helped me out of the screen. Maybe this will help you rotating it 270 degreed. My projects: Inventory / Mp3 Inventory, Computer Stats
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now