Jump to content
Sign in to follow this  

re load gui from sys tray problam

Recommended Posts

hare is my code:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

$settings   = TrayCreateItem("settings")
$exititem  = TrayCreateItem("exit")

While 1

Func settings()
$FromName = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "fromname")
$Subject = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "Subject")
$ToAddress = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "mailaddressto")
$FromAddress = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "mailaddressfrom")
$Username = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "usernamemail")
$Password = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "passwordmail")
$SmtpServer = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpserver")
$Port = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpport")
$ssl = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpusessl")

;Create window
GUICreate("settings", 400, 280, -1, -1, BitOR ($WS_CAPTION, $WS_SYSMENU), $WS_EX_LAYOUTRTL)
$FromName0 = GUICtrlCreateLabel("name", 10,10,210,20)
$FromName1 = GUICtrlCreateInput ($FromName, 210,10,150,20)
$Subject0 = GUICtrlCreateLabel("subject", 10,35,210,20)
$Subject1 = GUICtrlCreateInput ($Subject, 210,35,150,20)
$ToAddress0 = GUICtrlCreateLabel("to address", 10,60,210,20)
$ToAddress1 = GUICtrlCreateInput ($ToAddress, 210,60,150,20,0x0010)
$FromAddress0 = GUICtrlCreateLabel("from address:", 10,85,210,20)
$FromAddress1 = GUICtrlCreateInput ($FromAddress, 210,85,150,20,0x0010)
$Username0 = GUICtrlCreateLabel("username:", 10,110,210,20)
$Username1 = GUICtrlCreateInput ($Username, 210,110,150,20,0x0010)
$Password0 = GUICtrlCreateLabel("password:", 10,135,210,20)
$Password1 = GUICtrlCreateInput ($Password, 210,135,150,20,0x0020)
$SmtpServer0 = GUICtrlCreateLabel("server smtp:", 10,160,210,20)
$SmtpServer1 = GUICtrlCreateInput ($SmtpServer, 210,160,150,20,0x0010)
$Port0 = GUICtrlCreateLabel("port:", 10,185,210,20)
$Port1 = GUICtrlCreateInput ($Port, 210,185,150,20,0x2000)
$ssl0 = GUICtrlCreateLabel("using ssl connection (SSL)?", 10,210,210,20)
$ssl1 = GUICtrlCreateRadio ("yes", 210, 210, 30, 20)
$ssl2 = GUICtrlCreateRadio ("no", 250, 210, 30, 20)
        GUICtrlSetState($ssl1, $GUI_CHECKED)
$Save_Btn = GUICtrlCreateButton("save and close", 20, 250, 70, 25)
$Reset_Btn = GUICtrlCreateButton("reset form", 120, 250, 70, 25)
$Exit_Btn = GUICtrlCreateButton("close", 220, 250, 70, 25)
$delete_Btn = GUICtrlCreateButton("del settings", 320, 250, 70, 25)

Func settings()
While 1
    $msg = GUIGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
        Case $msg = $Save_Btn
            $DATA_FromName = GUICtrlRead($FromName1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "fromname", "REG_SZ", $DATA_FromName)
            $DATA_Subject = GUICtrlRead($Subject1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "Subject", "REG_SZ", $DATA_Subject)
            $DATA_ToAddress = GUICtrlRead($ToAddress1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "mailaddressto", "REG_SZ", $DATA_ToAddress)
            $DATA_FromAddress = GUICtrlRead($FromAddress1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "mailaddressfrom", "REG_SZ", $DATA_FromAddress)
            $DATA_Username = GUICtrlRead($Username1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "usernamemail", "REG_SZ", $DATA_Username)
            $DATA_Password = GUICtrlRead($Password1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "passwordmail", "REG_SZ", $DATA_Password)
            $DATA_SmtpServer = GUICtrlRead($SmtpServer1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpserver", "REG_SZ", $DATA_SmtpServer)
            $DATA_Port = GUICtrlRead($Port1)
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpport", "REG_SZ", $DATA_Port)
            If GUICtrlRead($ssl1) = 1 Then
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpusessl", "REG_SZ", "1")
            ElseIf GUICtrlRead($ssl2) = 1 Then
                RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpusessl", "REG_SZ", "0")
        Case $msg = $Reset_Btn
                GUICtrlSetData($FromName1, '')
                GUICtrlSetData($Subject1, '')
                GUICtrlSetData($ToAddress1, '')
                GUICtrlSetData($FromAddress1, '')
                GUICtrlSetData($Username1, '')
                GUICtrlSetData($Password1, '')
                GUICtrlSetData($SmtpServer1, '')
                GUICtrlSetData($Port1, '')
        Case $msg = $delete_Btn
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "fromname", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "Subject", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "mailaddressto", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "mailaddressfrom", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "usernamemail", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "passwordmail", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpserver", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpport", "REG_SZ", "")
                RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\SendMyIP", "smtpusessl", "REG_SZ", "")
        Case $msg = $Exit_Btn

Func ExitScript()

if i open the settings windows first time it is open good but if i try open it again from the tray menu its not open

help me please.


Edited by shai

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forum. :graduated:

You need to escape from the While...WEnd loop in the settings function - so add ExitLoop immediately after each GUIDelete() line. :(

You might also want to use Opt("TrayMenuMode", 3) so you do not get ticks in the tray menu. :D

All clear? :D


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...