Jump to content

Need help with my code ! Take a peek inside !


Ruud0209
 Share

Recommended Posts

Could someone please put this in scite, run it and then tell me what i'm doing wrong ?

The thing is, I can't get the GUI's to work like they should. I suppose it's to do with @SW_HIDE and maybe winhandle() and maybe continueloops and exitloops but F1 doesn't really help anymore.

Run the code and press Alt-S to popup the settings GUI then press the "Admin Tools" button and then select "Snelkoppeling naar ander account". Then try to go back to the previous GUIS to do something there. It's NOT WORKING ANYMORE ! Why ?

I'm out of options and I've been trying on and off for three days now. :wacko::mad: :"> -_-

I know i'm doing something wrong but the big question is. WHERE and (why of course) so if you are replying

then point out WHERE i'm going wrong (elaborate a bit) if you can ?

[Warning]

Registry keys are written when you install (press yes on 1st messagebox) but they are pretty harmless.

HKLM\Software\Zuilen

HKCU\Software\Zuilen

HKCU\Software\Microsoft\Windows\Currentversion\Run\Zuilen

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen

You can safely delete the above key when found. !

[/Warning]

;; Includes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#Include <GUIConstants.au3>                 ;;
#Include <IE.au3>                                  ;;
#include <GuiCombo.au3>                      ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Degfine Globals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global $lokatie                  ;;
Global $inifile                  ;;
Global $initem                   ;;
Global $installitem              ;;
Global $regcheckini              ;;
Global $regreadinstall           ;;
Global $regreadautorun           ;;
Global $regreadkiosk             ;;
Global $version = "2.2.0.58"     ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;Check registry and set variables accordingly
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$regreadini = RegRead("HKEY_CURRENT_USER\Software\Zuilen","ReadIni")                                                ;;
Select                                                                                                              ;;
    Case $regreadini = ""                                                                                       ;;
        $regcheckini = 0                                                                                    ;;
    Case $regreadini = 1                                                                                        ;;
        $regcheckini = 1  ;obviously                                                                        ;;
    Case Else                                                                                                   ;;
        $regcheckini = 0                                                                                    ;;
EndSelect                                                                                                           ;;
;;
$regreadautorun = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Zuilen")               ;;
Select                                                                                                              ;;
    Case $regreadautorun = ""                                                                                   ;;
        $regreadautorun = 0                                                                                 ;;
    Case Else                                                                                                   ;;
        $regreadautorun = 1                                                                                 ;;
EndSelect                                                                                                           ;;
;;
$regreadkiosk = RegRead("HKEY_CURRENT_USER\Software\Zuilen","Kioskmode")                                            ;;
Select                                                                                                              ;;
    Case $regreadkiosk = ""                                                                                     ;;
        $regreadkiosk = 0                                                                                   ;;
    case $regreadkiosk = 0                                                                                      ;;
        $regreadkiosk = 0 ;obviously                                                                        ;;
    case Else                                                                                                   ;;
        $regreadkiosk = 1                                                                                   ;;
EndSelect                                                                                                           ;;
;;
$regreadinstall = RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","InstallPath")                                       ;;
If $regreadinstall = "" Then $regreadinstall = -1                                                                   ;;
;;
$regreadpingspeed = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed")                                        ;;
$regreadpingival = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingInterval")                                      ;;
;;
If @Compiled = 1 Then                                                                                               ;;
    $inifile = @ScriptDir & "\" & StringReplace(@Scriptname,".exe",".ini")                                          ;;
Else                                                                                                                ;;
    ;   MsgBox(0,"","Not Compiled = : " & @Error )                                                                  ;;
    $inifile = @ScriptDir & "\" & StringReplace(@Scriptname,".au3",".ini")                                          ;;
Endif                                                                                                               ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Check if process is already running, of so then error.
;;;;;;;;;;;;;;;;;;;
_TestActive()    ;;
;;;;;;;;;;;;;;;;;;;


;; Options
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Opt("GUIOnEventMode", 0)  ; Change to OnEvent mode                                             ;;
Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.      ;;
Opt("TrayIconDebug",0)  ; Debug in tooltip                                                     ;;
Opt("TrayAutoPause",1)                                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; TrayTip
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _TrayTip()                                                                                                                     ;;
    local $trayping                                                                                                             ;;
    local $trayini                                                                                                              ;;
    local $trayautorun                                                                                                          ;;
    local $traylokatie = $lokatie                                                                                               ;;
    $trayping = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed")                                                        ;;
    $traypingival = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingInterval")                                                 ;;
    ;MsgBox(0,"",RegRead("HKEY_CURRENT_USER\Software\Zuilen","ReadIni"))                                                        ;;
    If $regcheckini = 0 Then                                                                                                    ;;
        $trayini = "Uit"                                                                                                    ;;
    Else                                                                                                                        ;;
        $trayini = "Aan"                                                                                                    ;;
    EndIf                                                                                                                       ;;
    ;;
    If $regreadautorun = 0 Then                                                                                                 ;;
        $trayautorun = "Uit"                                                                                                ;;
    Else                                                                                                                        ;;
        $trayautorun = "Aan"                                                                                                ;;
    EndIf                                                                                                                       ;;
    TrayTip ("Hermes Zuilen :" & $version, "Het Zuilen programma is aktief" & @CRLF & "Ping latency : "& $trayping & " ms." _   ;;
    & @CRLF & "Ping Interval : "& $traypingival & " seconden"& @CRLF &  "INI lezen is " & $trayini & @CRLF &  "Autorun is " _   ;;
    & $trayautorun & @CRLF &  "Lokatie is " & $traylokatie & @CRLF &  "Druk op F1 voor Help", 5, 1)                             ;;
EndFunc                                                                                                                             ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;splashimage
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
SplashImageOn("Hermes Groep NV","zuilen_banner.jpg","480","120","-1","-1",1)                  ;;
Sleep ( 1000 )                                                                                ;;
SplashOff()                                                                                   ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Stel lokatie in
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$setlokatie = _ReadIni()                                                                                                                                  ;;
;MsgBox(0,"Ini", "Value :"& $setlokatie)                                                                                                                  ;;
If  $setlokatie = "0" then                                                                                                                                ;;
    ;;
    DIM $IP = @IPAddress1 ; get local IP                                                                                                              ;;
    $lokatie = StringReplace(StringReplace($IP, "." , "" ),"14579","") ; From the ip adress replace the "." with nothing then replace 14579 with nothing. ;;
    ; MsgBox (64,"ip = ", $lokatie )                                                                                                                  ;;
    Select                                                                                                                                            ;;
        case $lokatie = "17343" ; If ip adress ends with                                                                                          ;;
            $lokatie = "EINDHOVEN" ;  Lokatie = City                                                                                          ;;
        case $lokatie = "17415"                                                                                                                   ;;
            $lokatie = "EINDHOVEN"                                                                                                            ;;
        case $lokatie = "166"                                                                                                                     ;;
            $lokatie = "HEERLEN"                                                                                                              ;;
        case $lokatie = "17715"                                                                                                                   ;;
            $lokatie = "HEERLEN"                                                                                                              ;;
        case $lokatie = "17845"                                                                                                                   ;;
            $lokatie = "HEERLEN"                                                                                                              ;;
        case $lokatie = "18215"                                                                                                                   ;;
            $lokatie = "HELMOND"                                                                                                              ;;
        case $lokatie = "17015"                                                                                                                   ;;
            $lokatie = "MAASTRICHT"                                                                                                           ;;
        case $lokatie = "17853"                                                                                                                   ;;
            $lokatie = "MAASTRICHT"                                                                                                           ;;
        case $lokatie = "17615"                                                                                                                   ;;
            $lokatie = "NIJMEGEN"                                                                                                             ;;
        case $lokatie = "17815"                                                                                                                   ;;
            $lokatie = "NIJMEGEN"                                                                                                             ;;
        case $lokatie = "17834"                                                                                                                   ;;
            $lokatie = "NIJMEGEN"                                                                                                             ;;
        case $lokatie = "17867"                                                                                                                   ;;
            $lokatie = "ROERMOND"                                                                                                             ;;
        case $lokatie = "16915"                                                                                                                   ;;
            $lokatie = "SITTARD"                                                                                                              ;;
        case $lokatie = "17860"                                                                                                                   ;;
            $lokatie = "VENLO"                                                                                                                ;;
        case $lokatie = "17915"                                                                                                                   ;;
            $lokatie = "VENLO"                                                                                                                ;;
        case Else                                                                                                                                 ;;
            $lokatie = _SelectLok()                                                                                                           ;;
            ;;
    EndSelect                                                                                                                                         ;;
Else                                                                                                                                                      ;;
    If @Compiled = 1 Then                                                                                                                             ;;
        $inifile = @ScriptDir & "\" & StringReplace(@Scriptname,".exe",".ini")                                                                    ;;
    Else                                                                                                                                              ;;
        $inifile = @ScriptDir & "\" & StringReplace(@Scriptname,".au3",".ini")                                                                    ;;
    Endif                                                                                                                                             ;;
    If not FileExists($inifile) Then                                                                                                                  ;;
        MsgBox (16 , "Fout :","Het bestand " & $inifile & " is niet gevonden" & @CRLF & "Er wordt een bestand aangemaakt",2)                      ;;
        IniWrite($inifile,"Instellingen","Lokatie","Eindhoven")                                                                                   ;;
        _restart()                                                                                                                                ;;
    Else                                                                                                                                              ;;
        $lokatie = IniRead( $inifile,"Instellingen","Lokatie","Rayon")                                                                            ;;
        If $lokatie = "Rayon" Then                                                                                                                ;;
            MsgBox (16 , "Fout :","Het bestand " & $inifile & " bevat een fout op de lokatie sleutel : " & $lokatie & @CRLF _                             ;;
            & "Herstel de fout en start het programma opnieuw",5)                                                                                 ;;
            ;       RunWait("notepad.exe " & $inifile)                                                                                        ;;
            _restart()                                                                                                                        ;;
        Else                                                                                                                                      ;;
            MsgBox (64,"Lokatie :", "Lokatie ingesteld op : " & $lokatie ,2)                                                                  ;;
        EndIf                                                                                                                                     ;;
    Endif                                                                                                                                             ;;
EndIf                                                                                                                                                     ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;; Hotkeys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HotKeySet ("!{F4}","terminate")        ;;
;HotKeySet ("!{F12}","_Admintools")     ;;
HotKeySet ("{F1}","_help")             ;;
HotKeySet ("!s","_Settings")       ;;
HotKeySet ("!o","_About")              ;;
HotKeySet ("!r","_restart")            ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;Run the Traytip iinfo Function
;;;;;;;;;;;;;;;
_TrayTip()   ;;
;;;;;;;;;;;;;;;


;;Run the Actual Program Function, this is what it;s all about.
;;;;;;;;;;;;;;;
_RunForm()   ;;
;;;;;;;;;;;;;;;

;; The About box
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _About()                                                                                                                              ;;
    Msgbox(64, "Over:", "Hermes Zuilen Emulator" & @CRLF & "Ruud Sas " & Chr("169") & " (2006)"& @CRLF & "Version : " & $version )         ;;
EndFunc                                                                                                                                    ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; This is what it's all about !
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _RunForm()                                                                                                                                                               ;;
    If $regreadkiosk = 1 Then                                                                                                                                             ;;
        Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode                                                                                                                    ;;
        $Form1 = GUICreate("Zuilen Pagina", 1024, 772, (@DesktopWidth - 1024) /2, (@DesktopHeight - 768) /2,  BitOR($WS_POPUP,$WS_EX_TOPMOST  )) ; create the GUI object      ;;
    Else                                                                                                                                                                      ;;
        Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode                                                                                                                    ;;
        GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")                                                                                                                          ;;
        $Form1 = GUICreate("Zuilen Pagina", 1024, 772, (@DesktopWidth - 1024) /2, (@DesktopHeight - 768) /2 )                                   ; create the GUI object       ;;
    EndIf                                                                                                                                                                 ;;
    ; The Internet Explorer object will be projected on this object.                                                                                                      ;;
    ;;
    ;;
    ;;
    ;;
    $Obj = _IECreateEmbedded ( )                                                                                                                                          ;;
    $browser = GUICtrlCreateObj($Obj, 0, 0, 1024, 772 )                                                                                                                   ;;
    GUISetState(@SW_SHOW)                                                                                                                                                 ;;
    _IENavigate ($Obj, 'about:blank')                                                                                                                                     ;;
    dim $sHTML                                                                                                                                                            ;;
    $sHTML = "<HTML><BODY><BR><BR><BR><CENTER><h1 style='font-family : ARIAL; color: #000377'>" _                                                                         ;;
    & "Er wordt verbinding gezocht met de server ...</h1><BR>" _                                                                                          ;;
    & " <h2 style='font-family : ARIAL; font-size : 20px; font-weight :bold; color: #000377'>Een moment geduld a.u.b.</h2>" _                             ;;
    & "<BR><BR><BR><h2 style='font-family : ARIAL; color: #000377'> Lokatie : " & $lokatie & "</h2></CENTER></body></html>"                               ;;
    _IEBodyWriteHTML ($Obj, $sHTML)                                                                                                                                       ;;
    ;;
    $online = 1                                                                                                                                                           ;;
    $wasonline = 0                                                                                                                                                        ;;
    ;;
    $ping = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed")                                                                                                      ;;
    $pingival = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingInterval")                                                                                               ;;
    TraySetToolTip("Ping latency : " & $ping & " ms." & @CRLF & "Ping interval : " & $pingival & " seconden")                                                             ;;
    ;;
    while   1                                                                                                                                                                     ;;
        ;;
        if Ping("callisto.hermes.nl",$ping ) Then                                                                                                                     ;;
            ;ConsoleWrite("ping !")                                                                                                                               ;;
            $online = 1                                                                                                                                           ;;
            TraySetIcon( @ScriptFullPath,0)                                                                                                                       ;;
        Else                                                                                                                                                          ;;
            $online = 0                                                                                                                                           ;;
            TraySetIcon("Shell32.dll",109)                                                                                                                        ;;
        EndIf                                                                                                                                                         ;;
        ;;
        if $wasonline <> $online Then                                                                                                                                 ;;
            WinActivate($Form1)                                                                                                                                   ;;
            $wasonline = $online                                                                                                                                  ;;
            if $online Then                                                                                                                                       ;;
                ;;
                _IENavigate ($Obj, 'http://callisto.hermes.nl:7778/pls/portal/portal.wwctx_app_language.set_language?p_http_language=nl&p_nls_language=nl&p_nls_' _           ;;
                & 'territory=THE%20NETHERLANDS&p_requested_url=%2Fpls%2Fportal%2FURL%2FPAGE%2FHMS_DIRECT_GRP%2FHMS_HOME_DIR%3Fp_rayon%3D' _                                   ;;
                & $lokatie & '%26p_ipadres%3D' & @IPAddress1 & '","jav","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0' _                                ;;
                & ',resizable=0,width=1024,height=768,left=0,top=0,fullscreen=1,resizable=no,name=zuilen')                                                                    ;;
                ;_IENavigate ($Obj, 'http://www.google.com')                                                                                                  ;;
                ;;
            Else                                                                                                                                                  ;;
                _IENavigate ($Obj, 'about:blank')                                                                                                             ;;
                $sHTML = "<HTML><BODY><CENTER><BR><BR><BR><h1 style='font-family : ARIAL; font-size : 24px; font-weight" _                                    ;;
                & ":bold; color: #000377'>De server is tijdelijk niet bereikbaar. </h1><BR><BR><h2 style='font-family : ARIAL;" _             ;;
                & "font-size : 20px; font-weight :bold; color: #000377'>De verbinding wordt automatisch hersteld ...</h2>"                    ;;
                _IEBodyWriteHTML ($Obj, $sHTML)                                                                                                               ;;
            EndIf                                                                                                                                                 ;;
            ;;
            ;;
        EndIf                                                                                                                                                         ;;
        sleep($pingival*1000)                                                                                                                                         ;;
    Wend                                                                                                                                                                  ;;
EndFunc                                                                                                                                                                       ;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


#comments-start
    Index :
    
    OnAutoItStart() - constains code that runs ALWAYS and FIRST on start. Also handles commandline paramters
    _Settings()     - This functions contains the GUI and code for the Settings window.
    _AdminTools     - contains GUI and code for Admin Tools window
    _CopyLink()     - contains GUI and code for Shortcut Copy window
    _SelectLok()    - contains GUI and code for Vestiging Select window
    _terminate()    - contains Exit function
    _Install()      - contains Program Installation code
    _Update()       - contains Program Update code
    _restart        - constins code to make program restart itself.
    _UpdateStart    - contains code to start update process (for menu and commandline)
    _Help           - contains code wich displays little help Msgbox
    _TestActive     - contains code wich checks if program, when compiled, is already active. If so then exit.
    
#comments-end


;##################################################################################################################################################################



Func OnAutoItStart()
    Opt("GUIOnEventMode", 0)
    If $CmdLine[0]>"0" Then
        If $CmdLineRaw <> "" Then
            ;;
            Select
                Case $CmdLineRaw = "/INSTALL"
                    _Install()
                    if @error = 0 then terminate()
                    exit
                Case $CmdLineRaw = "/UPDATE"
                    _Update()
                    if @error = 0 then _restart()
                    exit
                Case $CmdLineRaw = "/REMOTEUPDATE"
                    _UpdateStart()
                    if @error = 0 then _restart()
                    exit
                Case Else
                    MsgBox(16, "Fout : de parameter is incorrect !", "Gebruik : " & @ScriptName & " [/INSTALL] of [/UPDATE] of [/REMOTEUPDATE]" & @CRLF _
                            & "/INSTALL - Installeer programma" & @CRLF _
                            & "/UPDATE  - Voer Update procedure uit" & @CRLF _
                            & "/REMOTEUPDATE - Download laatse versie van server en update")

                    Exit
            EndSelect
        Endif
    Endif
EndFunc

;##################################################################################################################################################################

Func _Settings()

    Local $restart = 0
    ;Local $SettingsForm
    ;Local $checkini
    Opt("GUIOnEventMode", 0)
    ;Local $SettingsForm

    ;# Define GUI

    #Region ### START Koda GUI section ### Form=c:\program files\autoit3\au3tokoda\out_form.kxf
    $SettingsForm = GUICreate("Settings", 615, 451, 198, 138,BitOR($WS_SYSMENU,$WS_DLGFRAME))
    $Group2 = GUICtrlCreateGroup("", 8, 376, 601, 49)
    $OKButton1 = GUICtrlCreateButton("OK", 442, 392, 73, 25, 0)
    $CancelButton1 = GUICtrlCreateButton("Cancel", 522, 392, 73, 25, 0)
    $InstallButton1 = GUICtrlCreateButton("Installeren", 20, 392, 73, 25, 0)
    $DeinstallButton1 = GUICtrlCreateButton("Deinstalleren", 100, 392, 73, 25, 0)
    $AdminButton1 = GUICtrlCreateButton("Admin Tools", 264, 392, 73, 25, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group1 = GUICtrlCreateGroup("Instellingen", 8, 7, 601, 369)
    $Group3 = GUICtrlCreateGroup("INI bestand instellingen", 24, 176, 570, 57)
    $Useini1 = GUICtrlCreateCheckbox("Gebruik INI", 40, 199, 97, 17)
    GUICtrlCreateLabel("Voer de lokatie in :", 175, 199, 92, 17)
    $iniopgeslagen = GUICtrlCreateLabel("INI opgeslagen", 490, 199, 76, 17)
    $lokatie_input1 = GUICtrlCreateInput("Voer de lokatie in", 270, 196, 121, 21)
    $save_ini_button1 = GUICtrlCreateButton("Bewaar INI", 408, 195, 75, 25, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Pingslider1 = GUICtrlCreateSlider(100, 39, 473, 41, BitOR($TBS_AUTOTICKS,$TBS_BOTH,$TBS_NOTICKS))
    GUICtrlSetLimit(-1, 5000, 200)
    GUICtrlSetData(-1, 200)
    $PingValue1 = GUICtrlCreateInput("PingValue", 40, 42, 41, 21)
    GUICtrlCreateLabel("Toegestane ping latency", 120, 16, 121, 17)
    GUICtrlCreateLabel("200", 100, 80, 22, 17)
    GUICtrlCreateLabel("5000", 546, 80, 28, 17)
    $PingSlider2 = GUICtrlCreateSlider(100, 119, 473, 41, BitOR($TBS_AUTOTICKS,$TBS_BOTH,$TBS_NOTICKS))
    GUICtrlSetLimit(-1, 60, 2)
    GUICtrlSetData(-1, 2)
    GUICtrlCreateLabel("2", 110, 160, 10, 17)
    GUICtrlCreateLabel("60", 556, 160, 16, 17)
    $PingValue2 = GUICtrlCreateInput("PingValue2", 40, 122, 41, 21)
    GUICtrlCreateLabel("Ping Interval", 120, 96, 63, 17)
    $AutorunGroup1 = GUICtrlCreateGroup("Autorun Instellingen", 24, 240, 569, 57)
    $autorun1 = GUICtrlCreateCheckbox("AutoRun", 40, 262, 97, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $KieskGroup1 = GUICtrlCreateGroup("Kiosk Instellingen", 24, 305, 569, 57)
    $Kioskmode = GUICtrlCreateCheckbox("Aktiveer kiosk mode", 40, 329, 121, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    $enablelabel = GUICtrlCreateLabel("Autorun geaktiveerd, klik op OK om te bewaren", 175, 263, 228, 17)
    $disablelabel = GUICtrlCreateLabel("Autorun gedeaktiveerd, klik op OK om te bewaren", 175, 263, 240, 17)
    GUICtrlSetState($iniopgeslagen, $GUI_HIDE )
    GUICtrlSetState($enablelabel, $GUI_HIDE )
    GUICtrlSetState($disablelabel, $GUI_HIDE )
    GUICtrlSetState($PingValue1, $GUI_DISABLE)
    GUICtrlSetState($PingValue2, $GUI_DISABLE)

    #EndRegion ### END Koda GUI section ###

    ;# Set GUI according to install
    If $regreadinstall = -1 Then
        GUICtrlSetState($Pingslider1, $GUI_DISABLE)
        GUICtrlSetState($Pingslider2, $GUI_DISABLE)
        GUICtrlSetState($autorun1, $GUI_DISABLE)
        GUICtrlSetState($Useini1, $GUI_DISABLE)
        GUICtrlSetState($lokatie_input1, $GUI_DISABLE)
        GUICtrlSetState($save_ini_button1, $GUI_DISABLE)
        GUICtrlSetState($autorun1, $GUI_DISABLE)
        GUICtrlSetState($Kioskmode, $GUI_DISABLE)
        GUICtrlSetState($DeinstallButton1, $GUI_DISABLE)
    Else
        GUICtrlSetState($InstallButton1, $GUI_DISABLE)
    EndIf


    ;# Set GUI according to registry
    If $regcheckini = 0  Then
        ;MsgBox(0,"",$regcheckini)
        GUICtrlSetState($Useini1, 0)
        GUICtrlSetState($lokatie_input1, $GUI_DISABLE)
        GUICtrlSetState($save_ini_button1, $GUI_DISABLE)
        GUICtrlSetData($lokatie_input1,IniRead($inifile,"Instellingen","Lokatie","Voer lokatie in:"))
    Else
        GUICtrlSetState($Useini1, 1)
        GUICtrlSetState($lokatie_input1, $GUI_ENABLE)
        GUICtrlSetState($save_ini_button1, $GUI_ENABLE)
        GUICtrlSetData($lokatie_input1,IniRead($inifile,"Instellingen","Lokatie","Voer lokatie in:"))
    EndIf


    GUICtrlSetData( $Pingslider1 , $regreadpingspeed )
    GUICtrlSetData( $Pingslider2 , $regreadpingival )

    If $regreadautorun = 0 Then
        GUICtrlSetState($autorun1, $GUI_UNCHECKED)
    ElseIf $regreadautorun <> 0 Then
        GUICtrlSetState($autorun1, $GUI_CHECKED)
    Endif

    If $regreadkiosk= 0 Then
        GUICtrlSetState($Kioskmode, $GUI_UNCHECKED)
    ElseIf $regreadkiosk <> 0 Then
        GUICtrlSetState($Kioskmode, $GUI_CHECKED)
    Endif

    $tmpautorun = GuiCtrlRead($autorun1)
    ;MsgBox(0,"$tmpautorun",$tmpautorun)
    ;@ Enter Loop
    GUISetState(@SW_SHOW)

    While 1
        $settingsmsg = GuiGetMsg()
        $checkini = GUICtrlRead($Useini1)
        If $checkini = 1 Then
            $checkini = 1
        Else
            $checkini = 0
        Endif

        GUICtrlSetData($PingValue1,GUICtrlRead($Pingslider1))
        GUICtrlSetData($PingValue2,GUICtrlRead($Pingslider2))

        Select
            Case $settingsmsg = $GUI_EVENT_CLOSE
                GUISetState(@SW_HIDE, "Settings")
                return 3
                ExitLoop

            Case $settingsmsg = $CancelButton1
                GUISetState(@SW_HIDE,$SettingsForm)
                return 3
                ExitLoop

            Case $settingsmsg = $AdminButton1
                if $regreadinstall = -1 Then
                    MsgBox(16,"Fout","Het programma is nog niet geinstalleerd",5 )
                    Return 1
                Else
                    ; == GUI generated with Koda ==

                    $AdminForm = GUICreate("Admin Tools", 242, 272, 192, 125,BitOR($WS_SYSMENU,$WS_DLGFRAME),"",$SettingsForm)
                    $Restart = GUICtrlCreateRadio("Herstart programma", 24, 120, 169, 17)
                    $Logoff = GUICtrlCreateRadio("Logoff", 24, 24, 169, 17)
                    $Shutdown = GUICtrlCreateRadio("Shutdown en Restart", 24, 56, 169, 17)
                    $Shortcut = GUICtrlCreateRadio("Snelkoppeling naar ander account", 24, 88, 185, 17)
                    $Update = GUICtrlCreateRadio("Installeer Update", 24, 152, 169, 17)
                    $OKButtonA = GUICtrlCreateButton("OK", 16, 216, 81, 25, 0)
                    $CancellButtonA = GUICtrlCreateButton("Cancel", 120, 216, 81, 25, 0)
                    GUISetState(@SW_SHOW,$AdminForm)

                    While 1
                        $Adminmsg = GuiGetMsg()
                        Select
                            Case $Adminmsg = $GUI_EVENT_CLOSE
                                GUISetState(@SW_HIDE,$AdminForm)
                                ExitLoop
                            Case $Adminmsg = $CancellButtonA
                                GUISetState(@SW_HIDE,$AdminForm)
                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Restart), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                If Not IsDeclared("MsgBoxRestart") Then Dim $MsgBoxRestart
                                $MsgBoxRestart = MsgBox(64,"Herstart programma","Het programma wordt herstart.",2)
                                Select
                                    Case $MsgBoxRestart = -1 ;Timeout

                                    Case Else                ;OK

                                EndSelect
                                #EndRegion --- CodeWizard generated code End ---

                                _restart()
                                ExitLoop
                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Logoff), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                If Not IsDeclared("MsgBoxLogoff") Then Dim $MsgBoxLogoff
                                $MsgBoxLogoff = MsgBox(308,"Logoff !","Weet U zeker dat U zich wilt afmelden ?")
                                Select
                                    Case $MsgBoxLogoff = 6 ;Yes
                                        Shutdown(0)
                                        ExitLoop
                                    Case $MsgBoxLogoff = 7 ;No
                                        ExitLoop
                                EndSelect
                                #EndRegion --- CodeWizard generated code End ---

                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Shutdown), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                If Not IsDeclared("MsgBoxShutdown") Then Dim $MsgBoxShutdown
                                $MsgBoxShutdown = MsgBox(308,"Shutdown en Restart !","Weet U zeker dat U de computer opnieuw wilt starten ?")
                                Select
                                    Case $MsgBoxShutdown = 6 ;Yes
                                        Shutdown(6)
                                        ExitLoop
                                    Case $MsgBoxShutdown = 7 ;No
                                        ExitLoop
                                EndSelect


                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Shortcut), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                if $regreadinstall = -1 Then
                                    MsgBox(16,"Fout","Het programma is nog niet geinstalleerd",5 )
                                    Return 1
                                Else
                                    if IsAdmin() Then
                                        $Documents =  StringSplit( @MyDocumentsDir ,"\")
                                        $programs =  StringSplit( @ProgramsDir ,"\")
                                        $search = $Documents[1] & "\" & $Documents[2] & "\*.*"
                                        dim $destination
                                        ; == GUI generated with Koda ==
                                        $CopyForm = GUICreate("Copy Shortcut", 360, 325, 292, 225,BitOR($WS_SYSMENU,$WS_DLGFRAME),"",$AdminForm)
                                        $DirCombo = GUICtrlCreateCombo("", 24, 24, 305, 200,$CBS_DROPDOWNLIST)
                                        $LinkCopyLabel = GUICtrlCreateLabel( "Label",24,208,312,37)
                                        $OKButton = GUICtrlCreateButton("Copy Shortcut", 24, 268, 137, 25, 0)
                                        $CancelButton = GUICtrlCreateButton("Cancel", 200, 268, 137, 25, 0)
                                        GUICtrlSetState($OKButton,$GUI_DISABLE)
                                        $allocated = _GUICtrlComboInitStorage ($DirCombo, 26, 50)
                                        _GUICtrlComboResetContent ($DirCombo)

                                        $ret = _GUICtrlComboAddDir ($DirCombo, "D,NB" , $search)
                                        If ($ret < 0) Then
                                            If ($ret == $CB_ERRATTRIBUTE) Then
                                                MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlComboAddDir")
                                            ElseIf ($ret == $CB_ERRSPACE) Then
                                                MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlComboAddDir")
                                            ElseIf ($ret == $CB_ERRREQUIRED) Then
                                                MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlComboAddDir")
                                            ElseIf ($ret == $CB_ERR) Then
                                                MsgBox(16, "Error", "Unknown error from _GUICtrlComboAddDir" & @CRLF & "Possibly no files/folders found")
                                            EndIf
                                        EndIf

                                        GUISetState(@SW_SHOW)
                                        While 1
                                            $destination = StringReplace(StringReplace(GUICtrlRead( $DirCombo),"[",""),"]","")
                                            $copypath = $Documents[1] & "\" & $Documents[2] & "\" & $destination  & "\" & $programs[4] & "\" & $programs[5]
                                            If $destination = "" Or $destination = ".." Or StringInStr($Destination,"administrator") Or StringInStr($Destination,"heruxa") Or StringInStr($Destination,"All Users") Or StringInStr($Destination,"Default User") Then
                                                $copypath = "Geen geldige bestemming gekozen"
                                                GUICtrlSetState($OKButton,$GUI_DISABLE)
                                            Else
                                                If FileExists($copypath) Then

                                                    $copypath = $Documents[1] & "\" & $Documents[2] & "\" & $destination  & "\" & $programs[4] & "\" & $programs[5]
                                                    GUICtrlSetState($OKButton,$GUI_ENABLE)
                                                EndIf
                                            Endif

                                            GUICtrlSetData($LinkCopyLabel,$copypath)
                                            $msg = GuiGetMsg()
                                            Select
                                                Case $msg = $GUI_EVENT_CLOSE
                                                    GUISetState(@SW_HIDE)
                                                    ;ExitLoop
                                                Case $msg = $CancelButton
                                                    GUISetState(@SW_HIDE)
                                                    ;ExitLoop
                                                Case $msg = $OKButton

                                                    FileCreateShortcut(@ScriptFullPath, $copypath & "\Zuilen Emulator.lnk" , @ScriptDir )
                                                    ;Then
                                                    MsgBox(64,"Shortcut","Shortcut is aangemaakt op :" & @CRLF & $copypath ,2)
                                                    ;Endif
                                                    GUISetState(@SW_HIDE)
                                                    return
                                                    ExitLoop
                                                    ;Case Else

                                                    ;ExitLoop
                                                    ;;;;;;;
                                            EndSelect
                                            sleep (50)
                                        WEnd

                                    Else
                                        MsgBox(16,"Fout","U heeft administrator rechten nodig voor deze funktie.")
                                        return 1
                                    EndIf

                                    Return
                                Endif

                                ExitLoop

                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Update), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                _UpdateStart()
                                ExitLoop

                        EndSelect
                    WEnd
                    Return



                Endif

                GUISetState(@SW_SHOW,$SettingsForm)
                ExitLoop

            Case $settingsmsg = $OKButton1

                if $regreadpingspeed <> GUICtrlRead($Pingslider1) Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed","REG_SZ",GUICtrlRead($Pingslider1))
                    $restart = 1
                EndIf

                if $regreadpingival <> GUICtrlRead($Pingslider2) Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingInterval","REG_SZ",GUICtrlRead($Pingslider2))
                    $restart = 1

                EndIf
                If $checkini <> $regcheckini Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ",$checkini)
                    $restart = 1
                else
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ",$checkini)
                EndIf


                If GUICtrlRead($autorun1) = 1 Then
                    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Zuilen","REG_SZ", $regreadinstall & "\" & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Zuilen","ProgramName"))
                    ; Key created
                Else
                    RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Zuilen")
                    ; Key deleted
                Endif

                ;$restart = 1
                If GUICtrlRead($Kioskmode) = 1 Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","Kioskmode","REG_SZ","1")
                Else
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","Kioskmode","REG_SZ","0")
                Endif

                GUISetState(@SW_HIDE,$SettingsForm)
                ExitLoop

            Case $settingsmsg = $InstallButton1

                _Install()
                if @error = 0 then terminate()
                GUISetState(@SW_HIDE,$SettingsForm)
                ExitLoop
            Case $settingsmsg = $DeinstallButton1

                Run ( $regreadinstall & "\uninstall.exe")

                $restart = 0
                GUISetState(@SW_HIDE,$SettingsForm)
                ExitLoop

            Case $settingsmsg = $Kioskmode
                $restart = 1
                ContinueLoop
            Case $settingsmsg = $autorun1

                If GUICtrlRead($autorun1) = 1 Then
                    GUICtrlSetState($disablelabel, $GUI_HIDE )
                    GUICtrlSetState($enablelabel, $GUI_SHOW )
                Else
                    GUICtrlSetState($enablelabel, $GUI_HIDE )
                    GUICtrlSetState($disablelabel, $GUI_SHOW )
                    ContinueLoop
                Endif


            Case $settingsmsg = $save_ini_button1

                If $lokatie_input1 <> IniRead($inifile,"Instellingen","Lokatie","Rayon") Then
                    IniWrite($inifile,"Instellingen","Lokatie",GUICtrlRead( $lokatie_input1))
                    GUICtrlSetState($iniopgeslagen, $GUI_SHOW )
                    $restart = 1
                EndIf

                ContinueLoop


            Case $settingsmsg = $Useini1
                if GUICtrlRead($Useini1) = 1 Then
                    GUICtrlSetState($lokatie_input1, $GUI_ENABLE)
                    GUICtrlSetState($save_ini_button1, $GUI_ENABLE)
                Else
                    GUICtrlSetState($lokatie_input1, $GUI_DISABLE)
                    GUICtrlSetState($save_ini_button1, $GUI_DISABLE)
                Endif

                ContinueLoop
            Case Else
                ;;;;;;;
        EndSelect



    WEnd

    if $restart = 1 Then _restart()
    exit




EndFunc

;##################################################################################################################################################################



;##################################################################################################################################################################

Func _SelectLok()
    Opt("GUIOnEventMode", 0)

    $Form2 = GUICreate("Selecteer vestiging", 240, 160, @DesktopWidth / 2 - 120, @DesktopHeight / 2 - 260)
    $City_Combo = GUICtrlCreateCombo("", 24, 48, 177, 21, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "Eindhoven|Nijmegen|Heerlen|Maastricht|Roermond|Venlo|Sittard|Helmond","Eindhoven")
    GUICtrlCreateLabel("Welke vestiging wilt u emuleren ?", 24, 24, 162, 17)
    $Group1 = GUICtrlCreateGroup("Maak uw keuze:", 8, 8, 224, 140)


    $OKButton = GUICtrlCreateButton("&OK",14, 100, 210, 33 )
    GUICtrlSetState(-1,$GUI_FOCUS)
    GUISetState(@SW_SHOW)



    while 1
        $msg1 = GuiGetMsg()
        Select
            Case $msg1 = $GUI_EVENT_CLOSE
                GUISetState(@SW_HIDE)
                GUISetState(@SW_SHOW,$AdminForm)
                terminate()
                Exitloop
            Case $msg1 = $OKButton
                GUISetState(@SW_HIDE)
                $selection = GUICtrlRead( $city_Combo )
                Return $selection

            Case Else
                ;;;;;
        EndSelect
    Wend

EndFunc


;##################################################################################################################################################################

Func terminate()
    Opt("GUIOnEventMode", 0)
    ConsoleWrite('@@ (107) :(' & @MIN & ':' & @SEC & ') terminate()' & @CR) ;### Trace Function
    exit 3
EndFunc

;##################################################################################################################################################################

Func _Install()
    Opt("GUIOnEventMode", 0)
    If IsAdmin() Then
        $PathToInstall = FileSelectFolder("Selecteer een directory" & @CRLF & "Let op ! er word een automatisch een subdirectory ""zuilen"" aangemaakt !", @HomeDrive ,3 , @ProgramFilesDir)
        If @error = 1 then
            msgbox(16,"Afgebroken", "De installatie is afgebroken")
            return 1
        Endif
        $PathToInstall = $PathToInstall & "\Zuilen"
        ProgressOn("Installatie voortgang", "Installatie van Zuilen Emulator" , "0 procent")
        sleep(2100)
        ProgressSet( 5, 5 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\Software\Zuilen","Installpath","REG_SZ", $PathToInstall)
        ProgressSet( 10, 10 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\Software\Zuilen","ProgramName","REG_SZ", @ScriptName)
        ProgressSet( 15, 15 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "DisplayIcon", "REG_SZ", $PathToInstall & "\" & @ScriptName )
        ProgressSet( 20, 20 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "DisplayIconEx", "REG_SZ", $PathToInstall & "\" & @ScriptName )
        ProgressSet( 25, 25 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "DisplayName", "REG_SZ", "Zuilen Emulator")
        ProgressSet( 30, 30 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "EstimatedSizeEx", "REG_DWORD", "00000259")
        ProgressSet( 35, 35 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "InstallLocationEx", "REG_SZ", $PathToInstall)
        ProgressSet( 40, 40 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "NoModify", "REG_DWORD", "00000001")
        ProgressSet( 45, 45 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "NoRepair", "REG_DWORD", "00000001")
        ProgressSet( 50, 50 & " procent")
        sleep(50)
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "UninstallString", "REG_SZ", """" &  $PathToInstall & "\uninstall.exe" & """" )
        ProgressSet( 55, 55 & " procent")
        sleep(50)
        RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed","REG_SZ", "250")
        RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingInterval","REG_SZ", "2")
        ProgressSet( 60, 60 & " procent")
        sleep(50)
        RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ", "0")
        ProgressSet( 65, 65 & " procent")
        sleep(50)

        DirCreate ( $PathToInstall )
        ProgressSet( 70, 70 & " procent")
        sleep(250)
        FileInstall ("C:\Program Files\AutoIt3\Projects\newzuilen\zuilen_banner.jpg" , $PathToInstall & "\", 1 )
        ProgressSet( 75, 75 & " procent")
        sleep(150)
        FileInstall ("C:\Program Files\AutoIt3\Projects\newzuilen\uninstall.exe" , $PathToInstall & "\",1)
        ProgressSet( 80, 80 & " procent")
        sleep(150)
        FileCopy( @ScriptFullPath , $PathToInstall , 1 )
        ProgressSet( 85, 85 & " procent")
        sleep(50)
        DirCreate ( @ProgramsCommonDir & "\Zuilen")
        ProgressSet( 90, 90 & " procent")
        sleep(50)
        FileCreateShortcut( $PathToInstall & "\" & @ScriptName, @ProgramsCommonDir & "\Zuilen\Zuilen Emulator.lnk" , $PathToInstall)
        FileCreateShortcut( $PathToInstall & "\" & "\uninstall.exe", @ProgramsCommonDir & "\Zuilen\Uninstall Zuilen Emulator.lnk" , $PathToInstall)
        FileCreateShortcut( $PathToInstall & "\" & @ScriptName, @ProgramsCommonDir & "\Zuilen\Update Zuilen Emulator.lnk" , $PathToInstall,"/REMOTEUPDATE", "Update Zuilen Emulator", @SystemDir & "\shell32.dll", "", "135")

        ProgressSet(100 , "Klaar", "Compleet")
        sleep(1500)
        ProgressOff()

        MsgBox(64,"Geinstalleerd","De Update is voltooid. Start het programma via Menu Start ->Programma's" & @CRLF & "Binnen het programma kunt U de volgende ""hotkeys"" gebruiken :" & @CRLF & @CRLF & "F1   = Help" & @CRLF & "Alt - F4  = Exit" & @CRLF & "Alt - F12  = Admin Tools" & @CRLF & "Alt - S  = Instellingen." & @CRLF & "Alt - O  = Over " &  @ScriptName)
        return 0
        Exit
    Else
        MsgBox(16,"Fout !","Om het programma te kunnen installeren zijn administrator rechten vereist !")
    EndIf

EndFunc

;##################################################################################################################################################################

Func _Update()
    Opt("GUIOnEventMode", 0)
    $regreadinstall = RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","InstallPath")
    If $regreadinstall = "" Then $regreadinstall = -1
    If $regreadinstall = -1 Then
        MsgBox(16,"Fout","Kan het programma niet updaten want het is niet geinstalleerd !")
        Exit
        terminate()
    Else

        If IsAdmin() Then
            $PathToUpdate = RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","InstallPath")
            If @error = 1 then
                msgbox(16,"Afgebroken", "De installatie is afgebroken")
                return 1
            Endif
            ProgressOn("Update voortgang", "Update van Zuilen Emulator" , "0 procent")
            sleep(1000)
            ProgressSet( 5, 5 & " procent")
            sleep(50)
            ProgressSet( 10, 10 & " procent")
            sleep(50)
            ProgressSet( 15, 15 & " procent")
            sleep(50)
            ProgressSet( 20, 20 & " procent")
            sleep(50)
            ProgressSet( 25, 25 & " procent")
            sleep(50)
            ProgressSet( 30, 30 & " procent")
            sleep(50)
            ProgressSet( 35, 35 & " procent")
            sleep(50)
            ProgressSet( 40, 40 & " procent")
            sleep(50)
            ProgressSet( 45, 45 & " procent")
            sleep(50)

            ProgressSet( 50, 50 & " procent")
            sleep(50)
            ProgressSet( 55, 55 & " procent")
            sleep(50)
            ProgressSet( 60, 60 & " procent")
            sleep(50)
            ProgressSet( 65, 65 & " procent")
            sleep(50)
            ProgressSet( 70, 70 & " procent")
            sleep(50)
            FileInstall ("C:\Program Files\AutoIt3\Projects\newzuilen\zuilen_banner.jpg" , $PathToUpdate & "\", 1 )
            ProgressSet( 75, 75 & " procent")
            sleep(50)
            FileInstall ("C:\Program Files\AutoIt3\Projects\newzuilen\uninstall.exe" , $PathToUpdate & "\",1)
            ProgressSet( 80, 80 & " procent")
            sleep(50)
            FileCopy( @ScriptFullPath , $PathToUpdate , 1 )
            ProgressSet( 85, 85 & " procent")
            sleep(50)
            DirCreate ( @ProgramsCommonDir & "\Zuilen")
            ProgressSet( 90, 90 & " procent")
            sleep(50)
            FileCreateShortcut( $PathToUpdate & "\" & @ScriptName, @ProgramsCommonDir & "\Zuilen\Zuilen Emulator.lnk" , $PathToUpdate)
            FileCreateShortcut( $PathToUpdate & "\" & "\uninstall.exe", @ProgramsCommonDir & "\Zuilen\Uninstall Zuilen Emulator.lnk" , $PathToUpdate)
            FileCreateShortcut( $PathToUpdate & "\" & @ScriptName, @ProgramsCommonDir & "\Zuilen\Update Zuilen Emulator.lnk" , $PathToUpdate,"/REMOTEUPDATE", "Update Zuilen Emulator", @SystemDir & "\shell32.dll", "", "135")

            ProgressSet(100 , "Klaar", "Compleet")
            sleep(1500)
            ProgressOff()

            MsgBox(64,"Geinstalleerd","De Update is voltooid. Start het programma via Menu Start ->Programma's" & @CRLF & "Binnen het programma kunt U de volgende ""hotkeys"" gebruiken :" & @CRLF & @CRLF & "F1   = Help" & @CRLF & "Alt - F4  = Exit" & @CRLF & "Alt - F12  = Admin Tools" & @CRLF & "Alt - S  = Instellingen." & @CRLF & "Alt - O  = Over " &  @ScriptName,30)
            Run( $PathToUpdate & "\" & @ScriptName )
            Exit
        Else
            MsgBox(16,"Fout !","Om het programma te kunnen installeren zijn administrator rechten vereist !")
            Exit
            terminate()
        EndIf


    EndIf
EndFunc

;##################################################################################################################################################################

Func _ReadIni()
    Opt("GUIOnEventMode", 0)
    If NOT RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","Installpath") = "" Then
        return $regcheckini

    Else

        If Not IsDeclared("installanswer") Then Dim $installanswer
        $installanswer = MsgBox(36,"Installatie","Het programma is nog niet geinstalleerd. Wilt U dit nu doen ?")
        Select
            Case $installanswer = 6 ;Yes
                _install()
                if @error = 0 then terminate()
                Exit
            Case $installanswer = 7 ;No
                ;
        EndSelect
        return 0
    EndIf

EndFunc


;##################################################################################################################################################################

Func _restart()
    Opt("GUIOnEventMode", 0)
    ; Restart your program
    ; Author UP_NORTH
    If @Compiled = 1 Then
        Run( FileGetShortName(@ScriptFullPath))
    Else
        Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
Endfunc

;##################################################################################################################################################################

Func _UpdateStart()
    Opt("GUIOnEventMode", 0)
    ; Restart your program and update
    ; Author UP_NORTH, adapted for Update Process by Ruud_Sas
    If IsAdmin() Then

        If @Compiled = 1 Then
            Run("\\callisto\images\zuilen\zuilen.exe /update" )
            Exit
        Endif
    Else
        MsgBox(16,"Fout !","Om het programma te kunnen updaten zijn administrator rechten vereist !")
    EndIf

Endfunc

;##################################################################################################################################################################

Func _Help()
    Opt("GUIOnEventMode", 0)
    MsgBox(32,"Help",@CRLF & "F1    =   Help (Dit venster)" & @CRLF & @CRLF & "Alt-S =   Instellingen" & @CRLF & @CRLF & "Alt-F4 = Afsluiten" & @CRLF & "Alt-F12 = Admin Tools" & @CRLF & "Alt - O  = Over " & @ScriptName &  @CRLF & "Alt - R  = Restart " ,10)
EndFunc

;##################################################################################################################################################################

Func _TestActive()
    Opt("GUIOnEventMode", 0)
    Sleep( 1000)
    $list = ProcessList( @scriptname )
    If $list[0][0] >= 2 Then
        MsgBox(16, "Fout", "Het programma is al actief !",5)
        Exit
    EndIf
EndFunc

;##################################################################################################################################################################

Func _CallSettings()
    $returncode = @error
    
    While $returncode <> 3
        _Settings()
        MsgBox(0,"" ,$returncode)
    Wend
EndFunc
;##################################################################################################################################################################

Thank you for looking !!

Edited by Ruud_Sas
Link to comment
Share on other sites

Two things in function _Settings():

1- You are returning this function when the user closes the settings GUI

GUISetState(@SW_SHOW,$AdminForm)
                                _UpdateStart()
                                ExitLoop

                        EndSelect
                    WEnd
 ;Return <---- Right here!!!! this is not very good.
                Endif

                GUISetState(@SW_SHOW,$SettingsForm)
                ExitLoop

And when you do that you don't listen for messages anymore and this why the page don't respond after that.

2- In the case of more than two GUIs I recommend that you use GUIgetMsg(1) instead GUIgetmsg();

RK

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Ah,

the 'return' there was indeed not smart. However, this does not change the working of the GUI's in my case so that has probably to do with the 2nd thing you suggested. I changed the GuiGetMsg() 's from the _Settings() fuction to GuiGetMsg(1) but this does not work either.

I'm sure I misunderstand your point so can you elaborate a little more. (It's only my 4th week since I discovered AutoIt so please be patient )

thanks sofar :)

Link to comment
Share on other sites

You need to rewrite your GUI functions

1- seperate the actions from the GUI functions by using other functions like:

func _shutDown()
        Shutdown(0)
Endfunc
oÝ÷ Ûf(ºwvÚ%Ë^ÚP¯z{l~º&¶«mÂ)Ý£ZÙ^ªê-m¦zfÞ¯}â*.'^heè zÙ¥ËbYb²×§¶­Ê°Yaj÷­¡×¥z×¢¶ì¢g­)àý»aȬʫ±ëmx,~éܶ*'"·©§teIëRµ«^Id9m7èfqh®l"7¥z×´ß )Å¢¹j[(ºÇè zÙ¬X§¶vö§yÙ¨uç!yÉ"¶­jwk{
âµì¨º»®*mjëh×6

Func _Settings()

    Local $restart = 0
    ;Local $SettingsForm
    ;Local $checkini
    Opt("GUIOnEventMode", 0)
    ;Local $SettingsForm

    ;# Define GUI
    $SettingsForm = GUICreate("Settings", 615, 451, 198, 138,BitOR($WS_SYSMENU,$WS_DLGFRAME))
    $Group2 = GUICtrlCreateGroup("", 8, 376, 601, 49)
    $OKButton1 = GUICtrlCreateButton("OK", 442, 392, 73, 25, 0)
    $CancelButton1 = GUICtrlCreateButton("Cancel", 522, 392, 73, 25, 0)
    $InstallButton1 = GUICtrlCreateButton("Installeren", 20, 392, 73, 25, 0)
    $DeinstallButton1 = GUICtrlCreateButton("Deinstalleren", 100, 392, 73, 25, 0)
    $AdminButton1 = GUICtrlCreateButton("Admin Tools", 264, 392, 73, 25, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group1 = GUICtrlCreateGroup("Instellingen", 8, 7, 601, 369)
    $Group3 = GUICtrlCreateGroup("INI bestand instellingen", 24, 176, 570, 57)
    $Useini1 = GUICtrlCreateCheckbox("Gebruik INI", 40, 199, 97, 17)
    GUICtrlCreateLabel("Voer de lokatie in :", 175, 199, 92, 17)
    $iniopgeslagen = GUICtrlCreateLabel("INI opgeslagen", 490, 199, 76, 17)
    $lokatie_input1 = GUICtrlCreateInput("Voer de lokatie in", 270, 196, 121, 21)
    $save_ini_button1 = GUICtrlCreateButton("Bewaar INI", 408, 195, 75, 25, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Pingslider1 = GUICtrlCreateSlider(100, 39, 473, 41, BitOR($TBS_AUTOTICKS,$TBS_BOTH,$TBS_NOTICKS))
    GUICtrlSetLimit(-1, 5000, 200)
    GUICtrlSetData(-1, 200)
    $PingValue1 = GUICtrlCreateInput("PingValue", 40, 42, 41, 21)
    GUICtrlCreateLabel("Toegestane ping latency", 120, 16, 121, 17)
    GUICtrlCreateLabel("200", 100, 80, 22, 17)
    GUICtrlCreateLabel("5000", 546, 80, 28, 17)
    $PingSlider2 = GUICtrlCreateSlider(100, 119, 473, 41, BitOR($TBS_AUTOTICKS,$TBS_BOTH,$TBS_NOTICKS))
    GUICtrlSetLimit(-1, 60, 2)
    GUICtrlSetData(-1, 2)
    GUICtrlCreateLabel("2", 110, 160, 10, 17)
    GUICtrlCreateLabel("60", 556, 160, 16, 17)
    $PingValue2 = GUICtrlCreateInput("PingValue2", 40, 122, 41, 21)
    GUICtrlCreateLabel("Ping Interval", 120, 96, 63, 17)
    $AutorunGroup1 = GUICtrlCreateGroup("Autorun Instellingen", 24, 240, 569, 57)
    $autorun1 = GUICtrlCreateCheckbox("AutoRun", 40, 262, 97, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $KieskGroup1 = GUICtrlCreateGroup("Kiosk Instellingen", 24, 305, 569, 57)
    $Kioskmode = GUICtrlCreateCheckbox("Aktiveer kiosk mode", 40, 329, 121, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    $enablelabel = GUICtrlCreateLabel("Autorun geaktiveerd, klik op OK om te bewaren", 175, 263, 228, 17)
    $disablelabel = GUICtrlCreateLabel("Autorun gedeaktiveerd, klik op OK om te bewaren", 175, 263, 240, 17)
    GUICtrlSetState($iniopgeslagen, $GUI_HIDE )
    GUICtrlSetState($enablelabel, $GUI_HIDE )
    GUICtrlSetState($disablelabel, $GUI_HIDE )
    GUICtrlSetState($PingValue1, $GUI_DISABLE)
    GUICtrlSetState($PingValue2, $GUI_DISABLE)

    ;# Set GUI according to install
    If $regreadinstall = -1 Then
        GUICtrlSetState($Pingslider1, $GUI_DISABLE)
        GUICtrlSetState($Pingslider2, $GUI_DISABLE)
        GUICtrlSetState($autorun1, $GUI_DISABLE)
        GUICtrlSetState($Useini1, $GUI_DISABLE)
        GUICtrlSetState($lokatie_input1, $GUI_DISABLE)
        GUICtrlSetState($save_ini_button1, $GUI_DISABLE)
        GUICtrlSetState($autorun1, $GUI_DISABLE)
        GUICtrlSetState($Kioskmode, $GUI_DISABLE)
        GUICtrlSetState($DeinstallButton1, $GUI_DISABLE)
    Else
        GUICtrlSetState($InstallButton1, $GUI_DISABLE)
    EndIf


    ;# Set GUI according to registry
    If $regcheckini = 0  Then
        ;MsgBox(0,"",$regcheckini)
        GUICtrlSetState($Useini1, 0)
        GUICtrlSetState($lokatie_input1, $GUI_DISABLE)
        GUICtrlSetState($save_ini_button1, $GUI_DISABLE)
        GUICtrlSetData($lokatie_input1,IniRead($inifile,"Instellingen","Lokatie","Voer lokatie in:"))
    Else
        GUICtrlSetState($Useini1, 1)
        GUICtrlSetState($lokatie_input1, $GUI_ENABLE)
        GUICtrlSetState($save_ini_button1, $GUI_ENABLE)
        GUICtrlSetData($lokatie_input1,IniRead($inifile,"Instellingen","Lokatie","Voer lokatie in:"))
    EndIf


    GUICtrlSetData( $Pingslider1 , $regreadpingspeed )
    GUICtrlSetData( $Pingslider2 , $regreadpingival )

    If $regreadautorun = 0 Then
        GUICtrlSetState($autorun1, $GUI_UNCHECKED)
    ElseIf $regreadautorun <> 0 Then
        GUICtrlSetState($autorun1, $GUI_CHECKED)
    Endif

    If $regreadkiosk= 0 Then
        GUICtrlSetState($Kioskmode, $GUI_UNCHECKED)
    ElseIf $regreadkiosk <> 0 Then
        GUICtrlSetState($Kioskmode, $GUI_CHECKED)
    Endif

    $tmpautorun = GuiCtrlRead($autorun1)
    ;MsgBox(0,"$tmpautorun",$tmpautorun)
    ;@ Enter Loop
    GUISetState(@SW_SHOW)

    While 1
        $settingsmsg = GuiGetMsg()
        $checkini = GUICtrlRead($Useini1)
        If $checkini = 1 Then
            $checkini = 1
        Else
            $checkini = 0
        Endif

        GUICtrlSetData($PingValue1,GUICtrlRead($Pingslider1))
        GUICtrlSetData($PingValue2,GUICtrlRead($Pingslider2))

        Select
            Case $settingsmsg = $GUI_EVENT_CLOSE
                ;GUISetState(@SW_HIDE, "Settings")
                GUIDelete( $SettingsForm )
                return 3
                ExitLoop

            Case $settingsmsg = $CancelButton1
                ;GUISetState(@SW_HIDE,$SettingsForm)
                GUIDelete( $SettingsForm )
                return 3
                ExitLoop

            Case $settingsmsg = $AdminButton1
                if $regreadinstall = -1 Then
                    MsgBox(16,"Fout","Het programma is nog niet geinstalleerd",5 )
                    Return 1
                Else
                    $AdminForm = GUICreate("Admin Tools", 242, 272, 192, 125,BitOR($WS_SYSMENU,$WS_DLGFRAME),"",$SettingsForm)
                    $Restart = GUICtrlCreateRadio("Herstart programma", 24, 120, 169, 17)
                    $Logoff = GUICtrlCreateRadio("Logoff", 24, 24, 169, 17)
                    $Shutdown = GUICtrlCreateRadio("Shutdown en Restart", 24, 56, 169, 17)
                    $Shortcut = GUICtrlCreateRadio("Snelkoppeling naar ander account", 24, 88, 185, 17)
                    $Update = GUICtrlCreateRadio("Installeer Update", 24, 152, 169, 17)
                    $OKButtonA = GUICtrlCreateButton("OK", 16, 216, 81, 25, 0)
                    $CancellButtonA = GUICtrlCreateButton("Cancel", 120, 216, 81, 25, 0)
                    GUISetState(@SW_SHOW,$AdminForm)
                    
                    While 1
                        ;#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>
                        $Adminmsg = GuiGetMsg(1);HERE IS GuiGetMsg(1)
                        ;#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>#<>
                        
                        If $Adminmsg[1] <> $AdminForm Then ; If the message wasn't gereated by $AdminForm then ignore it.
                            ContinueLoop; this will send the excution back to "While 1" read the help.
                        EndIf
                        $Adminmsg = $Adminmsg[0]
                        Select
                            Case $Adminmsg = $GUI_EVENT_CLOSE
                                ;GUISetState(@SW_HIDE,$AdminForm)
                                GUIDelete( $AdminForm )
                                ExitLoop
                            Case $Adminmsg = $CancellButtonA
                                ;GUISetState(@SW_HIDE,$AdminForm)
                                GUIDelete( $AdminForm )
                                ExitLoop
                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Restart), $GUI_CHECKED) = $GUI_CHECKED
                                ;GUISetState(@SW_SHOW,$AdminForm)
                                GUIDelete( $AdminForm )
                                If Not IsDeclared("MsgBoxRestart") Then Dim $MsgBoxRestart
                                $MsgBoxRestart = MsgBox(64,"Herstart programma","Het programma wordt herstart.",2)
                                Select
                                    Case $MsgBoxRestart = -1 ;Timeout
                                    Case Else                ;OK
                                EndSelect
                                
                                _restart()
                                ExitLoop
                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Logoff), $GUI_CHECKED) = $GUI_CHECKED
                                ;GUISetState(@SW_SHOW,$AdminForm)
                                GUIDelete( $AdminForm )
                                If Not IsDeclared("MsgBoxLogoff") Then Dim $MsgBoxLogoff
                                if MsgBox(308,"Logoff !","Weet U zeker dat U zich wilt afmelden ?") = 6 Then
                                    Shutdown(0)
                                    ExitLoop
                                Else
                                    ExitLoop
                                EndIf
                                
                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Shutdown), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                GUIDelete( $AdminForm )
                                If Not IsDeclared("MsgBoxShutdown") Then Dim $MsgBoxShutdown
                                $MsgBoxShutdown = MsgBox(308,"Shutdown en Restart !","Weet U zeker dat U de computer opnieuw wilt starten ?")
                                Select
                                    Case $MsgBoxShutdown = 6 ;Yes
                                        Shutdown(6)
                                        ExitLoop
                                    Case $MsgBoxShutdown = 7 ;No
                                        ExitLoop
                                EndSelect
                                
                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Shortcut), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                GUIDelete( $AdminForm )
                                if $regreadinstall = -1 Then
                                    MsgBox(16,"Fout","Het programma is nog niet geinstalleerd",5 )
                                    Return 1
                                Else
                                    if IsAdmin() Then
                                        $Documents =  StringSplit( @MyDocumentsDir ,"\")
                                        $programs =  StringSplit( @ProgramsDir ,"\")
                                        $search = $Documents[1] & "\" & $Documents[2] & "\*.*"
                                        dim $destination
                                        ; == GUI generated with Koda ==
                                        $CopyForm = GUICreate("Copy Shortcut", 360, 325, 292, 225,BitOR($WS_SYSMENU,$WS_DLGFRAME),"",$AdminForm)
                                        $DirCombo = GUICtrlCreateCombo("", 24, 24, 305, 200,$CBS_DROPDOWNLIST)
                                        $LinkCopyLabel = GUICtrlCreateLabel( "Label",24,208,312,37)
                                        $OKButton = GUICtrlCreateButton("Copy Shortcut", 24, 268, 137, 25, 0)
                                        $CancelButton = GUICtrlCreateButton("Cancel", 200, 268, 137, 25, 0)
                                        GUICtrlSetState($OKButton,$GUI_DISABLE)
                                        $allocated = _GUICtrlComboInitStorage ($DirCombo, 26, 50)
                                        _GUICtrlComboResetContent ($DirCombo)

                                        $ret = _GUICtrlComboAddDir ($DirCombo, "D,NB" , $search)
                                        If ($ret < 0) Then
                                            If ($ret == $CB_ERRATTRIBUTE) Then
                                                MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlComboAddDir")
                                            ElseIf ($ret == $CB_ERRSPACE) Then
                                                MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlComboAddDir")
                                            ElseIf ($ret == $CB_ERRREQUIRED) Then
                                                MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlComboAddDir")
                                            ElseIf ($ret == $CB_ERR) Then
                                                MsgBox(16, "Error", "Unknown error from _GUICtrlComboAddDir" & @CRLF & "Possibly no files/folders found")
                                            EndIf
                                        EndIf

                                        GUISetState(@SW_SHOW)
                                        While 1
                                            $destination = StringReplace(StringReplace(GUICtrlRead( $DirCombo),"[",""),"]","")
                                            $copypath = $Documents[1] & "\" & $Documents[2] & "\" & $destination  & "\" & $programs[4] & "\" & $programs[5]
                                            If $destination = "" Or $destination = ".." Or StringInStr($Destination,"administrator") Or StringInStr($Destination,"heruxa") Or StringInStr($Destination,"All Users") Or StringInStr($Destination,"Default User") Then
                                                $copypath = "Geen geldige bestemming gekozen"
                                                GUICtrlSetState($OKButton,$GUI_DISABLE)
                                            Else
                                                If FileExists($copypath) Then

                                                    $copypath = $Documents[1] & "\" & $Documents[2] & "\" & $destination  & "\" & $programs[4] & "\" & $programs[5]
                                                    GUICtrlSetState($OKButton,$GUI_ENABLE)
                                                EndIf
                                            Endif

                                            GUICtrlSetData($LinkCopyLabel,$copypath)
                                            $msg = GuiGetMsg()
                                            Select
                                                Case $msg = $GUI_EVENT_CLOSE
                                                    GUISetState(@SW_HIDE)
                                                    ;ExitLoop
                                                Case $msg = $CancelButton
                                                    GUISetState(@SW_HIDE)
                                                    ;ExitLoop
                                                Case $msg = $OKButton

                                                    FileCreateShortcut(@ScriptFullPath, $copypath & "\Zuilen Emulator.lnk" , @ScriptDir )
                                                    ;Then
                                                    MsgBox(64,"Shortcut","Shortcut is aangemaakt op :" & @CRLF & $copypath ,2)
                                                    ;Endif
                                                    GUISetState(@SW_HIDE)
                                                    return
                                                    ExitLoop
                                                    ;Case Else

                                                    ;ExitLoop
                                                    ;;;;;;;
                                            EndSelect
                                            sleep (50)
                                        WEnd

                                    Else
                                        MsgBox(16,"Fout","U heeft administrator rechten nodig voor deze funktie.")
                                        return 1
                                    EndIf
                                    Return
                                Endif

                                ExitLoop

                            Case $Adminmsg = $OKButtonA And BitAND(GUICtrlRead($Update), $GUI_CHECKED) = $GUI_CHECKED
                                GUISetState(@SW_SHOW,$AdminForm)
                                _UpdateStart()
                                ExitLoop

                        EndSelect
                    WEnd
                    ;Return



                Endif

                GUISetState(@SW_SHOW,$SettingsForm)
                ;ExitLoop

            Case $settingsmsg = $OKButton1

                if $regreadpingspeed <> GUICtrlRead($Pingslider1) Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed","REG_SZ",GUICtrlRead($Pingslider1))
                    $restart = 1
                EndIf

                if $regreadpingival <> GUICtrlRead($Pingslider2) Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingInterval","REG_SZ",GUICtrlRead($Pingslider2))
                    $restart = 1

                EndIf
                If $checkini <> $regcheckini Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ",$checkini)
                    $restart = 1
                else
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ",$checkini)
                EndIf


                If GUICtrlRead($autorun1) = 1 Then
                    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Zuilen","REG_SZ", $regreadinstall & "\" & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Zuilen","ProgramName"))
                    ; Key created
                Else
                    RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Zuilen")
                    ; Key deleted
                Endif

                ;$restart = 1
                If GUICtrlRead($Kioskmode) = 1 Then
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","Kioskmode","REG_SZ","1")
                Else
                    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","Kioskmode","REG_SZ","0")
                Endif

                GUISetState(@SW_HIDE,$SettingsForm)
                ExitLoop

            Case $settingsmsg = $InstallButton1

                _Install()
                if @error = 0 then terminate()
                GUISetState(@SW_HIDE,$SettingsForm)
                ExitLoop
            Case $settingsmsg = $DeinstallButton1

                Run ( $regreadinstall & "\uninstall.exe")

                $restart = 0
                GUISetState(@SW_HIDE,$SettingsForm)
                ExitLoop

            Case $settingsmsg = $Kioskmode
                $restart = 1
                ContinueLoop
            Case $settingsmsg = $autorun1

                If GUICtrlRead($autorun1) = 1 Then
                    GUICtrlSetState($disablelabel, $GUI_HIDE )
                    GUICtrlSetState($enablelabel, $GUI_SHOW )
                Else
                    GUICtrlSetState($enablelabel, $GUI_HIDE )
                    GUICtrlSetState($disablelabel, $GUI_SHOW )
                    ContinueLoop
                Endif


            Case $settingsmsg = $save_ini_button1

                If $lokatie_input1 <> IniRead($inifile,"Instellingen","Lokatie","Rayon") Then
                    IniWrite($inifile,"Instellingen","Lokatie",GUICtrlRead( $lokatie_input1))
                    GUICtrlSetState($iniopgeslagen, $GUI_SHOW )
                    $restart = 1
                EndIf

                ContinueLoop


            Case $settingsmsg = $Useini1
                if GUICtrlRead($Useini1) = 1 Then
                    GUICtrlSetState($lokatie_input1, $GUI_ENABLE)
                    GUICtrlSetState($save_ini_button1, $GUI_ENABLE)
                Else
                    GUICtrlSetState($lokatie_input1, $GUI_DISABLE)
                    GUICtrlSetState($save_ini_button1, $GUI_DISABLE)
                Endif

                ContinueLoop
            Case Else
                ;;;;;;;
        EndSelect



    WEnd

    if $restart = 1 Then _restart()
    exit


EndFunc

feel free to ask any question, just make sure that you use the Help file first.

RK

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Aaaah,

Somebody give that man a cigar !

This is great !, You've been a great help in solving my problem.

I think I also understand now what I did wrong but thanks to your explanations i've managed to solve all issues i had with this.

A 1000 thanks :)

Edited by Ruud_Sas
Link to comment
Share on other sites

Aaaah,

Somebody give that man a cigar !

This is great !, You've been a great help in solving my problem.

I think I also understand now what I did wrong but thanks to your explanations i've managed to solve all issues i had with this.

A 1000 thanks :)

Your welcome.

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...