Sign in to follow this  
Followers 0
GrizDoug

Trackbar handling

12 posts in this topic

From my new and limited experience with the AutoIt scripting language, I have not been able to find a way to assign or set a value for an msctls_trackbar321. I am trying to setup a script to configure the Playback and Recording devices from the Sound icon in the tray at the bottom right of the screen. I am doing this in Vista. Each one of the Playback and Recording devices in this dialog has a levels tab with a slider to set the volume level. Is there a way to assign a new value to the slider?

Thanks in advance.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites



From my new and limited experience with the AutoIt scripting language, I have not been able to find a way to assign or set a value for an msctls_trackbar321. I am trying to setup a script to configure the Playback and Recording devices from the Sound icon in the tray at the bottom right of the screen. I am doing this in Vista. Each one of the Playback and Recording devices in this dialog has a levels tab with a slider to set the volume level. Is there a way to assign a new value to the slider?

Thanks in advance.

Just checking back, I hadn't heard anything and I'm running up against a deadline. If anyone has some sample code that will do this, it would be greatly appreciated if I could check it out.

Thanks again in advance. :)


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

From my new and limited experience with the AutoIt scripting language, I have not been able to find a way to assign or set a value for an msctls_trackbar321. I am trying to setup a script to configure the Playback and Recording devices from the Sound icon in the tray at the bottom right of the screen. I am doing this in Vista. Each one of the Playback and Recording devices in this dialog has a levels tab with a slider to set the volume level. Is there a way to assign a new value to the slider?

Thanks in advance.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

Just checking back, I hadn't heard anything and I'm running up against a deadline. If anyone has some sample code that will do this, it would be greatly appreciated if I could check it out.

Thanks again in advance. :)

Just wanted to add that I checked out the GUI Reference, but that applies to when you create a GUI for doing your configuration. I don't need that, I just need a way to set the value of the slider on the Levels tab of the dialog that is displayed when you select a Playback device and click the properties button. Please help. Thanks.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

I am sure you will get more response when you show something that demonstrates your issue. I for one have no clue how I could help you.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

From the suggestion, I captured a screen shot of the slider and how to get there, so anyone out there might get a better idea of what I'm trying to manipulate. Well, I tried to upload the screen shot, but the file was too big so it couldn't be done. I will try to describe how to get to it so anyone can see what I am trying to manipulate.

Go to the tray at the lower right corner of your screen in windows and locate the icon that looks like a speaker. For XP, right click the speaker icon and click "Open Volume Control". There you will see many examples of sliders that need to be manipulated by assigning a value to them.

For Vista, locate the white speaker icon and right click it. Select Playback Devices from the context menu and when the dialog comes up click one of the devices in the listview to highlight it. Click the Properties button in the lower right of the dialog. When the Properties dialog is displayed, click the Levels tab and there are sliders on that tab that need to have a value assigned to them. I am not sure how to assign these values in the context of AutoIt. If anyone knows of a way to do this, could you please give me a code snippet as an example, for the AutoIt scripting language, so I can implement it in my script.

The slider has a "value" field that can be assigned when working with it in C#. Through AutoIt, I'm not sure that I have access to that field. So now with this information, plus the description that I have provided to get you to the screen in Windows, does anyone out there have any suggestions. Thanks in advance.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

From the suggestion, I captured a screen shot of the slider and how to get there, so anyone out there might get a better idea of what I'm trying to manipulate. Well, I tried to upload the screen shot, but the file was too big so it couldn't be done. I will try to describe how to get to it so anyone can see what I am trying to manipulate.

Go to the tray at the lower right corner of your screen in windows and locate the icon that looks like a speaker. For XP, right click the speaker icon and click "Open Volume Control". There you will see many examples of sliders that need to be manipulated by assigning a value to them.

For Vista, locate the white speaker icon and right click it. Select Playback Devices from the context menu and when the dialog comes up click one of the devices in the listview to highlight it. Click the Properties button in the lower right of the dialog. When the Properties dialog is displayed, click the Levels tab and there are sliders on that tab that need to have a value assigned to them. I am not sure how to assign these values in the context of AutoIt. If anyone knows of a way to do this, could you please give me a code snippet as an example, for the AutoIt scripting language, so I can implement it in my script.

The slider has a "value" field that can be assigned when working with it in C#. Through AutoIt, I'm not sure that I have access to that field. So now with this information, plus the description that I have provided to get you to the screen in Windows, does anyone out there have any suggestions. Thanks in advance.

You can read the sliders (in the XP Pro volume control, anyway) with the _GuiCtrlSlider_* functions:
#Include <GuiSlider.au3>

$hWin = WinGetHandle("[CLASS:Volume Control;TITLE:Volume Control]")
ConsoleWrite("Debug: $hWin = " & $hWin & @LF)
$hSlider = ControlGetHandle($hWin, "", "[CLASS:msctls_trackbar32;INSTANCE:7]")
ConsoleWrite("Debug: $hSlider = " & $hSlider & @LF)
While 1
    $iData = _GUICtrlSlider_GetPos($hSlider)
    ToolTip("$iData = " & $iData)
    Sleep(500)
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You can read the sliders (in the XP Pro volume control, anyway) with the _GuiCtrlSlider_* functions:

#Include <GuiSlider.au3>

$hWin = WinGetHandle("[CLASS:Volume Control;TITLE:Volume Control]")
ConsoleWrite("Debug: $hWin = " & $hWin & @LF)
$hSlider = ControlGetHandle($hWin, "", "[CLASS:msctls_trackbar32;INSTANCE:7]")
ConsoleWrite("Debug: $hSlider = " & $hSlider & @LF)
While 1
    $iData = _GUICtrlSlider_GetPos($hSlider)
    ToolTip("$iData = " & $iData)
    Sleep(500)
WEnd

:)

I see your code snippet has a #Include <GuiSlider.au3>. Do I need to include this in my code as well, and if so, how can I find it?

Thanks in advance.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

The standard include files are automatically found by autoit3 in its Include subdirectory.

Jos

Jos,

I appreciate all your help. This seems to work. I added a WaitDelay of one second to the steps of the code and I can see everything happening. I set the slider and I set the static associated with the slider on the Vista Sound interface. I see this all happening. For some reason though, it does not get saved even though I click the Ok button. When I go back and look at the values in the Sound dialog, they are still the same values I started out with even though I watched the slider get moved and I watched the static get set to the proper value. I tried re-arranging the code several times, but it didn't help. I am going to include my function with the code below. If you see something wrong, can you point it out? Thanks in advance.

#include <GuiSlider.au3>

;*********************************************

Func ConfigureHeadsetEarphone()

;Go to the Levels tab

Send("^{TAB}")

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Set the Static text value

ControlSetText("[CLASS:#32770]", "", 1522, "100")

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Set the Slider value

$hWin = WinGetHandle("[CLASS:#32770; INSTANCE:1]")

;ConsoleWrite("Debug: $hWin = " & $hWin & @LF)

$hSlider = ControlGetHandle($hWin, "", "[CLASS:msctls_trackbar32;INSTANCE:1]")

;ConsoleWrite("Debug: $hSlider = " & $hSlider & @LF)

_GUICtrlSlider_SetPos($hSlider, 100)

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

$iData = _GUICtrlSlider_GetPos($hSlider)

ToolTip("$iData = " & $iData)

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Go to the Advanced tab

Send("^{TAB}")

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Send("{DOWN}")

;Set the dropdown selection

ControlCommand("[CLASS:#32770]", "", 1410, "SelectString", "2 channel, 16 bit, 44100 Hz (CD Quality)")

;Uncheck the first checkbox

ControlCommand("[CLASS:#32770]", "Allow applications to take exclusive control of this device", 1411, "UnCheck", "")

;Click the Ok button

ControlClick("[CLASS:#32770]", "", 1)

Opt("WinWaitDelay", 1000)

WinWait("Sound")

EndFunc

;*********************************************


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

Jos,

I appreciate all your help. This seems to work. I added a WaitDelay of one second to the steps of the code and I can see everything happening. I set the slider and I set the static associated with the slider on the Vista Sound interface. I see this all happening. For some reason though, it does not get saved even though I click the Ok button. When I go back and look at the values in the Sound dialog, they are still the same values I started out with even though I watched the slider get moved and I watched the static get set to the proper value. I tried re-arranging the code several times, but it didn't help. I am going to include my function with the code below. If you see something wrong, can you point it out? Thanks in advance.

#include <GuiSlider.au3>

;*********************************************

Func ConfigureHeadsetEarphone()

;Go to the Levels tab

Send("^{TAB}")

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Set the Static text value

ControlSetText("[CLASS:#32770]", "", 1522, "100")

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Set the Slider value

$hWin = WinGetHandle("[CLASS:#32770; INSTANCE:1]")

;ConsoleWrite("Debug: $hWin = " & $hWin & @LF)

$hSlider = ControlGetHandle($hWin, "", "[CLASS:msctls_trackbar32;INSTANCE:1]")

;ConsoleWrite("Debug: $hSlider = " & $hSlider & @LF)

_GUICtrlSlider_SetPos($hSlider, 100)

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

$iData = _GUICtrlSlider_GetPos($hSlider)

ToolTip("$iData = " & $iData)

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Go to the Advanced tab

Send("^{TAB}")

Opt("WinWaitDelay", 1000)

WinWait("[CLASS:#32770]")

;Send("{DOWN}")

;Set the dropdown selection

ControlCommand("[CLASS:#32770]", "", 1410, "SelectString", "2 channel, 16 bit, 44100 Hz (CD Quality)")

;Uncheck the first checkbox

ControlCommand("[CLASS:#32770]", "Allow applications to take exclusive control of this device", 1411, "UnCheck", "")

;Click the Ok button

ControlClick("[CLASS:#32770]", "", 1)

Opt("WinWaitDelay", 1000)

WinWait("Sound")

EndFunc

;*********************************************

There is a problem with this script, it sets the static value as 100 and the msctls_trackbar32 value to 100, but they are not saved. By doing a ControlClick on the Ok button, that should be like clicking the Ok button, which should save the values. So when I view the dialog after the AutoIt script has run, the value has returned to its original value before the script was run. Is there something that I'm missing, or is there another way to set these values so that they will persist? Thanks in advance for any help.


Gotta keep on truckin' to find the perfect solution, but sometimes you run into roadblocks, so you gotta jam right through those roadblocks!!

Share this post


Link to post
Share on other sites

I don't know if he ever solved his problem.

But i was thinking perhaps one could give the slider focus, and then send cursor key presses instead, cursor left or cursor right will move the slider.

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