ontherocks Posted June 26, 2008 Share Posted June 26, 2008 (edited) I am trying to create a simple gui for a command line player "MPXPLAY".The volume increases or decreases on pressing "." or "," respectively on the keyboard. I want to mimic this i.e. increase/decrease the volume using a slider in the gui. How do I do it?expandcollapse popup#include <GUIConstantsEx.au3> Global $select_file, $select_exe, $input_file, $input_exe Opt("GUIOnEventMode", 1) GUICreate("MPXPLAY GUI", 370, 160) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked ;---------------------------ALL BUTTONS-------------------------------------- $browsebutton_exe = GUICtrlCreateButton("Browse", 270, 20, 70, 20) GUICtrlSetOnEvent($browsebutton_exe, "BROWSEButton_exe") $browsebutton_file = GUICtrlCreateButton("Browse", 270, 60, 70, 20) GUICtrlSetOnEvent($browsebutton_file, "BROWSEButton_file") $input_exe = GUICtrlCreateInput("Put MPXPLAY.exe here", 40, 20, 220, 20) $input_file = GUICtrlCreateInput("Put audio file here", 40, 60, 220, 20) GUICtrlCreateLabel("Volume", 40, 90) GUICtrlCreateSlider(80, 90, 200, 20) $okbutton = GUICtrlCreateButton("OK", 30, 120, 80, 20) GUICtrlSetOnEvent($okbutton, "OKButton") $playbutton = GUICtrlCreateButton("PLAY/PAUSE", 110, 120, 80, 20) GUICtrlSetOnEvent($playbutton, "PLAYButton") $stopbutton = GUICtrlCreateButton("STOP", 190, 120, 80, 20) GUICtrlSetOnEvent($stopbutton, "STOPButton") $exitbutton = GUICtrlCreateButton("EXIT", 270, 120, 70, 20) GUICtrlSetOnEvent($exitbutton, "EXITButton") ;-------------------------------------------------------------------------- Func BROWSEButton_exe() $select_exe = FileOpenDialog("Browse MPXPLAY.exe", "C:\", "(*.exe)") GUICtrlSetData($input_exe, $select_exe) EndFunc Func BROWSEButton_file() $select_file = FileOpenDialog("Browse the audio file", "C:\", "(*.mp3)") GUICtrlSetData($input_file, $select_file) EndFunc While 1 Sleep(1000) WEnd Func OKButton() Local $n8 = '"' & $select_exe & '" ' & '"' & $select_file & '"' Run($n8) EndFunc ;==>OKButton Func PLAYButton() WinActivate("Mpxplay") Send("{P}") EndFunc ;==>PLAYButton Func STOPButton() WinActivate("Mpxplay") Send("{S}") EndFunc ;==>STOPButton Func EXITButton() WinActivate("Mpxplay") Send("{Esc}") Exit EndFunc ;==>EXITButton Edited June 26, 2008 by ontherocks Link to comment Share on other sites More sharing options...
enaiman Posted June 26, 2008 Share Posted June 26, 2008 Declare 2 hotkeys; one for volume up, other for volume down. Work with _GUICtrlSlider_ ... functions to get the slider move. The help file is your best friend here. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 27, 2008 Share Posted June 27, 2008 One way to do this is in "AlphaBlend.au3" in your \AutoIt3\Examples\GUI\Advanced directory .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ontherocks Posted June 28, 2008 Author Share Posted June 28, 2008 Sorry guys...read through the whole help file and everything suggested, still cannot figure out how to do. Pls help Link to comment Share on other sites More sharing options...
martin Posted June 28, 2008 Share Posted June 28, 2008 Something like this maybe expandcollapse popup#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $slider1 Global $slide = 0 Global $stepsperinc = 2;set how many . or , are sent for a change in the slider Example() Func Example() Local $button, $msg GUICreate("slider", 220, 100, 100, 200) GUISetBkColor(0x00E0FFFF); will change background color $slider1 = GUICtrlCreateSlider(10, 10, 200, 20) GUICtrlSetLimit(-1, 200, 0); change min/max value $button = GUICtrlCreateButton("Value?", 75, 70, 70, 20) GUISetState() GUICtrlSetData($slider1, 45); set cursor AdlibEnable("volupdate", 100) Do $msg = GUIGetMsg() If $msg = $button Then MsgBox(0, "slider1", GUICtrlRead($slider1), 2) EndIf Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Func volupdate() Local $nowslider = GUICtrlRead($slider1) If $nowslider < $slide Then Send("{. " & Int(($slide - $nowslider) / $stepsperinc & "}") ElseIf $nowslider > $slide Then Send("{, " & Int(($nowslider - $slide) / $stepsperinc) & "}") EndIf $slide = $nowslider EndFunc ;==>volupdate Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ontherocks Posted June 29, 2008 Author Share Posted June 29, 2008 Thanks a lot martin. I was able to advance further. The issue now is as follows:- The dos window of the player has to be on top & activated for any key to work. Hence with the code below, the increments in slider does not work in parallel to the increase in dos window. It happens in kind of jumps. I move the slider->the dos window activates->the volume increases/decreases->but the GUI deactivates. So I have to activate the GUI by clicking with mouse and then repeat the above process. I am not sure if both the GUI and dos window can be activated simultaneously. Or if the dos window can be put/hidden in background but the keys would still work. expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiSlider.au3> Global $slider_value, $slide Global $select_file, $select_exe, $input_file, $input_exe, $browsebutton_exe, $browsebutton_file Global $okbutton, $playbutton, $stopbutton, $exitbutton Opt("GUIOnEventMode", 1) GUICreate("MPXPLAY GUI", 370, 160) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked ;-------------------------------------------------------------------------- $browsebutton_exe = GUICtrlCreateButton("Browse", 270, 20, 70, 20) GUICtrlSetOnEvent($browsebutton_exe, "BROWSEButton_exe") $browsebutton_file = GUICtrlCreateButton("Browse", 270, 60, 70, 20) GUICtrlSetOnEvent($browsebutton_file, "BROWSEButton_file") $input_exe = GUICtrlCreateInput("Put MPXPLAY.exe here", 40, 20, 220, 20) $input_file = GUICtrlCreateInput("Put audio file here", 40, 60, 220, 20) GUICtrlCreateLabel("Volume", 40, 90) $slider_value = GUICtrlCreateSlider(80, 90, 200, 20, $TBS_TOOLTIPS) GUICtrlSetLimit($slider_value, 200, 0) GUICtrlSetData($slider_value, 100) $okbutton = GUICtrlCreateButton("OK", 30, 120, 80, 20) GUICtrlSetOnEvent($okbutton, "OKButton") $playbutton = GUICtrlCreateButton("PLAY/PAUSE", 110, 120, 80, 20) GUICtrlSetOnEvent($playbutton, "PLAYButton") $stopbutton = GUICtrlCreateButton("STOP", 190, 120, 80, 20) GUICtrlSetOnEvent($stopbutton, "STOPButton") $exitbutton = GUICtrlCreateButton("EXIT", 270, 120, 70, 20) GUICtrlSetOnEvent($exitbutton, "EXITButton") ;-------------------------------------------------------------------------- Func BROWSEButton_exe() $select_exe = FileOpenDialog("Browse MPXPLAY.exe", "C:\", "(*.exe)") GUICtrlSetData($input_exe, $select_exe) EndFunc Func BROWSEButton_file() $select_file = FileOpenDialog("Browse the audio file", "C:\", "(*.mp3)") GUICtrlSetData($input_file, $select_file) EndFunc Func OKButton() Local $n8 = '"' & $select_exe & '" ' & '"' & $select_file & '"' Run($n8) EndFunc ;==>OKButton AdlibEnable("volupdate", 100) Func volupdate() Local $nowslider = GUICtrlRead($slider_value) If $nowslider < $slide Then WinActivate("Mpxplay") Send("{, " & Int(($slide - $nowslider)/2) & "}") ElseIf $nowslider > $slide Then WinActivate("Mpxplay") Send("{. " & Int(($nowslider - $slide)/2) & "}") EndIf $slide = $nowslider EndFunc ;==>volupdate Func PLAYButton() WinActivate("Mpxplay") Send("{P}") EndFunc ;==>PLAYButton Func STOPButton() WinActivate("Mpxplay") Send("{S}") EndFunc ;==>STOPButton Func EXITButton() WinActivate("Mpxplay") Send("{Esc}") Exit EndFunc ;==>EXITButton While 1 Sleep(1000) WEnd Link to comment Share on other sites More sharing options...
martin Posted June 30, 2008 Share Posted June 30, 2008 Thanks a lot martin. I was able to advance further. The issue now is as follows:- The dos window of the player has to be on top & activated for any key to work. Hence with the code below, the increments in slider does not work in parallel to the increase in dos window. It happens in kind of jumps. I move the slider->the dos window activates->the volume increases/decreases->but the GUI deactivates. So I have to activate the GUI by clicking with mouse and then repeat the above process. I am not sure if both the GUI and dos window can be activated simultaneously. Or if the dos window can be put/hidden in background but the keys would still work. expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiSlider.au3> Global $slider_value, $slide Global $select_file, $select_exe, $input_file, $input_exe, $browsebutton_exe, $browsebutton_file Global $okbutton, $playbutton, $stopbutton, $exitbutton Opt("GUIOnEventMode", 1) GUICreate("MPXPLAY GUI", 370, 160) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked ;-------------------------------------------------------------------------- $browsebutton_exe = GUICtrlCreateButton("Browse", 270, 20, 70, 20) GUICtrlSetOnEvent($browsebutton_exe, "BROWSEButton_exe") $browsebutton_file = GUICtrlCreateButton("Browse", 270, 60, 70, 20) GUICtrlSetOnEvent($browsebutton_file, "BROWSEButton_file") $input_exe = GUICtrlCreateInput("Put MPXPLAY.exe here", 40, 20, 220, 20) $input_file = GUICtrlCreateInput("Put audio file here", 40, 60, 220, 20) GUICtrlCreateLabel("Volume", 40, 90) $slider_value = GUICtrlCreateSlider(80, 90, 200, 20, $TBS_TOOLTIPS) GUICtrlSetLimit($slider_value, 200, 0) GUICtrlSetData($slider_value, 100) $okbutton = GUICtrlCreateButton("OK", 30, 120, 80, 20) GUICtrlSetOnEvent($okbutton, "OKButton") $playbutton = GUICtrlCreateButton("PLAY/PAUSE", 110, 120, 80, 20) GUICtrlSetOnEvent($playbutton, "PLAYButton") $stopbutton = GUICtrlCreateButton("STOP", 190, 120, 80, 20) GUICtrlSetOnEvent($stopbutton, "STOPButton") $exitbutton = GUICtrlCreateButton("EXIT", 270, 120, 70, 20) GUICtrlSetOnEvent($exitbutton, "EXITButton") ;-------------------------------------------------------------------------- Func BROWSEButton_exe() $select_exe = FileOpenDialog("Browse MPXPLAY.exe", "C:\", "(*.exe)") GUICtrlSetData($input_exe, $select_exe) EndFunc Func BROWSEButton_file() $select_file = FileOpenDialog("Browse the audio file", "C:\", "(*.mp3)") GUICtrlSetData($input_file, $select_file) EndFunc Func OKButton() Local $n8 = '"' & $select_exe & '" ' & '"' & $select_file & '"' Run($n8) EndFunc ;==>OKButton AdlibEnable("volupdate", 100) Func volupdate() Local $nowslider = GUICtrlRead($slider_value) If $nowslider < $slide Then WinActivate("Mpxplay") Send("{, " & Int(($slide - $nowslider)/2) & "}") ElseIf $nowslider > $slide Then WinActivate("Mpxplay") Send("{. " & Int(($nowslider - $slide)/2) & "}") EndIf $slide = $nowslider EndFunc ;==>volupdate Func PLAYButton() WinActivate("Mpxplay") Send("{P}") EndFunc ;==>PLAYButton Func STOPButton() WinActivate("Mpxplay") Send("{S}") EndFunc ;==>STOPButton Func EXITButton() WinActivate("Mpxplay") Send("{Esc}") Exit EndFunc ;==>EXITButton While 1 Sleep(1000) WEndMaybe if you used $mxPID = $Run($n8,@SystemDir, @SW_HIDE, $STDIN_CHILD ) then you could use StdinWrite($mxPID, "." ) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ontherocks Posted July 1, 2008 Author Share Posted July 1, 2008 Thanks a bunch marin. I tried your earlier suggestion using ControlSend and it worked great. The only problem was that the volume control using the slider was not smooth enough. Now you have suggested a StdinWrite. Is this to substitute Controlsend? I am getting errors using StdinWrite which I can't decipher. Link to comment Share on other sites More sharing options...
martin Posted July 1, 2008 Share Posted July 1, 2008 Thanks a bunch marin. I tried your earlier suggestion using ControlSend and it worked great. The only problem was that the volume control using the slider was not smooth enough.Now you have suggested a StdinWrite. Is this to substitute Controlsend?I am getting errors using StdinWrite which I can't decipher.The StdinWrite idea was to replace the ControlSend which I thought about after I'd posted it and decided it probably wouldn't work. Looks like I'm wrong both times! What errors do you get? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ontherocks Posted July 2, 2008 Author Share Posted July 2, 2008 There were some silly syntax errors, which I corrected. Strangely with the "Run" function in this case, both "@SW_HIDE, $STDIN_CHILD" don't work i.e. the mpxplay exe doesn't run. Either I have to put Run($n8, "", @SW_HIDE) or Run($n8, "", $STDIN_CHILD) Its still not clear to me how to replace ControlSend with StdinWrite. For example, I tried something like Func PLAYButton() $n9="{P}" StdinWrite ($mxPID, $n9) EndFunc ;==>PLAYButton But then nothing happens on clicking Play Button 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