Sign in to follow this  
Followers 0
Gillboss

Dont see the GUI

5 posts in this topic

why i dont see the gui?

#RequireAdmin
#include <GUIConstants.au3>
#include <File.au3>

Global $play, $stop, $add, $addGui


If Not FileExists(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe") Then
 MsgBox(16, "Crictal", "Windows Media Player must be installed")
 Exit
EndIf

WinClose("Windows Media Player")
Run(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe", "", @SW_HIDE)

Refresh()
 
GUICreate("Radio By G.H", 370, 320, (@DesktopWidth-370)/2, (@DesktopHeight-320)/2)
$play = GUICtrlCreateButton("Play", 300, 10, 60, 30)
$stop = GUICtrlCreateButton("Stop", 300, 40, 60, 30)
$add = GUICtrlCreateButton("Add", 300, 70, 60, 30)
$list = GUICtrlCreateList("Stations", 10, 10, 250, 130)
GUISetState()

 


Func _Play()
 If FileExists(@MyDocumentsDir&"\a.m3u") Then
  FileDelete(@MyDocumentsDir&"\a.m3u")
 EndIf
  
 $file = FileOpen(@MyDocumentsDir&"\a.m3u", 1)
 FileWriteLine($file, "#EXTM3U")
 FileWriteLine($file, "#EXTINF:101, radio")
 FileWriteLine($file, "[url="http://www.mizrahit.co.il/mediaplayer.wax"]http://www.mizrahit.co.il/mediaplayer.wax[/url]")
 FileClose($file)
 ShellExecute(@MyDocumentsDir&"\a.m3u")
 WinActivate("Radio By G.H")
 asd()
EndFunc

Func _Stop()
 WinClose("Windows Media Player")
 asd()
EndFunc

Func _Add()
 $addGui = GUICreate("Add Radio Station", 400, 150, 400, 400)
 GUICtrlCreateLabel("Title", 10, 10, 50, 20)
 $titleR = GUICtrlCreateInput("", 70, 10, 300, 20)
 
 GUICtrlCreateLabel("URL", 10, 40, 50, 20)
 $urlR = GUICtrlCreateInput("", 70, 40, 300, 20)
 
 $add1 = GUICtrlCreateButton("Add", 10, 100, 60, 30)
 $clear1 = GUICtrlCreateButton("Clear", 80, 100, 60, 30)
 $cancle1 = GUICtrlCreateButton("Cancle", 150, 100, 60, 30) 
 GUISetState()
 
 While 1
  $aMsg = GUIGetMsg()
  Switch $aMsg
  Case $GUI_EVENT_CLOSE
   GUIDelete($addGui)
  Case $add1
   If Not FileExists(@MyDocumentsDir&"\Radio.ini") Then
    $file2 = FileOpen(@MyDocumentsDir&"\Radio.ini", 1)
    _FileWriteToLine($file2, 1, "0", 1)
    FileClose($file2)
   EndIf
   
   $count = FileReadLine(@MyDocumentsDir&"\Radio.ini", 1)
   
   $file2 = FileOpen(@MyDocumentsDir&"\Radio.ini", 1)
   _FileWriteToLine($file2, 1 , $count +1, 1)
   _FileWriteToLine($file2, $count + 1, GUICtrlRead($titleR), 1)
   _FileWriteToLine($file2, $count + 1, GUICtrlRead($urlR), 1)
   FileClose($file2)
   GUIDelete($addGui)
   Refresh()
  Case $clear1
   GUICtrlSetData($titleR, "")
   GUICtrlSetData($urlR, "")   
  Case $cancle1
   GUIDelete($addGui)
   asd()
  EndSwitch
 WEnd
EndFunc

Func Refresh()
 If FileExists(@MyDocumentsDir&"\Radio.ini") Then
  $stations = FileReadLine(@MyDocumentsDir&"\Radio.ini", 1)
  
  For $i=2 To $stations Step 2
   $title = FileReadLine(@MyDocumentsDir&"\Radio.ini", $i)
   $url = FileReadLine(@MyDocumentsDir&"\Radio.ini", $i+1)
   GUICtrlSetData($list, $title&" - "&$url)
  Next
 EndIf
 GUIDelete($addGui)
 asd()
EndFunc

Func asd()
 While 1
 If Not WinExists("Windows Media Player") Then
  Run(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe", "", @SW_HIDE)
 EndIf
 $mMsg = GUIGetMsg()
 Switch $mMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $play
   _Play()
  Case $stop
   _Stop()  
  Case $add
   _Add()  
 EndSwitch
WEnd
EndFunc

Share this post


Link to post
Share on other sites



#RequireAdmin
 #include <GUIConstants.au3>
 #include <File.au3>
 
 Global $play, $stop, $add, $addGui
 
 
 If Not FileExists(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe") Then
  MsgBox(16, "Crictal", "Windows Media Player must be installed")
  Exit
 EndIf
 
 WinClose("Windows Media Player")
 Run(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe", "", @SW_HIDE)
 
 GUICreate("Radio By G.H", 370, 320, (@DesktopWidth-370)/2, (@DesktopHeight-320)/2)
 $play = GUICtrlCreateButton("Play", 300, 10, 60, 30)
 $stop = GUICtrlCreateButton("Stop", 300, 40, 60, 30)
 $add = GUICtrlCreateButton("Add", 300, 70, 60, 30)
 $list = GUICtrlCreateList("Stations", 10, 10, 250, 130)
 GUISetState()
 
 Refresh()
 asd() 
 
 Func _Play()
  If FileExists(@MyDocumentsDir&"\a.m3u") Then
   FileDelete(@MyDocumentsDir&"\a.m3u")
  EndIf
  
  $file = FileOpen(@MyDocumentsDir&"\a.m3u", 1)
  FileWriteLine($file, "#EXTM3U")
  FileWriteLine($file, "#EXTINF:101, radio")
  FileWriteLine($file, "http://www.mizrahit.co.il/mediaplayer.wax")
  FileClose($file)
  ShellExecute(@MyDocumentsDir&"\a.m3u")
  WinActivate("Radio By G.H")
  asd()
 EndFunc
 
 Func _Stop()
  WinClose("Windows Media Player")
  asd()
 EndFunc
 
 Func _Add()
  $addGui = GUICreate("Add Radio Station", 400, 150, 400, 400)
  GUICtrlCreateLabel("Title", 10, 10, 50, 20)
  $titleR = GUICtrlCreateInput("", 70, 10, 300, 20)
  
  GUICtrlCreateLabel("URL", 10, 40, 50, 20)
  $urlR = GUICtrlCreateInput("", 70, 40, 300, 20)
  
  $add1 = GUICtrlCreateButton("Add", 10, 100, 60, 30)
  $clear1 = GUICtrlCreateButton("Clear", 80, 100, 60, 30)
  $cancle1 = GUICtrlCreateButton("Cancle", 150, 100, 60, 30)
  GUISetState()
  
  While 1
   $aMsg = GUIGetMsg()
   Switch $aMsg
   Case $GUI_EVENT_CLOSE
    GUIDelete($addGui)
   Case $add1
    If Not FileExists(@MyDocumentsDir&"\Radio.ini") Then
     $file2 = FileOpen(@MyDocumentsDir&"\Radio.ini", 1)
     _FileWriteToLine($file2, 1, "0", 1)
     FileClose($file2)
    EndIf
    
    $count = FileReadLine(@MyDocumentsDir&"\Radio.ini", 1)
    
    $file2 = FileOpen(@MyDocumentsDir&"\Radio.ini", 1)
    _FileWriteToLine($file2, 1 , $count +1, 1)
    _FileWriteToLine($file2, $count + 1, GUICtrlRead($titleR), 1)
    _FileWriteToLine($file2, $count + 1, GUICtrlRead($urlR), 1)
    FileClose($file2)
    GUIDelete($addGui)
    Refresh()
   Case $clear1
    GUICtrlSetData($titleR, "")
    GUICtrlSetData($urlR, "")   
   Case $cancle1
    GUIDelete($addGui)
    asd()
   EndSwitch
  WEnd
 EndFunc
 
 Func Refresh()
  If FileExists(@MyDocumentsDir&"\Radio.ini") Then
   $stations = FileReadLine(@MyDocumentsDir&"\Radio.ini", 1)
  
   For $i=2 To $stations Step 2
    $title = FileReadLine(@MyDocumentsDir&"\Radio.ini", $i)
    $url = FileReadLine(@MyDocumentsDir&"\Radio.ini", $i+1)
    GUICtrlSetData($list, $title&" - "&$url)
   Next
  EndIf
  GUIDelete($addGui)
  asd()
 EndFunc
 
 Func asd()
  While 1
  If Not WinExists("Windows Media Player") Then
   Run(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe", "", @SW_HIDE)
  EndIf
  $mMsg = GUIGetMsg()
  Switch $mMsg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $play
    _Play()
   Case $stop
    _Stop() 
   Case $add
    _Add() 
  EndSwitch
 WEnd
 EndFunc

Share this post


Link to post
Share on other sites

yet not work, its open gui but soon hide it..

Share this post


Link to post
Share on other sites

You have no While WEnd loop, of course it's going to end.

Main loop was inside asd() function, but he mixed-up two GUI loops together.

#RequireAdmin
 #include <GUIConstants.au3>
 #include <File.au3>
 
 Global $play, $stop, $add, $addGui
 
 
 If Not FileExists(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe") Then
  MsgBox(16, "Crictal", "Windows Media Player must be installed")
  Exit
 EndIf
 
 WinClose("Windows Media Player")
 Run(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe", "", @SW_HIDE)
 
 $mainGui = GUICreate("Radio By G.H", 370, 320, (@DesktopWidth-370)/2, (@DesktopHeight-320)/2)
 $play = GUICtrlCreateButton("Play", 300, 10, 60, 30)
 $stop = GUICtrlCreateButton("Stop", 300, 40, 60, 30)
 $add = GUICtrlCreateButton("Add", 300, 70, 60, 30)
 $list = GUICtrlCreateList("Stations", 10, 10, 250, 130)
 GUISetState()
 
 Refresh()
 
 While 1
     If Not WinExists("Windows Media Player") Then
         Run(@ProgramFilesDir&"\Windows Media Player\wmplayer.exe", "", @SW_HIDE)
     EndIf
 
     $mMsg = GUIGetMsg()
     Switch $mMsg
     Case $GUI_EVENT_CLOSE
     Exit
     Case $play
     _Play()
     Case $stop
     _Stop() 
     Case $add
     _Add() 
     EndSwitch
 WEnd
 
 Func _Play()
  If FileExists(@MyDocumentsDir&"\a.m3u") Then
   FileDelete(@MyDocumentsDir&"\a.m3u")
  EndIf
  
  $file = FileOpen(@MyDocumentsDir&"\a.m3u", 1)
  FileWriteLine($file, "#EXTM3U")
  FileWriteLine($file, "#EXTINF:101, radio")
  FileWriteLine($file, "http://www.mizrahit.co.il/mediaplayer.wax")
  FileClose($file)
  ShellExecute(@MyDocumentsDir&"\a.m3u")
  WinActivate("Radio By G.H")
 ;~  asd()
 EndFunc
 
 Func _Stop()
  WinClose("Windows Media Player")
 ;~  asd()
 EndFunc
 
 Func _Add()
  $addGui = GUICreate("Add Radio Station", 400, 150, 400, 400)
  GUICtrlCreateLabel("Title", 10, 10, 50, 20)
  $titleR = GUICtrlCreateInput("", 70, 10, 300, 20)
  
  GUICtrlCreateLabel("URL", 10, 40, 50, 20)
  $urlR = GUICtrlCreateInput("", 70, 40, 300, 20)
  
  $add1 = GUICtrlCreateButton("Add", 10, 100, 60, 30)
  $clear1 = GUICtrlCreateButton("Clear", 80, 100, 60, 30)
  $cancle1 = GUICtrlCreateButton("Cancle", 150, 100, 60, 30)
  GUISetState(@SW_SHOW,$addGui)
  
  While 1
   $aMsg = GUIGetMsg(1)
   If $aMsg[1] = $addGui Then ; react only on messages from Add GUI
       Switch $aMsg[0]
       Case $GUI_EVENT_CLOSE
        GUIDelete($addGui)
        ExitLoop
       Case $add1
        If Not FileExists(@MyDocumentsDir&"\Radio.ini") Then
         $file2 = FileOpen(@MyDocumentsDir&"\Radio.ini", 1)
         _FileWriteToLine($file2, 1, "0", 1)
         FileClose($file2)
        EndIf
        
        $count = FileReadLine(@MyDocumentsDir&"\Radio.ini", 1)
        
        $file2 = FileOpen(@MyDocumentsDir&"\Radio.ini", 1)
        _FileWriteToLine($file2, 1 , $count +1, 1)
        _FileWriteToLine($file2, $count + 1, GUICtrlRead($titleR), 1)
        _FileWriteToLine($file2, $count + 1, GUICtrlRead($urlR), 1)
        FileClose($file2)
        GUIDelete($addGui)
        Refresh()
        ExitLoop
       Case $clear1
        GUICtrlSetData($titleR, "")
        GUICtrlSetData($urlR, "")   
       Case $cancle1
        GUIDelete($addGui)
        ExitLoop
     ;~    asd()
     EndSwitch
     EndIf
  WEnd
 EndFunc
 
 Func Refresh()
  If FileExists(@MyDocumentsDir&"\Radio.ini") Then
   $stations = FileReadLine(@MyDocumentsDir&"\Radio.ini", 1)
  
   For $i=2 To $stations Step 2
    $title = FileReadLine(@MyDocumentsDir&"\Radio.ini", $i)
    $url = FileReadLine(@MyDocumentsDir&"\Radio.ini", $i+1)
    GUICtrlSetData($list, $title&" - "&$url)
   Next
  EndIf
 ;~  GUIDelete($addGui)
 ;~  asd()
 EndFunc

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