Sign in to follow this  
Followers 0
Chris86

Need help with my GUI

3 posts in this topic

#1 ·  Posted (edited)

Hi, Can some one help me to find the problems in my GUI?

In this script there is 2 GUI's, the main gui and one settings gui, but I got some problems opening the settings gui from the main gui..

#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <Process.au3>
;End includes

;Files:
$folder = @AppDataDir & "\WakeOnLan"
$settingsini = @AppDataDir & "\WakeOnLan\Settings.ini"
FileInstall("C:\Users\Christian\Desktop\BG.BMP", $folder & "\BG.BMP")
FileInstall("C:\Users\Christian\Desktop\icon.ico", $folder & "\icon.ico")
TraySetIcon($folder & "\icon.ico")
Global $Settings
;End - Files


If FileExists(@AppDataDir & "\WakeOnLan\Settings.ini") Then
    $MACAddress = IniRead($settingsini, "WOL-Settings", "MAC", "")
    $IPAddress = IniRead($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")
    ;Teamviewer Settings
    $Tv = IniRead($settingsini, "Teamviewer", "Enable", "0")
    $TvID = IniRead($settingsini, "Teamviewer", "Teamviewer-ID", "0")
    $TvPWD = IniRead($settingsini, "Teamviewer", "Teamviewer-Password", "0")
    $TvDelay = IniRead($settingsini, "Teamviewer", "Delay", "30")
    $TvExe = IniRead($settingsini, "Teamviewer", "InstallDir", "")
    RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory")
Else
    install()
    _ReadSettings()
EndIf





;MAIN GUI
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Main = GUICreate("asdasd", 221, 178, 317, 218, $WS_CLIPSIBLINGS, BitOR($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE))
GUISetBkColor(0xA0A0A0)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "MainRestore")
$start = GUICtrlCreateButton("Start PC", 24, 8, 171, 57, $WS_GROUP)
GUICtrlSetOnEvent(-1, "startClick")
$settingsmenu = GUICtrlCreateButton("Settings", 64, 72, 91, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "settingsClick")
$Exit = GUICtrlCreateButton("Close", 24, 104, 171, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "ExitClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



Func ExitClick()
Exit
EndFunc
Func MainClose()

EndFunc
Func MainMaximize()

EndFunc
Func MainMinimize()

EndFunc
Func MainRestore()

EndFunc
Func settingsClick()
_ReadSettings()
GUISetState($Settings,@SW_SHOW)
GUISetState($Main,@SW_HIDE)
EndFunc
Func startClick()
_ReadSettings()

            If $Tv = 1 Then
                $sleep = $TvDelay * 1000
                Sendpacket()
                Sleep($sleep)
                $rc = _RunDOS($TvExe & "\teamviewer.exe>teamviewer.exe -i " & $TvID & " --Password " & $TvPWD)
            Else
                Sendpacket()
            EndIf
EndFunc

;END MAIN GUI



;
;SETTINGS GUI
;

#Region ### START Koda GUI section ### Form=c:\users\christian\desktop\settings.kxf
$Settings = GUICreate("Settings", 262, 261, 229, 161)
GUISetBkColor(0xA0A0A4)
GUISetOnEvent($GUI_EVENT_CLOSE, "SettingsClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SettingsMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "SettingsMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "SettingsRestore")
$Teamviewer = GUICtrlCreateTab(0, 0, 257, 233)
GUICtrlSetResizing($Teamviewer, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Settings")
$MACLabel = GUICtrlCreateLabel("MAC-Address", 8, 32, 68, 17)
GUICtrlSetFont($MACLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent($MACLabel, "MACLabelClick")
$MAC = GUICtrlCreateInput("00-00-00-00-00-00", 12, 49, 121, 21)
GUICtrlSetData($MAC, $MACAddress)
GUICtrlSetOnEvent($MAC, "MACChange")
$Uninstall = GUICtrlCreateButton("Uninstall", 8, 192, 99, 25, $WS_GROUP)
GUICtrlSetOnEvent($Uninstall, "UninstallClick")
$TabSheet2 = GUICtrlCreateTabItem("Teamviewer")
$Tv = GUICtrlCreateCheckbox("Enable Teamviewer", 8, 32, 121, 17)
GUICtrlSetOnEvent($Tv, "TvClick")
$TVPWDLabel = GUICtrlCreateLabel("Teamviewer Password", 8, 120, 111, 17)
GUICtrlSetFont($TVPWDLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent($TVPWDLabel, "TVPWDLabelClick")
$TVIDInput = GUICtrlCreateInput("TVID", 8, 80, 121, 21)
GUICtrlSetLimit($TVIDInput, 9)
GUICtrlSetData($TVIDInput, $TvID)
GUICtrlSetTip($TVIDInput, "Your unique user id")
GUICtrlSetOnEvent($TVIDInput, "TVIDChange")
$TvIDLabel = GUICtrlCreateLabel("Teamviewer ID", 8, 56, 76, 17)
GUICtrlSetFont($TvIDLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent($TvIDLabel, "TvIDLabelClick")
$TVPASSWDInput = GUICtrlCreateInput("", 8, 144, 121, 21)
GUICtrlSetLimit($TVPASSWDInput, 99)
GUICtrlSetData($TVPASSWDInput, $TvPWD)
GUICtrlSetOnEvent($TVPASSWDInput, "TVPASSWDChange")
$DelayLabel = GUICtrlCreateLabel("DelayLabel", 8, 168, 57, 17)
GUICtrlSetFont($DelayLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip($DelayLabel, "How long time your computer use to reach the Windows Login screen(Seconds)")
GUICtrlSetOnEvent($DelayLabel, "DelayLabelClick")
$Delay = GUICtrlCreateInput("", 8, 192, 41, 21)
GUICtrlSetLimit($Delay, 5)
GUICtrlSetData($Delay, $TvDelay)
GUICtrlSetOnEvent($Delay, "DelayChange")
GUICtrlCreateTabItem("")
GUICtrlSetOnEvent($Teamviewer, "TeamviewerChange")
$save = GUICtrlCreateButton("Save", 8, 232, 107, 25, $WS_GROUP)
GUICtrlSetOnEvent($save, "saveClick")
$Close = GUICtrlCreateButton("Close", 136, 232, 115, 25, $WS_GROUP)
GUICtrlSetOnEvent($Close, "CloseClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func CloseClick()
GUISetState($Settings,@SW_HIDE)
GUISetState($Main,@SW_SHOW)
EndFunc
Func DelayChange()

EndFunc
Func DelayLabelClick()

EndFunc
Func MACChange()

EndFunc
Func MACLabelClick()

EndFunc
Func saveClick()
;Read from GUI..
                $sMAC = GUICtrlRead($MAC)
                $sTV = GUICtrlRead($Tv)
                $sTVID = GUICtrlRead($TVIDInput)
                $sTVPASSWD = GUICtrlRead($TVPASSWDInput)


                ;Removing the "-" from the MAC address so the magicpacket part works properly
                ; $dMAC = StringReplace($sMAC, "-", "")
                ;-------
                ;$dTVID = StringReplace($sTVID, " ", "");Removing spaces

                ;Done! Huuurraaay!
                $LastDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory");Updating

                IniWrite($settingsini, "WOL-Settings", "MAC", $sMAC);MAC ADDRESS WITHOUT "-"
                IniWrite($settingsini, "Teamviewer", "Enable", $sTV) ;enable Teamviewer with this script?
                IniWrite($settingsini, "Teamviewer", "Teamviewer-ID", $sTVID)
                IniWrite($settingsini, "Teamviewer", "Teamviewer-Password", $sTVPASSWD)
                IniWrite($settingsini, "Teamviewer", "Delay", "60")
                IniWrite($settingsini, "Teamviewer", "InstallDir", $LastDir)

EndFunc
Func SettingsClose()
GUISetState($Settings,@SW_HIDE)
EndFunc
Func SettingsMaximize()

EndFunc
Func SettingsMinimize()

EndFunc
Func SettingsRestore()

EndFunc
Func TeamviewerChange()

EndFunc
Func TvClick()

EndFunc
Func TVIDChange()

EndFunc
Func TvIDLabelClick()

EndFunc
Func TVPASSWDChange()

EndFunc
Func TVPWDLabelClick()

EndFunc
Func UninstallClick()

EndFunc




;
;END: SETTINGS GUI
;










;SEND MAGICPACKET
Func Sendpacket()
    UDPStartup()

    $connexion = UDPOpen($IPAddress, 7)
    $res = UDPSend($connexion, GenerateMagicPacket($MACAddress))
    TraySetState()
    $pos = MouseGetPos()
    ToolTip("Magicpacket successfully sent!", $pos[0], $pos[1])
    sleep(5000)

    UDPCloseSocket($connexion)
    UDPShutdown()
EndFunc   ;==>Sendpacket

; ===================================================================
; Functions
; ===================================================================


; This function convert a MAC Address Byte (e.g. "1f") to a char
Func HexToChar($strHex)

    Return Chr(Dec($strHex))

EndFunc   ;==>HexToChar

; This function generate the "Magic Packet"
Func GenerateMagicPacket($strMACAddress)

    $MagicPacket = ""
    $MACData = ""

    For $p = 1 To 11 Step 2
        $MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2))
    Next

    For $p = 1 To 6
        $MagicPacket = HexToChar("ff") & $MagicPacket
    Next

    For $p = 1 To 16
        $MagicPacket = $MagicPacket & $MACData
    Next

    Return $MagicPacket

EndFunc   ;==>GenerateMagicPacket

Func _ReadSettings()
    $MACAddress = IniRead($settingsini, "WOL-Settings", "MAC", "")
    $IPAddress = IniRead($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")

    $Tv = IniRead($settingsini, "Teamviewer", "Enable", "0")
    $TvID = IniRead($settingsini, "Teamviewer", "Teamviewer-ID", "")
    $TvPWD = IniRead($settingsini, "Teamviewer", "Teamviewer-Password", "")
    $TvDelay = IniRead($settingsini, "Teamviewer", "Delay", "30")
    $TvExe = IniRead($settingsini, "Teamviewer", "InstallDir", "")
EndFunc   ;==>_ReadSettings

Func install()
    If FileExists($folder) Then
        _FileCreate($settingsini)
        IniWrite($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")
        IniWrite($settingsini, "WOL-Settings", "MAC", "")
        IniWrite($settingsini, "WOL-Settings", "dMAC", "")
        IniWrite($settingsini, "Teamviewer", "Enable", "0")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-ID", "")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-Password", "")
        IniWrite($settingsini, "Teamviewer", "Delay", "60")
        $LastDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory")
        IniWrite($settingsini, "Teamviewer", "InstallDir", $LastDir)
    Else
        DirCreate($folder)
        _FileCreate($settingsini)
        IniWrite($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")
        IniWrite($settingsini, "WOL-Settings", "MAC", "")
        IniWrite($settingsini, "WOL-Settings", "dMAC", "")
        IniWrite($settingsini, "Teamviewer", "Enable", "0")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-ID", "")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-Password", "")
        IniWrite($settingsini, "Teamviewer", "Delay", "60")
        $LastDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory")
        IniWrite($settingsini, "Teamviewer", "InstallDir", $LastDir)
    EndIf
EndFunc   ;==>install


Func Test()
    GUISetState(@SW_HIDE,$Settings)
EndFunc
Edited by Chris86

Share this post


Link to post
Share on other sites



what exactly is the problem? i really don't have time to look through that to find the problem.... whats happening and we'll see if we can tell you whats making it happen

Share this post


Link to post
Share on other sites

Hi, Can some one help me to find the problems in my GUI?

In this script there is 2 GUI's, the main gui and one settings gui, but I got some problems opening the settings gui from the main gui..

#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <Process.au3>
;End includes

;Files:
$folder = @AppDataDir & "\WakeOnLan"
$settingsini = @AppDataDir & "\WakeOnLan\Settings.ini"
FileInstall("C:\Users\Christian\Desktop\BG.BMP", $folder & "\BG.BMP")
FileInstall("C:\Users\Christian\Desktop\icon.ico", $folder & "\icon.ico")
TraySetIcon($folder & "\icon.ico")
Global $Settings
;End - Files


If FileExists(@AppDataDir & "\WakeOnLan\Settings.ini") Then
    $MACAddress = IniRead($settingsini, "WOL-Settings", "MAC", "")
    $IPAddress = IniRead($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")
    ;Teamviewer Settings
    $Tv = IniRead($settingsini, "Teamviewer", "Enable", "0")
    $TvID = IniRead($settingsini, "Teamviewer", "Teamviewer-ID", "0")
    $TvPWD = IniRead($settingsini, "Teamviewer", "Teamviewer-Password", "0")
    $TvDelay = IniRead($settingsini, "Teamviewer", "Delay", "30")
    $TvExe = IniRead($settingsini, "Teamviewer", "InstallDir", "")
    RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory")
Else
    install()
    _ReadSettings()
EndIf





;MAIN GUI
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Main = GUICreate("asdasd", 221, 178, 317, 218, $WS_CLIPSIBLINGS, BitOR($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE))
GUISetBkColor(0xA0A0A0)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "MainRestore")
$start = GUICtrlCreateButton("Start PC", 24, 8, 171, 57, $WS_GROUP)
GUICtrlSetOnEvent(-1, "startClick")
$settingsmenu = GUICtrlCreateButton("Settings", 64, 72, 91, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "settingsClick")
$Exit = GUICtrlCreateButton("Close", 24, 104, 171, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "ExitClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



Func ExitClick()
Exit
EndFunc
Func MainClose()

EndFunc
Func MainMaximize()

EndFunc
Func MainMinimize()

EndFunc
Func MainRestore()

EndFunc
Func settingsClick()
_ReadSettings()
GUISetState($Settings,@SW_SHOW)
GUISetState($Main,@SW_HIDE)
EndFunc
Func startClick()
_ReadSettings()

            If $Tv = 1 Then
                $sleep = $TvDelay * 1000
                Sendpacket()
                Sleep($sleep)
                $rc = _RunDOS($TvExe & "\teamviewer.exe>teamviewer.exe -i " & $TvID & " --Password " & $TvPWD)
            Else
                Sendpacket()
            EndIf
EndFunc

;END MAIN GUI



;
;SETTINGS GUI
;

#Region ### START Koda GUI section ### Form=c:\users\christian\desktop\settings.kxf
$Settings = GUICreate("Settings", 262, 261, 229, 161)
GUISetBkColor(0xA0A0A4)
GUISetOnEvent($GUI_EVENT_CLOSE, "SettingsClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SettingsMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "SettingsMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "SettingsRestore")
$Teamviewer = GUICtrlCreateTab(0, 0, 257, 233)
GUICtrlSetResizing($Teamviewer, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Settings")
$MACLabel = GUICtrlCreateLabel("MAC-Address", 8, 32, 68, 17)
GUICtrlSetFont($MACLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent($MACLabel, "MACLabelClick")
$MAC = GUICtrlCreateInput("00-00-00-00-00-00", 12, 49, 121, 21)
GUICtrlSetData($MAC, $MACAddress)
GUICtrlSetOnEvent($MAC, "MACChange")
$Uninstall = GUICtrlCreateButton("Uninstall", 8, 192, 99, 25, $WS_GROUP)
GUICtrlSetOnEvent($Uninstall, "UninstallClick")
$TabSheet2 = GUICtrlCreateTabItem("Teamviewer")
$Tv = GUICtrlCreateCheckbox("Enable Teamviewer", 8, 32, 121, 17)
GUICtrlSetOnEvent($Tv, "TvClick")
$TVPWDLabel = GUICtrlCreateLabel("Teamviewer Password", 8, 120, 111, 17)
GUICtrlSetFont($TVPWDLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent($TVPWDLabel, "TVPWDLabelClick")
$TVIDInput = GUICtrlCreateInput("TVID", 8, 80, 121, 21)
GUICtrlSetLimit($TVIDInput, 9)
GUICtrlSetData($TVIDInput, $TvID)
GUICtrlSetTip($TVIDInput, "Your unique user id")
GUICtrlSetOnEvent($TVIDInput, "TVIDChange")
$TvIDLabel = GUICtrlCreateLabel("Teamviewer ID", 8, 56, 76, 17)
GUICtrlSetFont($TvIDLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent($TvIDLabel, "TvIDLabelClick")
$TVPASSWDInput = GUICtrlCreateInput("", 8, 144, 121, 21)
GUICtrlSetLimit($TVPASSWDInput, 99)
GUICtrlSetData($TVPASSWDInput, $TvPWD)
GUICtrlSetOnEvent($TVPASSWDInput, "TVPASSWDChange")
$DelayLabel = GUICtrlCreateLabel("DelayLabel", 8, 168, 57, 17)
GUICtrlSetFont($DelayLabel, 9, 400, 0, "MS Sans Serif")
GUICtrlSetTip($DelayLabel, "How long time your computer use to reach the Windows Login screen(Seconds)")
GUICtrlSetOnEvent($DelayLabel, "DelayLabelClick")
$Delay = GUICtrlCreateInput("", 8, 192, 41, 21)
GUICtrlSetLimit($Delay, 5)
GUICtrlSetData($Delay, $TvDelay)
GUICtrlSetOnEvent($Delay, "DelayChange")
GUICtrlCreateTabItem("")
GUICtrlSetOnEvent($Teamviewer, "TeamviewerChange")
$save = GUICtrlCreateButton("Save", 8, 232, 107, 25, $WS_GROUP)
GUICtrlSetOnEvent($save, "saveClick")
$Close = GUICtrlCreateButton("Close", 136, 232, 115, 25, $WS_GROUP)
GUICtrlSetOnEvent($Close, "CloseClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func CloseClick()
GUISetState($Settings,@SW_HIDE)
GUISetState($Main,@SW_SHOW)
EndFunc
Func DelayChange()

EndFunc
Func DelayLabelClick()

EndFunc
Func MACChange()

EndFunc
Func MACLabelClick()

EndFunc
Func saveClick()
;Read from GUI..
                $sMAC = GUICtrlRead($MAC)
                $sTV = GUICtrlRead($Tv)
                $sTVID = GUICtrlRead($TVIDInput)
                $sTVPASSWD = GUICtrlRead($TVPASSWDInput)


                ;Removing the "-" from the MAC address so the magicpacket part works properly
                ; $dMAC = StringReplace($sMAC, "-", "")
                ;-------
                ;$dTVID = StringReplace($sTVID, " ", "");Removing spaces

                ;Done! Huuurraaay!
                $LastDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory");Updating

                IniWrite($settingsini, "WOL-Settings", "MAC", $sMAC);MAC ADDRESS WITHOUT "-"
                IniWrite($settingsini, "Teamviewer", "Enable", $sTV) ;enable Teamviewer with this script?
                IniWrite($settingsini, "Teamviewer", "Teamviewer-ID", $sTVID)
                IniWrite($settingsini, "Teamviewer", "Teamviewer-Password", $sTVPASSWD)
                IniWrite($settingsini, "Teamviewer", "Delay", "60")
                IniWrite($settingsini, "Teamviewer", "InstallDir", $LastDir)

EndFunc
Func SettingsClose()
GUISetState($Settings,@SW_HIDE)
EndFunc
Func SettingsMaximize()

EndFunc
Func SettingsMinimize()

EndFunc
Func SettingsRestore()

EndFunc
Func TeamviewerChange()

EndFunc
Func TvClick()

EndFunc
Func TVIDChange()

EndFunc
Func TvIDLabelClick()

EndFunc
Func TVPASSWDChange()

EndFunc
Func TVPWDLabelClick()

EndFunc
Func UninstallClick()

EndFunc




;
;END: SETTINGS GUI
;










;SEND MAGICPACKET
Func Sendpacket()
    UDPStartup()

    $connexion = UDPOpen($IPAddress, 7)
    $res = UDPSend($connexion, GenerateMagicPacket($MACAddress))
    TraySetState()
    $pos = MouseGetPos()
    ToolTip("Magicpacket successfully sent!", $pos[0], $pos[1])
    sleep(5000)

    UDPCloseSocket($connexion)
    UDPShutdown()
EndFunc   ;==>Sendpacket

; ===================================================================
; Functions
; ===================================================================


; This function convert a MAC Address Byte (e.g. "1f") to a char
Func HexToChar($strHex)

    Return Chr(Dec($strHex))

EndFunc   ;==>HexToChar

; This function generate the "Magic Packet"
Func GenerateMagicPacket($strMACAddress)

    $MagicPacket = ""
    $MACData = ""

    For $p = 1 To 11 Step 2
        $MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2))
    Next

    For $p = 1 To 6
        $MagicPacket = HexToChar("ff") & $MagicPacket
    Next

    For $p = 1 To 16
        $MagicPacket = $MagicPacket & $MACData
    Next

    Return $MagicPacket

EndFunc   ;==>GenerateMagicPacket

Func _ReadSettings()
    $MACAddress = IniRead($settingsini, "WOL-Settings", "MAC", "")
    $IPAddress = IniRead($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")

    $Tv = IniRead($settingsini, "Teamviewer", "Enable", "0")
    $TvID = IniRead($settingsini, "Teamviewer", "Teamviewer-ID", "")
    $TvPWD = IniRead($settingsini, "Teamviewer", "Teamviewer-Password", "")
    $TvDelay = IniRead($settingsini, "Teamviewer", "Delay", "30")
    $TvExe = IniRead($settingsini, "Teamviewer", "InstallDir", "")
EndFunc   ;==>_ReadSettings

Func install()
    If FileExists($folder) Then
        _FileCreate($settingsini)
        IniWrite($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")
        IniWrite($settingsini, "WOL-Settings", "MAC", "")
        IniWrite($settingsini, "WOL-Settings", "dMAC", "")
        IniWrite($settingsini, "Teamviewer", "Enable", "0")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-ID", "")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-Password", "")
        IniWrite($settingsini, "Teamviewer", "Delay", "60")
        $LastDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory")
        IniWrite($settingsini, "Teamviewer", "InstallDir", $LastDir)
    Else
        DirCreate($folder)
        _FileCreate($settingsini)
        IniWrite($settingsini, "WOL-Settings", "BroadcastIP", "192.168.1.255")
        IniWrite($settingsini, "WOL-Settings", "MAC", "")
        IniWrite($settingsini, "WOL-Settings", "dMAC", "")
        IniWrite($settingsini, "Teamviewer", "Enable", "0")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-ID", "")
        IniWrite($settingsini, "Teamviewer", "Teamviewer-Password", "")
        IniWrite($settingsini, "Teamviewer", "Delay", "60")
        $LastDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version4", "InstallationDirectory")
        IniWrite($settingsini, "Teamviewer", "InstallDir", $LastDir)
    EndIf
EndFunc   ;==>install


Func Test()
    GUISetState(@SW_HIDE,$Settings)
EndFunc

Quite a few errorsI can see in your script.

You have a while loop after creating the main gui which should be removed because it prevents the settings gui from being created.

You have the parameters reversed in some of your GuiSetState calls.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0