Jump to content
Sign in to follow this  
Akarillon

[Solved]Change active display screen

Recommended Posts

Akarillon

I am trying to make a script that changes the active display screen.

I got a setup with 3 screens and can only have 2 active screens at the same time, so I want to automate the process by making a script for it.

Screen 1(Main) and 2(Extended) are my main screens.

I also got a third screen that I use for watching movies and such.

I've tried searching both the forum and google for relevant problems, but I can't seem to find anything.

Also tried looking for the display settings in the registry, but gave up searching without any idea what to look for.

Do you guys got any tips?

Regards,

Akarillon

Edited by Akarillon

Challenge accepted!

Share this post


Link to post
Share on other sites
Danyfirex

try this:

WinSetState("[CLASS:Notepad]", "", @SW_HIDE)
Sleep(3000)
WinSetState("[CLASS:Notepad]", "", @SW_SHOW)

it's that you need.

regards.

Share this post


Link to post
Share on other sites
Akarillon

Maybe I didn't make myself clear.

I want to change the active screen, not a window.

At the moment I use the Screen Resolution setting like the screenshot shown in the image.

But since I am doing this 2-3 times a day I really want to automate it.

Posted Image


Challenge accepted!

Share this post


Link to post
Share on other sites
IanN1990

I had a quick look at the screen resoulation, and it appears to be compatable with controlclick.

So you could make a script that works like this.

Lauch Screen Res Run("rundll32.exe shell32.dll,Control_RunDLL desk.cpl")

Hide the window with WinSetTrans

The controlclick 3 Screen

Controlsend 5 tabs "so the focus is over Mutiplay displays drop down"

Controlsend down so its on extend displays

controlsend enter.

Then same again for the screen you want to disconnect

then controlclick the OK button

close the window

finished :)

Share this post


Link to post
Share on other sites
Akarillon

Thanks man! :P

Did not think about that.

I was a little bit slow replying, but was busy during the weekend.

Here's the script I got working.

Did not find any way to detect what screen was active so added a 2 button activation popup.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=..Compilex64ScreenResolution.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include 
#include 
#include 
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 258, 114, 401, 181)
$Button1 = GUICtrlCreateButton("Gaming", 32, 24, 75, 65)
$Button2 = GUICtrlCreateButton("Bed", 152, 24, 75, 65)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
Run("rundll32.exe shell32.dll,Control_RunDLL desk.cpl")
Sleep(500)
WinSetTrans("Screen Resolution", "", 0)
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{UP}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{DOWN}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{DOWN}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:1]", "{UP}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:1]", "{UP}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{UP}")
Sleep(150)
ControlClick("Screen Resolution", "", "[CLASS:Button; INSTANCE:4]")
Sleep(500)
Send("{LEFT}")
Sleep(150)
Send("{ENTER}")
Exit

Case $Button2
Run("rundll32.exe shell32.dll,Control_RunDLL desk.cpl")
Sleep(500)
WinSetTrans("Screen Resolution", "", 0)
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{UP}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:1]", "{DOWN}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{DOWN}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:1]", "{UP}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{DOWN}")
Sleep(150)
ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:3]", "{DOWN}")
Sleep(150)
ControlClick("Screen Resolution", "", "[CLASS:Button; INSTANCE:4]")
Sleep(500)
Send("{LEFT}")
Sleep(150)
Send("{ENTER}")
Exit

EndSwitch
WEnd

Challenge accepted!

Share this post


Link to post
Share on other sites
IanN1990

As you shown an effort instead i just did it for u ^^

ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:1]", "{Down 2}") ;From my test it always starts on screen 1, so down 2 for screen 3.

$ScreenText=WinGetText("Screen Resolution")
If StringInStr($ScreenText, "Extend desktop to this display", 1, 1) Then
ConsoleWrite("Screen 3 is Enabled. Run Disable Screen 3 and Enable Screen 1 Code" & @CRLF)
Else
ConsoleWrite("Screen 3 is Disabled. Run Disable Screen 1 and Enable Screen 3 Code" & @CRLF)
EndIf

Enjoy :D

Oh yea, make sure you read the spoiler as well. Its kinda important.

Ok So i had an idea on how you could automaicly detect which is active or not :)

So in your picture for example

Controlclick Screen 3

On the Mutiplie Displays it will say "extend desktop to this display" or "disconnect this display". You can get this info from WIngetText on the combo box.

So u get the list, if "Disonnect" is there then the screen is not on. Else it is and run the other one :)

I noticed after i had written how to do it, your post is kinda game-related. Ironic the first time i help someone and without knowing it was to assist with making gaming easier ^^. Make sure you read the forum rules so in the furture you do not get in any trouble.

http://www.autoitscript.com/forum/forum-2/announcement-15-forum-rules-7-nov-2012/

Now i defile anyone to say this topic is against the rules *apart from like Melba or any else in power who can defile me without a second glance ^^* It doesnt launch, automate or interact with a game or server. Just happens to have a button labeled "Gaming" :P

Edited by IanN1990

Share this post


Link to post
Share on other sites
Akarillon

As you shown an effort instead i just did it for u ^^

ControlSend("Screen Resolution", "", "[CLASS:ComboBox; INSTANCE:1]", "{Down 2}") ;From my test it always starts on screen 1, so down 2 for screen 3.

$ScreenText=WinGetText("Screen Resolution")
If StringInStr($ScreenText, "Extend desktop to this display", 1, 1) Then
ConsoleWrite("Screen 3 is Enabled. Run Disable Screen 3 and Enable Screen 1 Code" & @CRLF)
Else
ConsoleWrite("Screen 3 is Disabled. Run Disable Screen 1 and Enable Screen 3 Code" & @CRLF)
EndIf

Enjoy :D

Oh yea, make sure you read the spoiler as well. Its kinda important.

Ok So i had an idea on how you could automaicly detect which is active or not :)

So in your picture for example

Controlclick Screen 3

On the Mutiplie Displays it will say "extend desktop to this display" or "disconnect this display". You can get this info from WIngetText on the combo box.

So u get the list, if "Disonnect" is there then the screen is not on. Else it is and run the other one :)

I noticed after i had written how to do it, your post is kinda game-related. Ironic the first time i help someone and without knowing it was to assist with making gaming easier ^^. Make sure you read the forum rules so in the furture you do not get in any trouble.

http://www.autoitscript.com/forum/forum-2/announcement-15-forum-rules-7-nov-2012/

Now i defile anyone to say this topic is against the rules *apart from like Melba or any else in power who can defile me without a second glance ^^* It doesnt launch, automate or interact with a game or server. Just happens to have a button labeled "Gaming" :P

Yea, that should work.

Thanks! :)

About the gaming tag.

The rule clearly states:" Launching, automation or script interaction with games or game servers, regardless of the game."

And I am not doing any of those.

The reason I wrote gaming on the button is because that is what I usually do.

I could change the name to "work".


Challenge accepted!

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • Skeletor
      By Skeletor
      MS Splash Screens
      The office 2016/17 office suite has made many people turn heads with its functions and especially their splash screen.
      I now present to you, the MS Style Splash Screen. For Rookies, Novices and anyone who wants a ready made splash screen for your gui application.

      You can now download it and also try it out yourself.
      You have three colors to choose from:
      Blue
      Red
      Green
      All three colours are from the famous programs.
      I also included the KODA form to you can have freedom with this splash screen.
      Note: the KODA form does not have the three colours as well as the correct blue. 

      Have fun and enjoy.
      Note:
      Thanks to kaz for updating the side scrolling dots.
       
       
    • cahsobo
      By cahsobo
      Hello,

      I need help inserting these keys and values to registry
       
      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw\Compatibility\WK.1.exe]
      "Flags"=hex:00,08,00,00
      "ID"=hex:ec,33,74,3b
       
      Still can't figure out how...
    • Errious
      By Errious
      Hello,
      i am searching for a function that allows me some very specific functions for Screen Captures.
       
      First should be the possibillity to create a Screenshot from a specific window and this is possibly under another window but has to stay there and not getting forced to be in the first - layer position if this is clear enough :-) The other thing should be the ability to create a Screen Capture every couple minutes or a specific period.  
      I tried a lot of Screen Capture tools but neither can do both together.
      Also my try to create my own script with AutoIT failed, because of missing knoweledge about how to use it for this specific reasons, would be very kind if someone can tell me in the first place if this is possible at all and maybe someone has allready an idea about how to realize it?
       
      best regards
       
       
       
       
    • nitron
      By nitron
      Hy to all, 
      I am really Sorry to come up with this question but i can't seem to solve the Problem.
      Its quite easy, I have been using RegNumKey for Years, but i seemed to lose track of something.
      For $ZaehlerLocal = 1 to 1200
            $RegKey = RegEnumKey("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall", $ZaehlerLocal)
            If @error <> 0 then ExitLoop
            $RegKey2=RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"&$RegKey,"DisplayName")
            $RegKey3=RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"&$RegKey,"UninstallString")
            $RegKey4=RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"&$RegKey,"QuietUninstallString")

            if StringInStr($RegKey,"_Office15")==0 and StringInStr($RegKey2,"(German) 2013")==0 and StringInStr($RegKey,".KB")==0 and StringInStr($RegKey2,"Security update")==0 and StringInStr($RegKey2,"Framework")==0 Then
              FileWrite($FileHandleLocal,$RegKey&";")
              FileWrite($FileHandleLocal,$RegKey2&";")
              FileWrite($FileHandleLocal,$RegKey3&";")
              FileWriteline($FileHandleLocal,$RegKey4&";")
           EndIf
         Next
       
      Ive been using this to get all uninstall Strings from the Registry but for some reason, this doesn't work anymore. 
      I get some keys but not all, nore does it start with the first registry.
      As you can see in the picture, the Registry starts with {13DA9C7C-EBFB-40D0-94A1-55B42883DF21}
      but RegNumKey starts with Adressbook.
      Any Ideas what I am doing wrong? I tried HKLM64 instead as well, but with same result.
      Again sorry to bother, but i can't Find the mistake.
       

    • Skeletor
      By Skeletor
      Hi All,
      I know many newbies search for this feature.
      I decided to share this piece of code with everyone.
      Basically its a "splash screen" that has a transparent image.
      In a nutshell - Gui with a transparent gif.
      Enjoy...
      Download attachment....
       
      Splash Screen GUI.zip
×