JimC Posted February 18, 2009 Share Posted February 18, 2009 I am having an issue with a simple guictrlread; I am trying to read a computer name from a GUICtrlCreateInput statement and I I get as a result which is a 4 which I think might be a state. Can someone take a look and advise what I am doing wrong ? Any help would be greatly appreciated. I did use Koda to assist with gui creation. expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> Global $computer #Region ### START Koda GUI section ### Form=C:\Documents and Settings\e15850t\Desktop\Form1.kxf $Form1 = GUICreate("AMO Mif Fix", 630, 431, 379, 121) $Group1 = GUICtrlCreateGroup("Pc Information", 8, 16, 217, 129) $computer=GUICtrlCreateInput("", 20, 64, 105, 30, -1) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ping", 144, 40, 75, 33, 0) $Label1 = GUICtrlCreateLabel("PC Name", 56, 40, 49, 17) $Button2 = GUICtrlCreateButton("Map Drive", 144, 99, 75, 33, 0) GUICtrlSetState($Button2, $gui_disable) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("User Information for PC", 8, 152, 217, 265) GUICtrlCreateInput("", 16, 208, 121, 28) GUICtrlSetLimit(-1, 5) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("", 16, 272, 121, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("", 16, 336, 121, 21) $Label2 = GUICtrlCreateLabel("Cost Center", 48, 184, 59, 17) $Label3 = GUICtrlCreateLabel("Primary User", 48, 248, 63, 17) $Button3 = GUICtrlCreateButton("Modify Mif", 24, 375, 99, 33, 0) GUICtrlSetState($Button3, $gui_disable) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("PC Alive ?", 280, 24, 313, 57) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Drive Mapped ?", 277, 127, 313, 57) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup("Mif Written", 282, 225, 313, 113) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MyPing() EndSwitch WEnd Func MyPing() If GUICtrlRead($computer) = '' Then $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) Return Else $message = GUICtrlCreateLabel('Pinging PC ' & $computer, 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) EndIf $var = Ping($computer,250) If $var =1 Then; also possible: If @error = 0 Then ... $message = GUICtrlCreateLabel( $computer &' is online !', 300, 50, 570, 20) Else $message = GUICtrlCreateLabel( $computer &' is offline !', 300, 50, 570, 20) EndIf EndFunc Link to comment Share on other sites More sharing options...
SpookMeister Posted February 18, 2009 Share Posted February 18, 2009 In your Else statement you are using the handle $computer directly instead of doing a GuiCtrlRead($computer) If GUICtrlRead($computer) = '' Then $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) Return Else $message = GUICtrlCreateLabel('Pinging PC ' & GUICtrlRead($computer), 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) EndIf [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Zedna Posted February 18, 2009 Share Posted February 18, 2009 (edited) It works fine for me - returns text typed in input control: Func MyPing() MsgBox(0,'',GUICtrlRead($computer)) EndFunc Edited February 18, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
JimC Posted February 18, 2009 Author Share Posted February 18, 2009 It works fine for me - returns text typed in input control: Func MyPing() MsgBox(0,'',GUICtrlRead($computer)) EndFunc Thanks you very much using GUICtrlRead($computer) instead of $computer fixed it. Link to comment Share on other sites More sharing options...
JimC Posted February 18, 2009 Author Share Posted February 18, 2009 I spoke too soon. The ping doesnt work now. Link to comment Share on other sites More sharing options...
SpookMeister Posted February 18, 2009 Share Posted February 18, 2009 Because you are making the same mistake again... also instead of re-reading the information from the same place over and over again... you should stick it into a new variable and then use that. expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> Global $computer #Region ### START Koda GUI section ### Form=C:\Documents and Settings\e15850t\Desktop\Form1.kxf $Form1 = GUICreate("AMO Mif Fix", 630, 431, 379, 121) $Group1 = GUICtrlCreateGroup("Pc Information", 8, 16, 217, 129) $computer = GUICtrlCreateInput("", 20, 64, 105, 30, -1) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ping", 144, 40, 75, 33, 0) $Label1 = GUICtrlCreateLabel("PC Name", 56, 40, 49, 17) $Button2 = GUICtrlCreateButton("Map Drive", 144, 99, 75, 33, 0) GUICtrlSetState($Button2, $gui_disable) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("User Information for PC", 8, 152, 217, 265) GUICtrlCreateInput("", 16, 208, 121, 28) GUICtrlSetLimit(-1, 5) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("", 16, 272, 121, 28) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("", 16, 336, 121, 21) $Label2 = GUICtrlCreateLabel("Cost Center", 48, 184, 59, 17) $Label3 = GUICtrlCreateLabel("Primary User", 48, 248, 63, 17) $Button3 = GUICtrlCreateButton("Modify Mif", 24, 375, 99, 33, 0) GUICtrlSetState($Button3, $gui_disable) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("PC Alive ?", 280, 24, 313, 57) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Drive Mapped ?", 277, 127, 313, 57) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup("Mif Written", 282, 225, 313, 113) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MyPing() EndSwitch WEnd Func MyPing() $s_PCname = GUICtrlRead($computer) If $s_PCname = '' Then $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) Return Else $message = GUICtrlCreateLabel('Pinging PC ' & $s_PCname, 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) EndIf $var = Ping($s_PCname, 250) If $var = 1 Then; also possible: If @error = 0 Then ... $message = GUICtrlCreateLabel($s_PCname & ' is online !', 300, 50, 570, 20) Else $message = GUICtrlCreateLabel($s_PCname & ' is offline !', 300, 50, 570, 20) EndIf EndFunc ;==>MyPing [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] 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