JimC Posted February 22, 2009 Posted February 22, 2009 I am having problems displaying $message6 and $message7 in the func modmif after the first if statement. The message box that I placed as a test displays the information that I want placed on the gui, but for some reason they are not displayed. Any help or suggestions would be greatly appreciated. expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <array.au3> #include <file.au3> Global $computer,$costcenter,$pcomputer,$amosrce,$pcostcenter,$pprimuser,$floor1 #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, $ES_LOWERCASE) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Ping", 144, 64, 75, 33, 0) $Label1 = GUICtrlCreateLabel("PC Name", 56, 40, 49, 17) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("User Information for PC", 8, 152, 260, 265) $Label2 = GUICtrlCreateLabel("Cost Center", 12, 184, 59, 17) $costcenter=GUICtrlCreateInput("", 10, 208, 75, 28, $ES_NUMBER) GUICtrlSetLimit(-1, 5) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetState($costcenter, $gui_disable) $Label3 = GUICtrlCreateLabel("Primary User", 12, 248, 63, 17) $primeuser = GUICtrlCreateInput("", 8.5, 272, 230, 28,$ES_UPPERCASE) GUICtrlSetLimit(-1, 25, 7) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetState($primeuser, $gui_disable) $Label4 = GUICtrlCreateLabel("Floor: Valid value 1 or 2", 12, 308, 120, 17) ;$Combo1 = GUICtrlCreateCombo("", 10, 328, 200, 25) ;GUICtrlSetData(-1, "1|2", "1"); add other item snd set a new default $floor=GUICtrlCreateInput("",10, 328, 200, 25, $ES_NUMBER) GUICtrlSetState($floor, $gui_disable) GUICtrlSetLimit(-1, 1) $Button3 = GUICtrlCreateButton("Modify Mif", 24, 375, 99, 33, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetState($Button3, $gui_disable) $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 Current", 282, 190, 313, 113) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label5 = GUICtrlCreateLabel("Cost Center: ", 285, 210, 63, 17) $Label6 = GUICtrlCreateLabel("Primary User: ", 285, 230, 63, 17) $Label7 = GUICtrlCreateLabel("Floor: ", 285, 250, 63, 17) $Label8 = GUICtrlCreateLabel("Building: ", 285, 270, 63, 17) $Group6 = GUICtrlCreateGroup("Mif Written", 282, 303, 313, 113) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label9 = GUICtrlCreateLabel("Cost Center: ", 285, 320, 63, 17) $Label10 = GUICtrlCreateLabel("Primary User: ", 285, 340, 63, 17) $Label11 = GUICtrlCreateLabel("Floor: ", 285, 360, 63, 17) $Label12 = GUICtrlCreateLabel("Building: ", 285, 380, 63, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $message =GUICtrlCreateLabel(' ', 300, 50, 570, 20) $message1=GUICtrlCreateLabel(' ' , 300, 50, 570, 20) $message2 = GUICtrlCreateLabel(' ', 300, 50, 570, 20) $message3 = GUICtrlCreateLabel(' ', 300, 50, 570, 20) $message4 = GUICtrlCreateLabel(' ', 310, 140, 570, 20) $message5 = GUICtrlCreateLabel(' ', 310, 140, 570, 20) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MyPing() Case $Button3 Modmif() EndSwitch WEnd Func MyPing() GUICtrlDelete($message2) GUICtrlDelete($message3) GUICtrlDelete($message4) GUICtrlDelete($message5) If GUICtrlRead($computer) = '' Then $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message) Return Else $pcomputer=GUICtrlRead($computer) $message1 = GUICtrlCreateLabel('Pinging PC: ' & $pcomputer, 300, 50, 570, 20) Sleep(3000) GUICtrlDelete($message1) EndIf $var = Ping($pcomputer,250) If $var <> 0 Then $message2 = GUICtrlCreateLabel( GUICtrlRead($computer) &' is online !', 300, 50, 570, 20) GUICtrlSetState($Button1, $gui_disable) MapDrive() Else $message3 = GUICtrlCreateLabel( GUICtrlRead($computer) &' is offline !', 300, 50, 570, 20) EndIf EndFunc Func MapDrive() $amosrce = DriveMapAdd("*", "\\"&$pcomputer &"\c$\uam4\clientws", 8) If Not @error Then ;msgbox(0,"AmoFix!!!","The drive was mapped as " &$amosrce,2) $message4 = GUICtrlCreateLabel( 'Drive mapped as ' & $amosrce, 310, 140, 570, 20) GUICtrlSetState($costcenter, $gui_enable) GUICtrlSetState($costcenter, $GUI_FOCUS) GUICtrlSetState($primeuser, $gui_disable) GUICtrlSetState($floor, $gui_disable) GUICtrlSetState($computer, $gui_disable) userinfo() Else $message5 = GUICtrlCreateLabel('The drive was not mapped !!!', 310, 140, 570, 20) GUICtrlSetState($Button1, $gui_enable) Return EndIf EndFunc Func userinfo() While $pcostcenter < 10000 $pcostcenter=GUICtrlRead($costcenter) WEnd GUICtrlSetState($costcenter, $gui_disable) GUICtrlSetState($primeuser, $gui_enable) GUICtrlSetState($primeuser, $GUI_FOCUS) GUIctrlsetstate($floor, $gui_enable) While not ($floor1 = 1 or $floor1=2) $floor1=GUICtrlRead($floor) WEND GUICtrlSetState($Button3, $gui_enable) EndFunc func Modmif() Dim $array1, $array2, $array3, $array4 $pprimuser=GUICtrlRead($primeuser) GUICtrlSetState($Button3, $gui_disable) GUISetState($primeuser, $gui_disable) GUISetState($floor, $gui_disable) if FileExists ($amosrce &"\slmpc.mif") Then ;need to add code to display a message Else ;need to add code to display a message and exit gui ... EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array1) $string1="Access=Write-Only" $string2="Value=" $string3="EndAttribute" $test1=StringStripWS($array1[21],8) $test1=StringTrimRight($test1,5) $result1=StringCompare($string2, $test1, 2) msgbox(0,"result", $string2 &' '& $test1 &' '&$result1) if $result1 <> 0 then $message6 = GUICtrlCreateLabel("none", 350, 210, 570, 20) $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 570, 20) ;_FileWriteToLine($amosrce &"\slmpc.mif",21," Value = "& '"'&$pcostcenter&'"',0) else $temp=StringStripWS($array1[21],8) $cc=StringTrimLeft($temp,6) msgbox(0,"info",$temp &' '&$cc&' '& $pcostcenter) $message6 = GUICtrlCreateLabel($cc, 350, 210, 570, 20) $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 570, 20) ;_FileWriteToLine($amosrce &"\slmpc.mif",21," Value = "& '"'&$pcostcenter&'"',1) EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array2) _ArrayDisplay($array2,"MIF File") $test2=StringStripWS($array2[40],8) $result2=Stringcompare($string3, $test2,2) if $result2 <> 0 Then $message8 = GUICtrlCreateLabel("none", 350, 230, 570, 20) $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20) ;_fileWritetoline($amosrce &"\slmpc.mif",39, " Value = "& '"'&$pprimuser&'"',0) Else $temp2=StringStripWS($array2[39],8) $pu=Stringtrimleft($temp2,6) $message8 = GUICtrlCreateLabel($pu, 350, 230, 570, 20) $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20) ;_fileWritetoline($amosrce &"\slmpc.mif",39, " Value = "& '"'&$pprimuser&'"',1) EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array3) _ArrayDisplay($array3,"MIF File") $test3=StringStripWS($array3[124],8) $result3=Stringcompare($string3, $test3,2) if $result3 <> 0 Then $message10 = GUICtrlCreateLabel("none", 350, 250, 570, 20) $message11 = GUICtrlCreateLabel($floor1,350, 360, 570,20) ;_fileWritetoline($amosrce &"\slmpc.mif",123, " Value = "& '"'&$pprimuser&'"',0) Else $temp3=StringStripWS($array2[123],8) $fl=Stringtrimleft($temp3,6) $message10 = GUICtrlCreateLabel($fl, 350, 250, 570, 20) $message11 = GUICtrlCreateLabel($floor1,350, 360, 570,20) ;_fileWritetoline($amosrce &"\slmpc.mif",123, " Value = "& '"'&$pprimuser&'"',1) EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array4) _ArrayDisplay($array3,"MIF File") $building = "WILKES-BARRE" $test4=StringStripWS($array4[115],8) $result4=Stringcompare($string3, $test4,2) if $result4 <> 0 Then $message12 = GUICtrlCreateLabel("none", 350, 270, 570, 20) $message13 = GUICtrlCreateLabel($building,350, 380, 570,20) ;_fileWritetoline($amosrce &"\slmpc.mif",123, " Value = "& '"'&$pprimuser&'"',0) Else $temp4=StringStripWS($array2[114],8) $bu=Stringtrimleft($temp4,6) $message12 = GUICtrlCreateLabel($bu, 350, 270, 570, 20) $message13 = GUICtrlCreateLabel($building,350, 380, 570,20) ;_fileWritetoline($amosrce &"\slmpc.mif",123, " Value = "& '"'&$pprimuser&'"',1) EndIf ;add some more code for the two remaining fields...... sleep(8000) DriveMapDel($amosrce) ;GUICtrlDelete($message2) ;GUICtrlDelete($message3) ;GUICtrlDelete($message4) ;GUICtrlDelete($message5) ;GUICtrlDelete($message6) ;GUICtrlDelete($message7) ;GUICtrlDelete($message8) ;GUICtrlDelete($message9) ;DriveMapDel($amosrce) ;GUICtrlSetState($Button1, $gui_enable) ;GUICtrlSetState($computer, $gui_enable) _SelfRestart() EndFunc Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==>_SelfRestart
BrettF Posted February 23, 2009 Posted February 23, 2009 What about if you created the labels and used GUICtrlSetData to set the text? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
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