shai 0 Posted November 29, 2010 (edited) hare is my code: expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) $settings = TrayCreateItem("settings") TrayItemSetOnEvent(-1,"settings") $exititem = TrayCreateItem("exit") TrayItemSetOnEvent(-1,"ExitScript") TraySetState() While 1 Sleep(10) WEnd 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) GuiSetState() Func settings() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() 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") EndIf GUIDelete() 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 GUIDelete() EndSelect WEnd EndFunc Func ExitScript() Exit EndFunc 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. thanks Edited November 29, 2010 by shai Share this post Link to post Share on other sites
Melba23 3,456 Posted November 29, 2010 shai,Welcome to the AutoIt forum. 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. All clear? M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites
shai 0 Posted November 29, 2010 ok. now its work. thanks Share this post Link to post Share on other sites