Sign in to follow this  
Followers 0
Zohar

_GUICtrlSlider_SetPos Problem

6 posts in this topic

#1 ·  Posted (edited)

Hi

I 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 by Zohar

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Hi MKISH

Tried 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?

Share this post


Link to post
Share on other sites

Just add ControlClick("Display Properties", "", $hSlider, "Primary") at the end of your script

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
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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi MKISH

Your 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 by Zohar

Share this post


Link to post
Share on other sites

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 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

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  
Followers 0