Jump to content
Sign in to follow this  
MrDeltaX

Onevent Mode

Recommended Posts

MrDeltaX

Hi guys I am working at a script and it is almost done.

I only have some problems.

I can't do onevent mode in the about box :)

I wan't that the close button closes the about box

and that the ga naar mijn site button leads you to my site.

But I can't get it working.

Maybe some of you could help me ?

O and also if I press the INSERT button everything hides but if you have the about box opened than the aboutbox doesn't hide.

PS: the text in the programm is Dutch I hope you understand it.

Thanks Alot ;)

Here's is the script

#include <GUIConstants.au3>
#include <constants.au3>
#include <IE.au3>

Opt("TrayMenuMode", 0)
Opt("TrayOnEventMode", 1)
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 3)


HotKeySet("{INSERT}", "GUI_HIDE")
HotKeySet("!u", "Unhide")
HotKeySet("{ESC}", "exitt")


;other value's
$save=0
$aboutt=0


; Check default value in registry
$DefaultStation = "slamfm" 
$read = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm", "zender"); See if key exists
ConsoleWrite("Debug: At start, $read = " & $read & @LF)
If $read = "" And $save=1 Then
   ; Create reg key if required
    ConsoleWrite("Debug: Writing reg key HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm\zender = " & $DefaultStation & @LF)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm", "zender", "reg_sz", $DefaultStation)
    $read = $DefaultStation
EndIf

; Setup up tray icon
TraySetToolTip("Nederland FM")
TraySetState(2)
$TrayMenu_Exit = TrayCreateItem("Exit")
TraySetClick(8)
TrayItemSetOnEvent($TrayMenu_Exit, "GUI_Exit")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Tray_Restore")

; Setup GUI
$Nederland = GUICreate("Nederland.FM", @DesktopWidth - 200, @DesktopHeight - 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Exit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "GUI_Hide")

$radio = _IECreateEmbedded()
;GuiCtrlSetBkColor(-1, 0x00FF00)
$object = GUICtrlCreateObj($radio, 10, 10, @DesktopWidth - 220, @DesktopHeight - 250)
$combo = GUICtrlCreateCombo($DefaultStation, 10, @DesktopHeight - 230, 100, 120)

GUICtrlSetData(-1, "radio538|caz|tmfradio|3fm|538nonstop40|bnnfm|jumpstyle|q-music|538dancedept|", $read)
GUICtrlSetOnEvent(-1, "_ComboSel")
GUISetState(@SW_SHOW, $Nederland)
_IENavigate($radio, "http://www.nederland.fm?z=" & $read, 0)
GUICtrlCreateLabel("Selecteer je kanaal.",120,@DesktopHeight -225,200,120)
;GUICtrlCreateLabel("Je laatst gekozen kanaal opslaan",400,@DesktopHeight -225,200,120)
$check=GUICtrlCreateCheckbox("Je laatst gekozen kanaal opslaan.",400,@DesktopHeight -225,200,20)
$state=GUISetState() 
$about=GUICtrlCreateButton("About",600,@DesktopHeight -230,100,25)
GUICtrlSetOnEvent($about, "about")
GUICtrlSetOnEvent($check,"save")









While 1
    
$msg = GUIGetMsg()
Sleep(10)

if $msg = $check Then
    
    MsgBox(1,"test","test")
    
    EndIf





WEnd








Func Tray_Restore()
    GUISetState(@SW_SHOW, $Nederland)
    TraySetState(2)
    GUISetState(@SW_RESTORE, $Nederland)
EndFunc  ;==>Tray_Restore

Func GUI_Exit()
   ; Save current selection to reg key
    If $save = 1 Then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm", "zender", "reg_sz", GUICtrlRead($combo))
Else
        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm")
EndIf

    Exit
EndFunc  ;==>GUI_Exit






Func exitt()
    Exit
    EndFunc



Func endabout()
    
MsgBox(64, "Test", "Parent GUI will now close.")


GUIDelete()

EndFunc


Func about()
    


$12=0
$aboutt=1
$Form1 = GUICreate("About", 337, 263, 193, 115,$WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE,$Nederland)
$Label1 = GUICtrlCreateLabel("                                Nederland.FM vieuwer                                     ", 0, 0, 330, 17)
GUICtrlCreateInput("www.MrdeltaX.wordpress.com", 0, 136, 329, 21)
$Button1 = GUICtrlCreateButton("Close", 0, 200, 329, 25, 0)
GUISetOnEvent($button1,"endabout")
$Button2 = GUICtrlCreateButton("Ga naar mijn website.", 0, 168, 329, 25, 0)
$Label2 = GUICtrlCreateLabel("  Check mijn website voor meer functie's :", 0, 112, 330, 17)
$Label3 = GUICtrlCreateLabel("                                   Made by Mr.DeltaX                                       ", 0, 24, 337, 19)
GUICtrlSetFont(-1, 8, 400, 4, "Comic Sans MS")
GUICtrlSetColor(-1, 0x00FFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Icon1 = GUICtrlCreateIcon("", 0, 280, 72, 41, 33, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetCursor ($Icon1, 2)
GUICtrlSetData(-1, 25)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)


EndFunc



        
        Func website()
            _IENavigate($radio, "www.mrdeltax.wordpress.com", 0)
            EndFunc







Func save()
    
$save=1
    
    EndFunc



    
    
    
    
    

    
    

    
    
    

Func GUI_Hide()
    GUISetState(@SW_HIDE, $Nederland)
    TraySetState(1)
    Opt("TrayIconHide", 1)   
EndFunc  ;==>GUI_Hide

Func Unhide()
    
        GUISetState(@SW_SHOW, $Nederland)
    TraySetState(0)
    Opt("TrayIconHide", 0)   
    
    
    EndFunc


Func _ComboSel()
    _IEAction($radio, "stop")
    Sleep(250)
    _IENavigate($radio, "http://www.nederland.fm?z=" & GUICtrlRead($combo), 0)
EndFunc  ;==>_ComboSel

Share this post


Link to post
Share on other sites
DW1

#include <GUIConstants.au3>
#include <constants.au3>
#include <IE.au3>

Opt("TrayMenuMode", 0)
Opt("TrayOnEventMode", 1)
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 3)

HotKeySet("{INSERT}", "GUI_HIDE")
HotKeySet("!u", "Unhide")
HotKeySet("{ESC}", "exitt")

;other value's
$save = 0
$aboutt = 0
$hidden = 0 ; this specifies that the about box is not to be shown
; Check default value in registry
$DefaultStation = "slamfm" 
$read = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm", "zender"); See if key exists
ConsoleWrite("Debug: At start, $read = " & $read & @LF)
If $read = "" And $save = 1 Then
    ; Create reg key if required
    ConsoleWrite("Debug: Writing reg key HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm\zender = " & $DefaultStation & @LF)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm", "zender", "reg_sz", $DefaultStation)
    $read = $DefaultStation
EndIf

; Setup up tray icon
TraySetToolTip("Nederland FM")
TraySetState(2)
$TrayMenu_Exit = TrayCreateItem("Exit")
TraySetClick(8)
TrayItemSetOnEvent($TrayMenu_Exit, "GUI_Exit")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Tray_Restore")

; Setup GUI
$Nederland = GUICreate("Nederland.FM", @DesktopWidth - 200, @DesktopHeight - 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Exit")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "GUI_Hide")

$radio = _IECreateEmbedded()
;GuiCtrlSetBkColor(-1, 0x00FF00)
$object = GUICtrlCreateObj($radio, 10, 10, @DesktopWidth - 220, @DesktopHeight - 250)
$combo = GUICtrlCreateCombo($DefaultStation, 10, @DesktopHeight - 230, 100, 120)

GUICtrlSetData(-1, "radio538|caz|tmfradio|3fm|538nonstop40|bnnfm|jumpstyle|q-music|538dancedept|", $read)
GUICtrlSetOnEvent(-1, "_ComboSel")
GUISetState(@SW_SHOW, $Nederland)
_IENavigate($radio, "http://www.nederland.fm?z=" & $read, 0)
GUICtrlCreateLabel("Selecteer je kanaal.", 120, @DesktopHeight - 225, 200, 120)
;GUICtrlCreateLabel("Je laatst gekozen kanaal opslaan",400,@DesktopHeight -225,200,120)
$check = GUICtrlCreateCheckbox("Je laatst gekozen kanaal opslaan.", 400, @DesktopHeight - 225, 200, 20)
$state = GUISetState()
$about = GUICtrlCreateButton("About", 600, @DesktopHeight - 230, 100, 25)
GUICtrlSetOnEvent($about, "about")
GUICtrlSetOnEvent($check, "save")


$12 = 0
$aboutt = 1
$Form1 = GUICreate("About", 337, 263, 193, 115, $WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE, $Nederland)
$Label1 = GUICtrlCreateLabel("                                  Nederland.FM vieuwer                                       ", 0, 0, 330, 17)
GUICtrlCreateInput("www.MrdeltaX.wordpress.com", 0, 136, 329, 21)
$Button1 = GUICtrlCreateButton("Close", 0, 200, 329, 25, 0)
GUICtrlSetOnEvent($Button1, "endabout")
$Button2 = GUICtrlCreateButton("Ga naar mijn website.", 0, 168, 329, 25, 0)
GUICtrlSetOnEvent( -1, "gotosite" )
$Label2 = GUICtrlCreateLabel("    Check mijn website voor meer functie's :", 0, 112, 330, 17)
$Label3 = GUICtrlCreateLabel("                                     Made by Mr.DeltaX                                         ", 0, 24, 337, 19)
GUICtrlSetFont(-1, 8, 400, 4, "Comic Sans MS")
GUICtrlSetColor(-1, 0x00FFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Icon1 = GUICtrlCreateIcon("", 0, 280, 72, 41, 33, BitOR($SS_NOTIFY, $WS_GROUP))
GUICtrlSetCursor($Icon1, 2)
GUICtrlSetData(-1, 25)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, 0xFF0000)


While 1
    $msg = GUIGetMsg()
    Sleep(10)
    If $msg = $check Then
        MsgBox(1, "test", "test")
    EndIf
WEnd

Func Tray_Restore()
    GUISetState(@SW_SHOW, $Nederland)
    TraySetState(2)
    GUISetState(@SW_RESTORE, $Nederland)
EndFunc   ;==>Tray_Restore

Func GUI_Exit()
    ; Save current selection to reg key
    If $save = 1 Then
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm", "zender", "reg_sz", GUICtrlRead($combo))
    Else
        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\nederland\nederlandfm")
    EndIf

    Exit
EndFunc   ;==>GUI_Exit

Func exitt()
    Exit
EndFunc   ;==>exitt

Func endabout()
    GUISetState(@SW_HIDE, $Form1)
    $hidden = 0
EndFunc   ;==>endabout

Func about()
    GUISetState(@SW_SHOW, $Form1)
    $hidden = 1
EndFunc   ;==>about

Func website()
    _IENavigate($radio, "www.mrdeltax.wordpress.com", 0)
EndFunc   ;==>website

Func save()
    $save = 1
EndFunc   ;==>save

Func GUI_Hide()
    GUISetState(@SW_HIDE, $Nederland)
    If $hidden = 1 Then
        GUISetState(@SW_HIDE, $Form1)
    EndIf
    TraySetState(1)
    Opt("TrayIconHide", 1)
EndFunc   ;==>GUI_Hide

Func Unhide()
    GUISetState(@SW_SHOW, $Nederland)
    If $hidden = 1 Then
        GUISetState(@SW_SHOW, $Form1)
    EndIf
    TraySetState(0)
    Opt("TrayIconHide", 0)
EndFunc   ;==>Unhide

Func _ComboSel()
    _IEAction($radio, "stop")
    Sleep(250)
    _IENavigate($radio, "http://www.nederland.fm?z=" & GUICtrlRead($combo), 0)
EndFunc   ;==>_ComboSel

Func gotosite()
    _IECreate( "www.google.com" )
    ; or you can do this embedded
    _IENavigate($radio, "http://www.google.com" )
EndFunc

The last function needs to be adjusted to your needs

Edited by danwilli

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.