Zohar Posted May 7, 2012 Posted May 7, 2012 (edited) HiI am trying to write a small script, that will change the current Screen Resolution.I am using Windows XP SP3.I used _GUICtrlSlider_SetPos(),and it indeed moves the Slider,however, it seems tht the event that should happen after moving the slider, doesn't happen.Here's my small script:#include <GuiSlider.au3> Run("Rundll32.exe shell32.dll,Control_RunDLL desk.cpl ,3") ;ControlPanelDisplay, Settings Tab WinWaitActive("Display Properties") Local $hSlider=ControlGetHandle("","","msctls_trackbar321") _GUICtrlSlider_SetPos($hSlider,8) ;1280x1024 Sleep(2000) Send("{Enter}")If you run it, you can see, that the SLider indeed moves,but the underlying value of it, doesn't change.(You can know if the value actually changes, if the "XXXX by XXXX pixels" message changes too, according to the slider position)Anyone can tell me how to make it work?Thank you Edited May 7, 2012 by Zohar
stormbreaker Posted May 7, 2012 Posted May 7, 2012 Replace ControlGetHandle line in your script with ControlGetHandle("","","[Class:msctls_trackbar32]") ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
Zohar Posted May 7, 2012 Author Posted May 7, 2012 Hi MKISHTried what you offered,and no change happened.The slider still moves,but the "XXXX by XXXX pixels" line below did not change after it moved,and pressing Enter did not change the resolution.For some reason, the _GUICtrlSlider_SetPos() function only affects the Slider Visually, but not its Value.Why can that happen?
stormbreaker Posted May 8, 2012 Posted May 8, 2012 Just add ControlClick("Display Properties", "", $hSlider, "Primary") at the end of your scriptRun("Rundll32.exe shell32.dll,Control_RunDLL desk.cpl ,3") ;ControlPanelDisplay, Settings Tab WinWaitActive("Display Properties") Local $hSlider=ControlGetHandle("","","msctls_trackbar321") _GUICtrlSlider_SetPos($hSlider,8) ;1280x1024 ControlClick("Display Properties", "", $hSlider, "Primary") Send("{Enter}") ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
Zohar Posted May 9, 2012 Author Posted May 9, 2012 (edited) Hi MKISHYour workaround is very nice, because that's what I had to manually do every time -I had to click with the mouse, on the moving part of the Slider.(without moving it.._GUICtrlSlider_SetPos() moved it to the location I needed, and then I had to manually click with the mouse(myself), to activate the change in the slider's value)It indeed works good with the mouse,but unfortunately, it doesn't work good with this line of code:ControlClick("Display Properties", "", $hSlider, "Primary")The reason it doesn't work good, is:When you use CotnrolClick() on a Control,the Middle Location of that control is clicked.In a Slider, it means a point, which is not necessarily where the moving part of the slider is...So while this line of code does make a change in the slider's Value,It also moves the slider abit... I wonder,Does anyone know why _GUICtrlSlider_SetPos() doesn't activate the "Positionchanged" event of the Slider after it moves it?That seems to be the missing part here... Edited May 9, 2012 by Zohar
BrewManNH Posted May 9, 2012 Posted May 9, 2012 Why are you using the control panel to change the display? Do a search in the Example Scripts section for the Desktop Resolution Changer script. 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 GudeHow 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
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