DocMarten Posted January 17, 2007 Share Posted January 17, 2007 Hello, trying to set up a multizone audio solution für MediaPortal that ist controllable via a PC based radio controlled remote, I came to AutoIt - and I got hooked As the "kx Mixer" I need to control with the remote doesn't seem to be entirely standard window and even with the help the forum it was not possible to find a way to get the checkbox status (http://www.autoitscript.com/forum/index.php?showtopic=39203&hl=), I decides to make an own GUI to mirror the settings of the kxM Mixer. Taking into account that I have almost no idea of programming (except some lines of perl and word5 macros 20 years ago), it was a hard job for me - but thanks to the excellent documentation and the information I found in the forum, I've managed to get the basic things working (see below). When you are finished laughing at my code , I have three question left: I would love to learn how to a) send the {UP} and {DOWN} commands to the kx volume sliders while moving the AutoIt GUI sliders, and to do this smoothly and in a reliable manner (i.e. in a way that even when messing around with the GUI slider, no up or down is forgotten.) This is important because the idea depends on having the slider position in the kx mixer and the GUI always synchronized, and c) as I want to use the GUI for a little touchscreen, the volume buttons should work like "Send UPs or DOWNs while pressed, stop when released". But in spite of profound searching, I couldn't find something like "GUIbutton presses" Fot I have tried a modified version of a script I found in the forum (for testing purposes I put the standard windows mixer instead of the kx mixer - I know that normally one would control the standard windows mixer with SoundSetWaveVolume...): expandcollapse popup#include <GUIConstants.au3> GUICreate("Test") $Zahlenbox = GUICtrlCreateSlider ( "0000", 100, 300,40,-1,$ES_NUMBER) $Textbox = GUICtrlCreateInput ( "This is a test", 2, 30,70,-1) $Textanzeige = GUICtrlCreateLabel ( "text", 100, 2, 100, -1) GUISetState() $changed = GUICtrlRead ($Textanzeige) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $changed <> GUICtrlRead ($Zahlenbox) & " - " & GUICtrlRead ($Textbox) Then GUICtrlSetData ($Textanzeige, GUICtrlRead ($Zahlenbox) & " - " & GUICtrlRead ($Textbox)) IF $changed > GUICtrlRead ($Zahlenbox) Then $move_slider_down = ($changed - GUICtrlRead($Zahlenbox) ) * 5 ControlSend ( "Lautstärkeregelung", "", 2001, "{DOWN " & $move_slider_down & "}") SLEEP(250) EndIf If $changed < GUICtrlRead ($Zahlenbox) Then $move_slider_up = (GUICtrlRead($Zahlenbox) -$changed) * 5 ControlSend ( "Lautstärkeregelung", "", 2001, "{UP " & $move_slider_up & "}") SLEEP(250) EndIf EndIf $changed = GUICtrlRead ($Textanzeige) WendoÝ÷ ض¬±Êâ¦Ü(®K/z¼«¢è!+azÉbv)àȧµêëº^u©Ý¶¬Êw!v¬m±ç¦¶Þ{µhZ´Z½ë§¶)g£¬jëh×6#include <GUIConstants.au3> $var = IniReadSection("slider2.ini", "mute_settings") $var2 = IniReadSection("slider2.ini", "volume_settings") If @error Then MsgBox(4096, "", "Error - Where is INI?") EndIf ; To try script (only "Speakers room 1" with standard windows mixer (Wave volume and mute box), replace for german Win XP: ; ; ControlCommand ( "Mixer - SB0102 5.1 [d400]", "", 2304, "CHECK"} ; with ; ControlCommand ( "Lautstärkeregelung", "", 2000, "{SPACE}" ; and ; ControlCommand ( "Mixer - SB0102 5.1 [d400]", "", 1792, ; with ; ControlCommand ( "Lautstärkeregelung", "", 2001, ; and vice versa; actual status: Windows mixer ; ;slider2.ini ;[mute_settings] ;mute_room1 =4 ;mute_room1 = 4 ;mute_room2=4 ;[volume_settings] ;vol_status_room2 =Vol - ;vol_status_room1=Vol - ; GuiCreate("Test", 800, 600,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) ;setting GUI elements and variables $Vol_status_room_1 = $var2[1] [1] $Vol_status_room_2 = $var2[2] [1] $stopped_room_1 = $Vol_status_room_1 $stopped_room_2 = $Vol_status_room_2 $Slider_1 = GuiCtrlCreateSlider(30, 60, 360, 40) GUICtrlSetLimit($Slider_1,255,0) GUICtrlSetData($Slider_1,$stopped_room_1) $Vol_minus_room_1 = GuiCtrlCreateButton("Vol -", 440, 30, 110, 80) $Vol_plus_room_1 = GuiCtrlCreateButton("Vol +", 570, 30, 110, 80) $Mute_room1 = GuiCtrlCreateCheckbox("Mute", 700, 50, 80, 40) $Label_5 = GuiCtrlCreateLabel("Speakers Room 1", 60, 10, 200, 40) $Label_6 = GuiCtrlCreateLabel("Speakers Room 2", 60, 150, 200, 40) $Slider_2 = GuiCtrlCreateSlider(30, 190, 370, 50) GUICtrlSetLimit($Slider_2,255,0) GUICtrlSetData($Slider_2,$stopped_room_2) $Vol_minus_room_2 = GuiCtrlCreateButton("Vol -", 440, 170, 110, 80) $Vol_plus_room_2 = GuiCtrlCreateButton("Vol +", 570, 170, 110, 80) $Mute_room2 = GuiCtrlCreateCheckbox("Mute", 700, 190, 90, 40) $Delay_1 = GuiCtrlCreateInput($stopped_room_1, 40, 100, 70, 20, $ES_READONLY, $WS_EX_CLIENTEDGE) $Delay_2 = GuiCtrlCreateInput($stopped_room_2, 40, 240, 80, 20, $ES_READONLY, $WS_EX_CLIENTEDGE) GuiSetState() ;;;define what to do with the checkboxes after reading the ini Select Case $var[1] [1] =1 GUICtrlSetState ($Mute_room1, $GUI_CHECKED) $stop_room1 = 3 Case $var[1] [1] =4 $stop_room1 = 4 EndSelect Select Case $var[2] [1] =1 GUICtrlSetState ($Mute_room2, $GUI_CHECKED) $stop_room2=3 Case $var[2] [1] = 4 $stop_room2 = 4 EndSelect While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect If $msg = $Vol_minus_room_1 Then If GUICtrlRead($Delay_1) >= 5 Then ControlSend ( "Lautstärkeregelung", "", 2001, "{DOWN 5}" ) GUICtrlSetData ( $Delay_1, $Vol_status_room_1 - 5 ) GUICtrlSetData($Slider_1,$Vol_status_room_1 - 5) $Vol_status_room_1 = $Vol_status_room_1 - 5 EndIf EndIf If $msg = $Vol_plus_room_1 Then If GUICtrlRead($Delay_1) < 255 Then ControlSend ( "Lautstärkeregelung", "", 2001, "{UP 5}" ) GUICtrlSetData ( $Delay_1, $Vol_status_room_1 +5 ) GUICtrlSetData($Slider_1,$Vol_status_room_1 + 5) $Vol_status_room_1 = $Vol_status_room_1 + 5 EndIf EndIf If $msg = $Vol_minus_room_2 Then If GUICtrlRead($Delay_2) >= 5 Then ControlSend ( "Mixer - SB0102 5.1 [d400]", "", 1793, "{DOWN 5}" ) GUICtrlSetData ( $Delay_2, $Vol_status_room_2 - 5 ) GUICtrlSetData($Slider_2,$Vol_status_room_2 - 5) $Vol_status_room_2 = $Vol_status_room_2 - 5 EndIf EndIf If $msg = $Vol_plus_room_2 Then If GUICtrlRead($Delay_2) < 255 Then ControlSend ( "Mixer - SB0102 5.1 [d400]", "", 1793, "{UP 5}" ) GUICtrlSetData ( $Delay_2, $Vol_status_room_2 + 5 ) GUICtrlSetData($Slider_2,$Vol_status_room_2 + 5) $Vol_status_room_2 = $Vol_status_room_2 + 5 EndIf EndIf ;Retrieve and restore mute settings from last session If GUICtrlRead($Mute_room1) = $GUI_CHECKED And $stop_room1 = 3 Then $stop_room1 = 1 EndIf If GUICtrlRead($Mute_room1) = $GUI_UNCHECKED And $stop_room1 = 4 Then $stop_room1 = 0 EndIf If GUICtrlRead($Mute_room1) = $GUI_CHECKED And $stop_room1 = 0 Then ControlSend ("Lautstärkeregelung", "", 2000, "{SPACE}" ) $stop_room1 = 1 EndIf If GUICtrlRead($Mute_room1) = $GUI_UNCHECKED And $stop_room1 = 1 Then ControlSend ("Lautstärkeregelung", "", 2000, "{SPACE}" ) $stop_room1 = 0 EndIf If GUICtrlRead($Mute_room2) = $GUI_CHECKED And $stop_room2 = 3 Then $stop_room2 = 1 EndIf If GUICtrlRead($Mute_room2) = $GUI_UNCHECKED And $stop_room2 = 4 Then $stop_room2 = 0 EndIf If GUICtrlRead($Mute_room2) = $GUI_CHECKED And $stop_room2 = 0 Then ControlCommand ( "Mixer - SB0102 5.1 [d400]", "", 2305, "CHECK" ) $stop_room2 = 1 EndIf If GUICtrlRead($Mute_room2) = $GUI_UNCHECKED And $stop_room2 = 1 Then ControlCommand ( "Mixer - SB0102 5.1 [d400]", "", 2305, "CHECK" ) $stop_room2 = 0 EndIf ;sliders ;slider 1,including fast setting at min and max position If $msg = $Slider_1 Then GUICtrlSetData($Delay_1,StringFormat("%.2f",GUICtrlRead($Slider_1))) If GUICtrlRead($Slider_1) = 255 Then ControlSend ( "Lautstärkeregelung", "", 2001, "{Home}") $stopped_room_1 = GUICtrlRead($Slider_1) $Vol_status_room_1 = GUICtrlRead($Slider_1) EndIf If GUICtrlRead($Slider_1) = 0 Then ControlSend ( "Lautstärkeregelung", "", 2001, "{End}") $stopped_room_1 = GUICtrlRead($Slider_1) $Vol_status_room_1 = GUICtrlRead($Slider_1) EndIf If $stopped_room_1 >= GUICtrlRead($Slider_1) Then $move_slider_down = ($stopped_room_1 - GUICtrlRead($Slider_1)) ControlSend ( "Lautstärkeregelung", "", 2001, "{DOWN " & $move_slider_down & "}") $stopped_room_1 = GUICtrlRead($Slider_1) $Vol_status_room_1 = GUICtrlRead($Slider_1) EndIf If $stopped_room_1 <= GUICtrlRead($Slider_1) Then $move_slider_up = (GUICtrlRead($Slider_1) - $stopped_room_1) ControlSend ( "Lautstärkeregelung", "", 2001, "{UP " & $move_slider_up & "}") $stopped_room_1 = GUICtrlRead($Slider_1) $Vol_status_room_1 = GUICtrlRead($Slider_1) EndIf EndIf ;slider 2,including fast setting at min and max position If $msg = $Slider_2 Then GUICtrlSetData($Delay_2,StringFormat("%.2f",GUICtrlRead($Slider_2))) If GUICtrlRead($Slider_2) = 255 Then ControlSend ( "Mixer - SB0102 5.1 [d400]", "", 1793, "{Home}") $stopped_room_2 = GUICtrlRead($Slider_2) $Vol_status_room_2 = GUICtrlRead($Slider_2) EndIf If GUICtrlRead($Slider_2) = 0 Then ControlSend ( "Mixer - SB0102 5.1 [d400]", "", 1793, "{End}") $stopped_room_2 = GUICtrlRead($Slider_2) $Vol_status_room_2 = GUICtrlRead($Slider_2) EndIf If $stopped_room_2 >= GUICtrlRead($Slider_2) Then $move_slider_down = ($stopped_room_2 - GUICtrlRead($Slider_2)) ControlSend ( "Mixer - SB0102 5.1 [d400]", "", 1793, "{DOWN " & $move_slider_down & "}") $stopped_room_2 = GUICtrlRead($Slider_2) $Vol_status_room_2 = GUICtrlRead($Slider_2) EndIf If $stopped_room_2 <= GUICtrlRead($Slider_2) Then $move_slider_up = (GUICtrlRead($Slider_2) - $stopped_room_2) ControlSend ( "Mixer - SB0102 5.1 [d400]", "", 1793, "{UP " & $move_slider_up & "}") $stopped_room_2 = GUICtrlRead($Slider_2) $Vol_status_room_2 = GUICtrlRead($Slider_2) EndIf EndIf WEnd IniWrite ("slider2.ini", "mute_settings", "mute_room1", GUICtrlRead($Mute_room1) ) IniWrite ("slider2.ini", "mute_settings", "mute_room2", GUICtrlRead($Mute_room2) ) IniWrite ("slider2.ini", "volume_settings", "vol_status_room1", GUICtrlRead($Vol_minus_room_1) ) IniWrite ("slider2.ini", "volume_settings", "vol_status_room2", GUICtrlRead($Vol_minus_room_2) ) Exit So my question: Is there any way to get this working with AutoIt? Best regards from Heidelberg, Germany Martin Link to comment Share on other sites More sharing options...
LxP Posted January 21, 2007 Share Posted January 21, 2007 Unfortunately I don't believe that it's possible to do this. I would suggest writing a loop that checks the status of the sliders on the AutoIt window every 100ms (for example) and updates the sliders on the other window if the AutoIt slider has changed. (I'm quite certain that I've been able to adjust external sliders without sending keystrokes to them, but I don't remember how at this moment.) Best wishes 17km from Heidelberg, Australia. Link to comment Share on other sites More sharing options...
DocMarten Posted January 22, 2007 Author Share Posted January 22, 2007 Unfortunately I don't believe that it's possible to do this.I was afraid that this would be the case...I would suggest writing a loop that checks the status of the sliders on the AutoIt window every 100ms (for example) and updates the sliders on the other window if the AutoIt slider has changed. (I'm quite certain that I've been able to adjust external sliders without sending keystrokes to them, but I don't remember how at this moment.)ok, that might be an idea. I have already experimented with little "sleeps" to give the external slider some time to crawl up or down, but the results have not been satisfactory.I think that I had better forget the idea of the synching sliders and concentrate on the normal buttons. However, my initial question concerning their behaviour hasn't found an answer either: the volume buttons should work like "Send UPs or DOWNs while pressed, stop when released", or in other words: as I want tu use the GUI on a little touchscreen, volume should go continuously up while the big UP button is pressed and should go down while the DOWN button is pressed.Best wishes 17km from Heidelberg, Australia. Hey, is this http://en.wikipedia.org/wiki/Heidelberg_Heights,_Victoria ? How did it get its name? Perhaps I have some family over there which I don't know Best regardsMartin Link to comment Share on other sites More sharing options...
LxP Posted February 27, 2007 Share Posted February 27, 2007 Hey, is this http://en.wikipedia.org/wiki/Heidelberg_Heights,_Victoria ? How did it get its name? Perhaps I have some family over there which I don't know That's close, but there's an actual place called Heidelberg too. This Wikipedia article might tell you more about its history. Link to comment Share on other sites More sharing options...
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