pyrofool Posted July 1, 2009 Posted July 1, 2009 The GUI minimizes properly but if I try to show the GUI right after I click one of the tray menus, the gui only maximizes to the tray and does not show fully. This does not happen if I click one of the tray menus and click on the screen before I try to maximize, so I have no idea why it won't fully show up. I know the code is a bit messy but this is my first real application with autoit. Any help would be appreciated, I have been beating my head against the wall for days . CODE#include <GuiConstantsEx.au3> #include <WMMedia.au3> #include <Constants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) Global $is_minimized = 0 ;Tray $TrayMenu_Play = TrayCreateItem("Play") $TrayMenu_Stop = TrayCreateItem("Stop") $TrayMenu_Mute = TrayCreateItem("Mute") TrayCreateItem("") $TrayMenu_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent($TrayMenu_Exit, "Tray_Exit") TrayItemSetOnEvent($TrayMenu_Stop, "Tray_Stop") TraySetClick(8) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Toggle") TraySetToolTip ("Radio Streamer") ;GUI $Radio_Client = GUICreate('Radio Streamer', 200, 200) GuiSetState() GUICtrlCreateLabel('volume:', 10, 90, 50, 20) $checkCN = GUICtrlCreateCheckbox("Mute", 110, 100, 90, 20) $Play_Button = GUICtrlCreateButton("Play", 30, 40, 60, 25) $Stop_Button = GUICtrlCreateButton("Stop", 95, 40, 60, 25) ;$Pause_Button = GUICtrlCreateButton("PAuse", 125, 40, 60, 25) $Label = GUICtrlCreateLabel('4', 50, 90, 50, 20) ;Slider $Slider = GUICtrlCreateSlider(5, 125, 190, 40) GUICtrlSetLimit(-1, 100, 4) GUICtrlSetData(100,1) $Prev = GUICtrlRead($Slider) ;Menu $menu=GuiCtrlCreateMenu("Menu") $about_menu=GUICtrlCreateMenuItem("About", $menu) $stations_menu=GUICtrlCreateMenu("Stations", $menu, 1) $techno=GUICtrlCreateMenu("Techno", $stations_menu, 1) $Happy_Hardcore=GUICtrlCreateMenuItem("Happy Hardcore", $techno) $alt_rock=GUICtrlCreateMenu("Alt Rock", $stations_menu, 1) $WGRD=GUICtrlCreateMenuItem("WGRD", $alt_rock) $top_40=GUICtrlCreateMenu("Top 40", $stations_menu, 1) $hotfm=GUICtrlCreateMenuItem("Hot FM", $top_40) $Jackson=GUICtrlCreateMenuItem("Michael Jackson", $stations_menu, 1) while 1 ;Volume Control $Data = GUICtrlRead($Slider) if $Data <> $Prev then GUICtrlSetData($Label, $Data) $Prev = $Data WmSetVolume($Data) GUICtrlSetState ($checkCN, $GUI_UNCHECKED) endif ;Menu Items $Msg = GUIGetMsg() If $msg = $about_menu Then MsgBox(0, "Info","WGRD Radio 1.0"& @LF & "Created by Christopher Roelofs") endif If $msg = $Happy_Hardcore Then WMStop() $sFilename = ("http://www.di.fm/wma/hardcore.asx ") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $WGRD Then WMStop() $sFilename = ("http://media.streamads.com/clientdata/regent/asx/WGRD.asx") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $hotfm Then WMStop() $sFilename = ("mms://citadelcc-whts-fm.wm.llnwd.net/citadelcc_whts_fm") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $Jackson Then WMStop() $sFilename = ("http://www.mjtunes.com/mjtunesradio-7.asx") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf ;PLay,Pause,Stop,Mute Select Case $msg = $Play_Button $pObj.controls.play() Case $msg = $Stop_Button $pObj.controls.Stop() Case $msg = $checkCN And BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) = $GUI_CHECKED $pObj.settings.volume = (0) GUISetState() Case $msg = $checkCN And BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) <> $GUI_CHECKED WmSetVolume($Data) GUISetState() EndSelect switch $Msg case $GUI_EVENT_CLOSE WMStop() exit Case $GUI_EVENT_MINIMIZE GuiSetState(@SW_HIDE) $is_minimized = 1 endswitch wend ;Minimize Func Toggle() If $is_minimized = 1 Then GuiSetState(@SW_SHOW) $is_minimized = 0 Else GuiSetState(@SW_HIDE) $is_minimized = 1 EndIf EndFunc ;Exit Func Tray_Exit() WMStop() Exit EndFunc Func Tray_Stop() WMStop() EndFunc P.S the script use WMMedia.au3 which I have attachedWMMedia.au3
PsaltyDS Posted July 2, 2009 Posted July 2, 2009 (edited) The GUI minimizes properly but if I try to show the GUI right after I click one of the tray menus, the gui only maximizes to the tray and does not show fully. This does not happen if I click one of the tray menus and click on the screen before I try to maximize, so I have no idea why it won't fully show up. I know the code is a bit messy but this is my first real application with autoit. Any help would be appreciated, I have been beating my head against the wall for days . CODE#include <GuiConstantsEx.au3> #include <WMMedia.au3> #include <Constants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) Global $is_minimized = 0 ;Tray $TrayMenu_Play = TrayCreateItem("Play") $TrayMenu_Stop = TrayCreateItem("Stop") $TrayMenu_Mute = TrayCreateItem("Mute") TrayCreateItem("") $TrayMenu_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent($TrayMenu_Exit, "Tray_Exit") TrayItemSetOnEvent($TrayMenu_Stop, "Tray_Stop") TraySetClick(8) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "Toggle") TraySetToolTip ("Radio Streamer") ;GUI $Radio_Client = GUICreate('Radio Streamer', 200, 200) GuiSetState() GUICtrlCreateLabel('volume:', 10, 90, 50, 20) $checkCN = GUICtrlCreateCheckbox("Mute", 110, 100, 90, 20) $Play_Button = GUICtrlCreateButton("Play", 30, 40, 60, 25) $Stop_Button = GUICtrlCreateButton("Stop", 95, 40, 60, 25) ;$Pause_Button = GUICtrlCreateButton("PAuse", 125, 40, 60, 25) $Label = GUICtrlCreateLabel('4', 50, 90, 50, 20) ;Slider $Slider = GUICtrlCreateSlider(5, 125, 190, 40) GUICtrlSetLimit(-1, 100, 4) GUICtrlSetData(100,1) $Prev = GUICtrlRead($Slider) ;Menu $menu=GuiCtrlCreateMenu("Menu") $about_menu=GUICtrlCreateMenuItem("About", $menu) $stations_menu=GUICtrlCreateMenu("Stations", $menu, 1) $techno=GUICtrlCreateMenu("Techno", $stations_menu, 1) $Happy_Hardcore=GUICtrlCreateMenuItem("Happy Hardcore", $techno) $alt_rock=GUICtrlCreateMenu("Alt Rock", $stations_menu, 1) $WGRD=GUICtrlCreateMenuItem("WGRD", $alt_rock) $top_40=GUICtrlCreateMenu("Top 40", $stations_menu, 1) $hotfm=GUICtrlCreateMenuItem("Hot FM", $top_40) $Jackson=GUICtrlCreateMenuItem("Michael Jackson", $stations_menu, 1) while 1 ;Volume Control $Data = GUICtrlRead($Slider) if $Data <> $Prev then GUICtrlSetData($Label, $Data) $Prev = $Data WmSetVolume($Data) GUICtrlSetState ($checkCN, $GUI_UNCHECKED) endif ;Menu Items $Msg = GUIGetMsg() If $msg = $about_menu Then MsgBox(0, "Info","WGRD Radio 1.0"& @LF & "Created by Christopher Roelofs") endif If $msg = $Happy_Hardcore Then WMStop() $sFilename = ("http://www.di.fm/wma/hardcore.asx ") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $WGRD Then WMStop() $sFilename = ("http://media.streamads.com/clientdata/regent/asx/WGRD.asx") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $hotfm Then WMStop() $sFilename = ("mms://citadelcc-whts-fm.wm.llnwd.net/citadelcc_whts_fm") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf If $msg = $Jackson Then WMStop() $sFilename = ("http://www.mjtunes.com/mjtunesradio-7.asx") ;If @error Then MsgBox(0, "Error","There was an error connecting to the station"& @LF & "choose another station or try again later") WMStartPlayer() $sObj = WMOpenFile($sFilename) $pObj.settings.volume = (4) WMPlay($sFilename) EndIf ;PLay,Pause,Stop,Mute Select Case $msg = $Play_Button $pObj.controls.play() Case $msg = $Stop_Button $pObj.controls.Stop() Case $msg = $checkCN And BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) = $GUI_CHECKED $pObj.settings.volume = (0) GUISetState() Case $msg = $checkCN And BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) <> $GUI_CHECKED WmSetVolume($Data) GUISetState() EndSelect switch $Msg case $GUI_EVENT_CLOSE WMStop() exit Case $GUI_EVENT_MINIMIZE GuiSetState(@SW_HIDE) $is_minimized = 1 endswitch wend ;Minimize Func Toggle() If $is_minimized = 1 Then GuiSetState(@SW_SHOW) $is_minimized = 0 Else GuiSetState(@SW_HIDE) $is_minimized = 1 EndIf EndFunc ;Exit Func Tray_Exit() WMStop() Exit EndFunc Func Tray_Stop() WMStop() EndFuncP.S the script use WMMedia.au3 which I have attached I think you just made the minimize/restore too complicated. Try this for simplification (irrelevant functionality removed): expandcollapse popup#include <GuiConstantsEx.au3> #include <Constants.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) ;Tray $TrayMenu_Play = TrayCreateItem("Play") TrayItemSetOnEvent(-1, "Tray_Play") $TrayMenu_Stop = TrayCreateItem("Stop") TrayItemSetOnEvent(-1, "Tray_Stop") $TrayMenu_Mute = TrayCreateItem("Mute") TrayItemSetOnEvent(-1, "Tray_Mute") TrayCreateItem("") $TrayMenu_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "Tray_Exit") TraySetClick(8) TraySetToolTip("Radio Streamer") ;GUI $Radio_Client = GUICreate('Radio Streamer', 200, 200) GUICtrlCreateLabel('volume:', 10, 90, 50, 20) $checkCN = GUICtrlCreateCheckbox("Mute", 110, 100, 90, 20) $Play_Button = GUICtrlCreateButton("Play", 30, 40, 60, 25) $Stop_Button = GUICtrlCreateButton("Stop", 95, 40, 60, 25) $Label = GUICtrlCreateLabel('4', 50, 90, 50, 20) ;Slider $Slider = GUICtrlCreateSlider(5, 125, 190, 40) GUICtrlSetLimit(-1, 100, 4) GUICtrlSetData(100, 1) $Prev = GUICtrlRead($Slider) ;Menu $menu = GUICtrlCreateMenu("Menu") $about_menu = GUICtrlCreateMenuItem("About", $menu) $stations_menu = GUICtrlCreateMenu("Stations", $menu, 1) $techno = GUICtrlCreateMenu("Techno", $stations_menu, 1) $Happy_Hardcore = GUICtrlCreateMenuItem("Happy Hardcore", $techno) $alt_rock = GUICtrlCreateMenu("Alt Rock", $stations_menu, 1) $WGRD = GUICtrlCreateMenuItem("WGRD", $alt_rock) $top_40 = GUICtrlCreateMenu("Top 40", $stations_menu, 1) $hotfm = GUICtrlCreateMenuItem("Hot FM", $top_40) $Jackson = GUICtrlCreateMenuItem("Michael Jackson", $stations_menu, 1) GUISetState() While 1 ;Volume Control $Data = GUICtrlRead($Slider) If $Data <> $Prev Then GUICtrlSetData($Label, $Data) $Prev = $Data GUICtrlSetState($checkCN, $GUI_UNCHECKED) EndIf ;Menu Items $Msg = GUIGetMsg() Switch $Msg Case $about_menu MsgBox(0, "Info", "WGRD Radio 1.0" & @LF & "Created by Christopher Roelofs") Case $Happy_Hardcore ConsoleWrite("Menu: Happy_Hardcore" & @LF) Case $WGRD ConsoleWrite("Menu: WGRD" & @LF) Case $hotfm ConsoleWrite("Menu: Hot FM" & @LF) Case $Jackson ConsoleWrite("Menu: Michael Jackson" & @LF) Case $Play_Button ConsoleWrite("Button: Play" & @LF) Case $Stop_Button ConsoleWrite("Button: Stop" & @LF) Case $checkCN If BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) = $GUI_CHECKED Then ConsoleWrite("Checkbox: Mute" & @LF) GUISetState() Else ConsoleWrite("Checkbox: Un-Mute" & @LF) GUISetState() EndIf Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) EndSwitch WEnd ; Play Func Tray_Play() ConsoleWrite("Tray: Play" & @LF) GUISetState(@SW_SHOW, $Radio_Client) GUISetState(@SW_RESTORE, $Radio_Client) EndFunc ;==>Tray_Play ; Stop Func Tray_Stop() ConsoleWrite("Tray: Stop" & @LF) GUISetState(@SW_SHOW, $Radio_Client) GUISetState(@SW_RESTORE, $Radio_Client) EndFunc ;==>Tray_Stop ; Mute Func Tray_Mute() ConsoleWrite("Tray: Mute" & @LF) GUISetState(@SW_SHOW, $Radio_Client) GUISetState(@SW_RESTORE, $Radio_Client) EndFunc ;==>Tray_Stop ;Exit Func Tray_Exit() ConsoleWrite("Tray: Exit" & @LF) GUISetState(@SW_SHOW, $Radio_Client) GUISetState(@SW_RESTORE, $Radio_Client) Sleep(500) Exit EndFunc ;==>Tray_Exit Edited July 2, 2009 by PsaltyDS 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
pyrofool Posted July 7, 2009 Author Posted July 7, 2009 Thanks for the response, while your code does work it was not quite what I was thinking. I liked the toggle minimize part but I need to add a Guisetstate(@SW_restore) after the guisetstate(@SW_show). now when i want the gui to appear it maximizes to the tray then it restores itself to the screen. This was the problem the whole time.
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