Jump to content

Invert Desktop


Recommended Posts

So I got bored and wrote just some send() keys to invert Windows 7 desktop. I'm looking for an easier way and that would work on main Windows OS's (XP, Vista, 7)

Windows 7:

Send("#r")
Sleep(500)
Send("desk.cpl")
Send("{ENTER}")
Sleep(500)
Send("{TAB 3}")
Send("{DOWN 2}")
Send("{TAB 7}")
Send("{ENTER}")
Sleep(1000)
Send("{LEFT}")
Send("{ENTER}")
Send("!{F4}")
Link to comment
Share on other sites

Reason for this post is that several people have found it to be funny to invert other employee's screens and they call me to fix it and complain that me walking them through the fix (i.e. Display properties) is hard for them to accompish while inverted. The script above was to invert my own screen to test a Revert (Revert = change Send("{DOWN 2}") to Send("{UP 2}")). I was just going to make a little program that could be stored on the server and I could simply have them do a run command to run the Revert (that way not even using a mouse). I want this to work on XP, Vista, and 7 to be able to handle all computers in building.

The Send keys works but of course whenever you do Send keys it could be easily interrupted and may shutdown there machine especailly the Alt+F4 Send()

Link to comment
Share on other sites

hi,

With Intel graphics cards (like mine) there some hot-keys that help. Ctrl+Alt+Up restores the display to normal.

Posted Image

-smartee

EDIT: Typo with hot-key example

Edited by smartee
Link to comment
Share on other sites

I've checked the graphic's settings and most of these units don't have any hotkey settings. The culprits are using the windows display functions. It would be easy to tell the user to just hit Ctrl+Alt+Down on some units but it's not the case for all. Some of the WinXP machines are just that simple but on the newer units i.e. Win Vista, 7 is the ones that doesn't work. We are in the process of converting all the machines to Windows 7. I am working on also blocking display settings on each computer but as of right now I am having to go to each machine instead of over the local network.

Link to comment
Share on other sites

Here is a starting point...I'm running XP, and I'm not sure where you are going to make the change, but right off the bat I noticed that you could make this change.

Replace this:

Send("#r")
Sleep(500)
Send("desk.cpl")
Send("{ENTER}")
Sleep(500)

with this:

Run(@ComSpec & " /c " & 'desk.cpl', "", @SW_HIDE)
WinWaitActive('Display Properties')

after you get to display properties, where else are you trying to go?

Edited by dufran3
Link to comment
Share on other sites

Thanks for the support, was looking to do it a little easier than this but it looks like this is about the quickest and easiest way without having user interaction. At least Windows 7, need to test on Vista, should be the same.

Windows 7 Invert:

Opt("SendKeyDelay", 20)
Run(@ComSpec & " /c " & 'desk.cpl', "", @SW_HIDE)
WinWaitActive("Screen Resolution")
Send("{TAB 3}")
Send("{DOWN 2}")
ControlClick("Screen Resolution", "", "[CLASS:Button; INSTANCE:6]")
WinWaitActive("Display Settings", "")
ControlClick("Display Settings", "", "[CLASS:Button; INSTANCE:1]")
WinClose("Screen Resolution")

Windows 7 Revert:

Opt("SendKeyDelay", 20)
Run(@ComSpec & " /c " & 'desk.cpl', "", @SW_HIDE)
WinWaitActive("Screen Resolution")
Send("{TAB 3}")
Send("{UP 2}")
ControlClick("Screen Resolution", "", "[CLASS:Button; INSTANCE:6]")
WinWaitActive("Display Settings", "")
ControlClick("Display Settings", "", "[CLASS:Button; INSTANCE:1]")
WinClose("Screen Resolution")
Link to comment
Share on other sites

Are these computers using AD by any chance? Because it's easy to block access to the diplay properties using group policy if they are.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Are these computers using AD by any chance? Because it's easy to block access to the diplay properties using group policy if they are.

No its not. My supervisor can't figure out how to work the server (ID-10T Error) and he won't allow anyone else to access it to set permissions. So me + 2 other have to disable it machine to machine. He doesn't mind external programs being ran on a machine to fix an issue. So I get the luxary of walking to (Range(100,150)/3) units.

Link to comment
Share on other sites

Ctrl+Alt+Up restores the display to normal.

I've checked the graphic's settings and most of these units don't have any hotkey settings.

Oh no :> Well we have to fix that now don't we?

Try this :unsure:

;Ctrl+Alt+Up
HotKeySet("^!{UP}", "_ScreenOrientation_Restore")

Func _ScreenOrientation_Restore()
    Local $DEVMODE_MAP = "CHAR dmDeviceName[32];WORD dmSpecVersion;WORD dmDriverVersion;WORD dmSize;WORD dmDriverExtra;DWORD dmFields;"
    $DEVMODE_MAP &= "long dmPositionx;long dmPositiony;DWORD dmDisplayOrientation;DWORD dmDisplayFixedOutput;short dmColor;"
    $DEVMODE_MAP &= "short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;CHAR dmFormName[32];WORD dmLogPixels;"
    $DEVMODE_MAP &= "DWORD dmBitsPerPel;DWORD dmPelsWidth;DWORD dmPelsHeight;DWORD dmDisplayFlags;DWORD dmDisplayFrequency;"
    Local Const $DMDO_DEFAULT = 0, $ENUM_CURRENT_SETTINGS = -1
    Local $DEVMODE = DllStructCreate($DEVMODE_MAP)
    Local $DEVMODE_PTR = DllStructGetPtr($DEVMODE)
    DllCall('user32.dll', 'int', 'EnumDisplaySettings', 'ptr', 0, 'dword', $ENUM_CURRENT_SETTINGS, 'ptr', $DEVMODE_PTR)
    DllStructSetData($DEVMODE, "dmDisplayOrientation", $DMDO_DEFAULT)
    DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE))
    Return DllCall('user32.dll', 'long', 'ChangeDisplaySettings', 'ptr', $DEVMODE_PTR, 'dword', 0)
EndFunc   ;==>_ScreenOrientation_Restore

While 1
    Sleep(100)
WEnd

Ctrl+Alt+Up restores the display to normal.

;)

Hope this helps,

-smartee

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...