psynegy Posted April 30, 2009 Share Posted April 30, 2009 Is it possible to update something live with a slider (much like in the windows sound control panel, which allows to click and drag the slider to adjust the volume. #include <GuiConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> Global $GUI[1] Global $GUI_STATE[1] Global $CHANCOUNT = 10 Global $SLIDER[$CHANCOUNT+1] GUICreate("DMX Console", 900, 500) For $i = 1 to $CHANCOUNT Step +1 GuiCtrlCreateLabel($i, (10 + (42*($i-1))), 30, 42, 20, $SS_CENTER) $SLIDER[$i] = GuiCtrlCreateSlider((10 + (42*($i-1))), 50, 42, 170, BitOR($TBS_VERT, $TBS_BOTH, $TBS_AUTOTICKS)) GuiCtrlSetLimit($SLIDER[$i], 255, 0) GuiCtrlSetData(-1, 255) Next While 1 $GUI_STATE[0] = GUIGetMsg($GUI[0]) Switch $GUI_STATE[0] Case $GUI_EVENT_CLOSE Exit EndSwitch For $i = 1 to $CHANCOUNT Step +1 If $GUI_STATE[0] = $SLIDER[$i] Then MsgBox(0, "", 255-GUICtrlRead($SLIDER[$i])) EndIf Next Sleep(10) WEnd Obviously it won't be MsgBox I call when I do the real thing, but instead of that being called when you release, I want it to be called every time the slider moves so much as a pixel. Many thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 30, 2009 Moderators Share Posted April 30, 2009 psynegy,These snippets are taken from one of my scripts:; Create slider Global $hVol_Slider = GUICtrlCreateSlider(10, 10, 100, 20) GUICtrlSetLimit(-1, 0, 100) ; In While...WEnd loop $aInfo = GUIGetCursorInfo($hMain_Win) If $aInfo[4] = $hVol_Slider Then Check_Vol_Slider($aInfo) EndIf ; Function Func Check_Vol_Slider($aInfo) While $aInfo[2] SoundSetWaveVolume(GUICtrlRead($hVol_Slider)) ; Set tooltip If $aInfo[4] = $hVol_Slider Then ToolTip(100 - GUICtrlRead($hVol_Slider)) Else ToolTip("") EndIf ; Allow tooltip to display Sleep(100) ; Poll for loop $aInfo = GUIGetCursorInfo($hMain_Win) WEnd ToolTip("") EndFuncJust look at GUIGetCursorInfo in the Help file to see what is going on. I hope you find them useful.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Yashied Posted April 30, 2009 Share Posted April 30, 2009 Maybe this. #Include <GUIConstantsEx.au3> #Include <SliderConstants.au3> GUICreate('Test', 120, 200) $Label = GUICtrlCreateLabel('255', 70, 10, 30, 20) $Slider = GUICtrlCreateSlider(20, 10, 40, 180, BitOR($TBS_AUTOTICKS, $TBS_VERT, $TBS_BOTH)) GUICtrlSetLimit(-1, 255, 0) GUICtrlSetData(-1, 255) GUISetState() $Prev = GUICtrlRead($Slider) while 1 $Data = GUICtrlRead($Slider) if $Data <> $Prev then GUICtrlSetData($Label, $Data) $Prev = $Data endif $Msg = GUIGetMsg() switch $Msg case $GUI_EVENT_CLOSE exit endswitch wend My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
psynegy Posted April 30, 2009 Author Share Posted April 30, 2009 Both excellent answers, I'd just finished implementing Melba23's solution (which works perfectly thanks), but I'd rather have the level built into the GUI rather than floating, so I'll use Yashied's one for the final thing I reckon. Link to comment Share on other sites More sharing options...
BrettF Posted May 1, 2009 Share Posted May 1, 2009 Also check out _GUICtrlSlider_Create example... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
smashly Posted May 1, 2009 Share Posted May 1, 2009 Same thing again, but moving the slider check outside your main While loop.expandcollapse popup#include <GuiConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> Global $CHANCOUNT = 10 Global $SLIDER[$CHANCOUNT+1][3] $hGui = GUICreate("DMX Console", 900, 500) For $i = 1 to $CHANCOUNT Step +1 $SLIDER[$i][2] = GuiCtrlCreateLabel(0, (10 + (42*($i-1))), 30, 42, 20, $SS_CENTER) $SLIDER[$i][1] = GuiCtrlCreateSlider((10 + (42*($i-1))), 50, 42, 170, BitOR($TBS_VERT, $TBS_BOTH, $TBS_AUTOTICKS)) GuiCtrlSetLimit(-1, 255, 0) GuiCtrlSetData(-1, 255) Next GUISetState() AdlibEnable("ChkSlider", 50) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case Else ;;; EndSwitch WEnd Func ChkSlider() For $i = 1 To $CHANCOUNT If $SLIDER[$i][0] <> GUICtrlRead($SLIDER[$i][1]) Then $SLIDER[$i][0] = GUICtrlRead($SLIDER[$i][1]) GuiCtrlSetData($SLIDER[$i][2], 255 - $SLIDER[$i][0]) EndIf Next EndFunc Link to comment Share on other sites More sharing options...
rover Posted May 1, 2009 Share Posted May 1, 2009 search forum for WM_HSCROLL, many examples of this register WM_HSCROLL and/or WM_VSCROLL messages only occur on event no continuous slider reading in main loop can be used with OnEvent or loop mode expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SliderConstants.au3> Opt('MustDeclareVars', 1) ;Global Const $WM_HSCROLL = 0x0114 ;Global Const $WM_VSCROLL = 0x0115 Global $Slider, $hSlider, $Dummy, $iBuffer, $Label Example() Func Example() Local $hGUI, $msg $hGUI = GUICreate("Slider Demo", 280, 100) $Label = GUICtrlCreateLabel('0', 125, 50, 30, 20) $Slider = GUICtrlCreateSlider(40, 10, 200, 30, BitOR($TBS_AUTOTICKS, $TBS_TOOLTIPS)) $hSlider = GUICtrlGetHandle($Slider) GUICtrlSetCursor(-1, 0) $Dummy = GUICtrlCreateDummy() ;one or both at same time GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL") ;horz slider ;GUIRegisterMsg($WM_VSCROLL, "WM_HVSCROLL");vert slider GUISetState() Do $msg = GUIGetMsg() Switch $msg Case $Dummy _Slider() EndSwitch Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Func _Slider() Local $iValue, $sValue $iValue = GUICtrlRead($Dummy) If $iBuffer <> $iValue Then $iBuffer = $iValue GUICtrlSetData($Label, $iBuffer) ;ConsoleWrite('-Value = ' & $iBuffer & @CRLF) EndIf Return EndFunc ;==>_Slider Func WM_HVSCROLL($hwnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL Switch $lParam Case $hSlider GUICtrlSendToDummy($Dummy, GUICtrlRead($Slider)) EndSwitch Case $WM_VSCROLL EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_HVSCROLL mike2003 1 I see fascists... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2009 Moderators Share Posted May 1, 2009 All, Thanks for the tutorial - I learn so much from these exchanges. :-) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Yashied Posted May 1, 2009 Share Posted May 1, 2009 (edited) I like Rover`s example. Edited May 1, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2009 Moderators Share Posted May 1, 2009 (edited) I agree entirely. The use of Dummy is that way is worth a thread on its own - I now realise it is in the Help file, but I wonder how many others did before reading rover's post?His posts are always worth reading very carefully - even if a little hard to follow now and again for the simple hobbyists like me! :-)M23Edit: speeling Edited May 1, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 18, 2011 Moderators Share Posted March 18, 2011 jdg2010,The volume handling in Vista and Win7 is very different to that in XP - you are limited to modifying the process volume only. Whn I run your script in Vista with the "Volume Control" visible it acts only on the script volume. However, I believe there are a few example scripts out there which can deal with the master volume - try a search. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 18, 2011 Share Posted March 18, 2011 While this has no graphics or sliders for that matter, this bit of code affects the main volume on both Windows 7 and Vista PCs. I haven't tried this on one running XP. HotKeySet("{F2}", "VolUpDownMute") ;ToggleMute HotKeySet("{F3}", "VolUpDownMute") ;VolDown HotKeySet("{F4}", "VolUpDownMute") ;VolUp While 1 Sleep(100) WEnd Func VolUpDownMute() Switch @HotKeyPressed Case "{F2}" Send("{VOLUME_MUTE}") Case "{F3}" Send("{VOLUME_DOWN}") Case "{F4}" Send("{VOLUME_UP}") EndSwitch EndFunc reb 1 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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