shay Posted March 22, 2010 Share Posted March 22, 2010 i use this small script to see my IP etc... i want to move this code to GUI and so i can do "refresh" to the IP etc... i need Exit and refresh button. #include <INet.au3> $Public = _GetIP() if $Public = 0 Then $Public = "Error local IP" EndIf $lan1 = @IPAddress1 $lan2 = @IPAddress2 $name = @ComputerName MsgBox(0, "IpConfig", "Public IP: " &$Public & @CRLF & @CRLF & "Local IP: " & $lan1 & @CRLF & @CRLF & "Local LAN 2: " & $lan2 & @CRLF & @CRLF & "PC Name: " & $name ) thanks "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 22, 2010 Moderators Share Posted March 22, 2010 shay,i want to move this code to GUI and so i can do "refresh" to the IP etc...i need Exit and refresh button.If you can write the code you posted, you should be able to figure out how to write a GUI and 2 buttons. Look in the Help file under GUICtrlCreateButton and there is a nice example of how to do it.Give it go yourself and come back if you run into difficulties. 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 Link to comment Share on other sites More sharing options...
shay Posted March 24, 2010 Author Share Posted March 24, 2010 The GUI was no problem but i don't have any idea how to execute the "Refresh" so the IP will refresh. #include <INet.au3> GuiCreate("IP",230,200,209,29) $Public = _GetIP() if $Public = 0 Then $Public = "Error local IP" EndIf $lan1 = @IPAddress1 $lan2 = @IPAddress2 $name = @ComputerName $button1=GuiCtrlCreateButton("Exit",24,160,87,34) $button2=GuiCtrlCreateButton("Refresh",121,160,87,34) $label1=GuiCtrlCreateLabel("Public IP: " &$Public,50,40,136,15) $label2=GuiCtrlCreateLabel("Local IP: " & $lan1,50,60,136,15) $label3=GuiCtrlCreateLabel("Local LAN 2: " & $lan2,50,80,136,15) $label4=GuiCtrlCreateLabel("PC Name: " & $name,50,110,136,15) GuiSetState() While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit If $msg=$button1 Then button1() If $msg=$button2 Then button2() Wend Func button1() Exit EndFunc Func button2() ;need to refresh the labels EndFunc "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2010 Moderators Share Posted March 24, 2010 shay, but i don't have any idea how to execute the "Refresh"What did you do to get the values in the first place? If you were to put that code into a function, you could call it both initially and when the "Refresh" button is pressed. You can use GUICtrlSetData to change the content of the labels after the "Refresh". Like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <INet.au3> $Public = Get_IP() $lan1 = @IPAddress1 $lan2 = @IPAddress2 $name = @ComputerName GUICreate("IP", 230, 200, 209, 29) $button1 = GUICtrlCreateButton("Exit", 24, 160, 87, 34) $button2 = GUICtrlCreateButton("Refresh", 121, 160, 87, 34) $label1 = GUICtrlCreateLabel("Public IP: " & $Public, 50, 40, 136, 15) $label2 = GUICtrlCreateLabel("Local IP: " & $lan1, 50, 60, 136, 15) $label3 = GUICtrlCreateLabel("Local LAN 2: " & $lan2, 50, 80, 136, 15) $label4 = GUICtrlCreateLabel("PC Name: " & $name, 50, 110, 136, 15) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $button1 button1() Case $button2 button2() EndSwitch WEnd Func button1() Exit EndFunc ;==>button1 Func button2() GUICtrlSetData($label1, "Public IP: " & Get_IP()) GUICtrlSetData($label2, "Local IP: " & @IPAddress1) GUICtrlSetData($label3, "Local LAN 2: " & @IPAddress2) GUICtrlSetData($label4, "PC Name: " & @ComputerName) EndFunc ;==>button2 Func Get_IP() Local $Public = _GetIP() If $Public = 0 Then $Public = "Error local IP" EndIf Return $Public EndFunc ;==>Get_IP You will see I have changed your list of If statements for a Switch structure - this makes the code clearer (in the opinion of most) and actually faster! 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now