Jump to content

JimC

Active Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by JimC

  1. i am trying to write a small function to return a user network home drive, but my results are returned as 0. I would like to return the value of the home drive or exit with an error. Thansk in for your assistance. #NoTrayIcon ;*************************************** ; ; Network HOME Drive Tool ; ;*************************************** #include <Process.au3> ; Variables $numofDrives = "" $home = "" $homedrive=gethomedrive($home) msgbox(1, "Home Drive Results", $homedrive) Func gethomedrive($home) $user=@UserName $allDrives = "" $allDrives = DriveGetDrive( "network" ) if $allDrives = "" then msgbox(1,"Home Drive Search Results", "No Network Drives Found !!! Please contact local Technical Support for assistance!!!!") else $numofDrives=$allDrives[0] For $i = 1 to $numofDrives Step 1 $curDriveLtr = $allDrives[$i] $curDrivePath = DriveMapGet($curDriveLtr) $result=StringInStr($curDrivePath, $user) msgbox(1, "Result", $result) If $result > 0 Then $home = (@UserName & $curDrivePath & ' '&$curDriveLtr) msgbox(1, "HOMEDRIVE", $home) Return EndIf Next EndIf msgbox(1,"Home Drive Search", "No Home Drive Found !!! Please contact local Technical Support for assistance!!!!") EndFunc Exit
  2. I am building trying to fina a function that will allow you to browse like explorer.exe and set a path based on a selction. Additionally I will be verifying that certain files exist to verify the directory is valid, but I can find the function that will allow you to select a source via a button. Any assistance would be greatly appreciated. Thanks, jim
  3. I am trying to control the input using GUICTRLREAD , but I want to limit the valid input to numbers between 1 and 13 I also have another filed I want the valid values to between 1 and 28. How can I control this? $cube2 = GUICtrlCreateInput('', 50, 380, 30, 25, $ES_NUMBER) $TData1= '' While $TData1 = '' $Data1 = GUICtrlRead($cube2) $TData1 = StringLeft(StringRegExpReplace($Data1, '[0[1-9]|1[0-3])', ''), 1) WEnd
  4. It would seem that I never get out of the last input box prior to Button3 getting activated. I need the second value for $cube2 to be either 1,2,3,4,5,6,7,8,9,10,11,12, or 13. I also need to use the value of that function to be returned so I can use it to manipulate something later. Is the little stipet legal ? I also need to know why I never get out of the Func WM_Command $pcube = GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') do until GUIGetMsg() =-3 GUICtrlSetState($Button3, $gui_enable) #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <array.au3> #include <file.au3> #include <WindowsConstants.au3> #Include <StaticConstants.au3> #Include <WinAPI.au3> Global $computer, $costcenter, $pcomputer, $amosrce, $pcostcenter, $pprimuser, $floor1, $pcube #Region ### START Koda GUI section ### Form=C:\Documents and Settings\e15850t\Desktop\Form1.kxf $Form1 = GUICreate("AMO Mif Fix", 630, 500, 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, 330) $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,2,4", 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) $Label5 = GUICtrlCreateLabel("Cube location: Format: A-13-1", 12, 358, 160, 17) $cube1 = GUICtrlCreateInput('', 10, 380, 30, 25, $ES_CENTER) GUICtrlCreateLabel('-',42, 380, 10,15, $SS_CENTER) $cube2 = GUICtrlCreateInput('', 50, 380, 30, 25, $ES_CENTER) GUICtrlCreateLabel('-',80, 380, 10,15, $SS_CENTER) $cube3 = GUICtrlCreateInput('', 90, 380, 30, 25, $ES_CENTER) GUICtrlSetState($cube1, $gui_disable) GUICtrlSetState($cube2, $gui_disable) GUICtrlSetState($cube3, $gui_disable) $Button3 = GUICtrlCreateButton("Modify Mif", 24, 435, 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, 125) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label6 = GUICtrlCreateLabel("Cost Center: ", 285, 210, 63, 17) $Label7 = GUICtrlCreateLabel("Primary User: ", 285, 230, 63, 17) $Label8 = GUICtrlCreateLabel("Floor: ", 285, 250, 63, 17) $Label9 = GUICtrlCreateLabel("Building: ", 285, 270, 63, 17) $label14 = GUICtrlCreateLabel("Cube location: ", 285, 290, 90, 17) $Group6 = GUICtrlCreateGroup("Mif Written", 282, 330, 313, 130) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label10 = GUICtrlCreateLabel("Cost Center: ", 285, 350, 63, 17) $Label11 = GUICtrlCreateLabel("Primary User: ", 285, 370, 63, 17) $Label12 = GUICtrlCreateLabel("Floor: ", 285, 390, 63, 17) $Label13 = GUICtrlCreateLabel("Building: ", 285, 410, 63, 17) $label14 = GUICtrlCreateLabel("Cube location: ", 285, 430, 90, 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) $message6 = GUICtrlCreateLabel(' ', 350, 210, 570, 20) $message7 = GUICtrlCreateLabel(' ', 350, 350, 570, 20) $message8 = GUICtrlCreateLabel(' ', 350, 230, 570, 20) $message9 = GUICtrlCreateLabel(' ', 350, 370, 570, 20) $message10 = GUICtrlCreateLabel(' ', 350, 250, 570, 20) $message11 = GUICtrlCreateLabel(' ', 350, 390, 570, 20) $message12 = GUICtrlCreateLabel(' ', 350, 270, 570, 20) $message13 = GUICtrlCreateLabel(' ', 350, 410, 570, 20) $message14 = GUICtrlCreateLabel(' ', 350, 290, 570, 20) $message15 = GUICtrlCreateLabel(' ', 350, 430, 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) GUICtrlSetData($computer, "") GUICtrlSetState($computer, $GUI_FOCUS) EndIf EndFunc ;==>MyPing 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 ;==>MapDrive 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 or $floor1=4) $floor1 = GUICtrlRead($floor) WEnd GUICTRLSetState($cube1, $gui_enable) GUICTRLSetState($cube2, $gui_enable) GUICTRLSetState($cube3, $gui_enable) $pcube = GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') do until GUIGetMsg() =-3 GUICtrlSetState($Button3, $gui_enable) EndFunc ;==>userinfo Func Modmif() Dim $array1, $array2, $array3, $array4, $array5 $pprimuser = GUICtrlRead($primeuser) GUICtrlSetState($Button3, $gui_disable) GUISetState($primeuser, $gui_disable) GUISetState($floor, $gui_disable) GUISetState($cube1, $gui_disable) GUISetState($cube2, $gui_disable) GUISetState($cube3, $gui_disable) If Not FileExists($amosrce & "\slmpc.mif") Then MsgBox(0, "AMO Fix", "Problem with Mif file you will need to visit the PC. You may need to rerun collect.") DriveMapDel($amosrce) _SelfRestart() EndIf _FileReadToArray($amosrce & "\slmpc.mif", $array1) $max=UBound($array1) if $max < 100 then MsgBox(0, "AMO Fix", "Problem with Mif file you will need to visit the PC. You may need to rerun collect.") DriveMapDel($amosrce) _SelfRestart() EndIf $string1 = "Access=Write-Only" $string2 = "Value=" $string3 = "EndAttribute" $count = 0 For $linecount = 0 To UBound($array1) - 1 $test1 = StringStripWS($array1[$linecount], 8) $result1 = StringCompare($string1, $test1, 2) If $result1 = 0 Then $count = $count + 1 If $count = 1 Then ExitLoop Next $test2 = StringStripWS($array1[$linecount + 2], 8) $result2 = StringCompare($string3, $test2, 8) If $result2 = 0 Then $temp = StringStripWS($array1[$linecount + 1], 8) $cc = StringTrimLeft($temp, 6) GUICtrlSetData($message6, $cc) GUICtrlSetData($message7, $pcostcenter) $linecount = $linecount + 1 ;MsgBox(0, "Test2", $linecount & ' ' & $pcostcenter) _FileWriteToLine($amosrce &"\slmpc.mif",$linecount," Value = "& $pcostcenter,1) Else $test3 = StringStripWS($array1[$linecount + 1], 8) $result3 = StringCompare($string3, $test3, 8) If $result3 = 0 Then $lc = 21 GUICtrlSetData($message6, "none") GUICtrlSetData($message7, $pcostcenter) $linecount = $linecount + 1 ;MsgBox(0, "Test3", $linecount & ' ' & $pcostcenter) _FileWriteToLine($amosrce &"\slmpc.mif",$linecount," Value = "& $pcostcenter,0) EndIf EndIf _FileReadToArray($amosrce & "\slmpc.mif", $array2) ;_ArrayDisplay($array2, "Array2") $count = 0 For $linecount = 0 To UBound($array2) - 1 $test4 = StringStripWS($array2[$linecount], 8) $result4 = StringCompare($string1, $test4, 2) If $result4 = 0 Then $count = $count + 1 If $count = 3 Then ExitLoop Next $test5 = StringStripWS($array2[$linecount + 2], 8) $result5 = StringCompare($string3, $test5, 2) If $result5 = 0 Then $temp2 = StringStripWS($array2[$linecount + 1], 8) $pu = StringTrimLeft($temp2, 6) GUICtrlSetData($message8, $pu) GUICtrlSetData($message9, $pprimuser) $linecount = $linecount + 1 ;MsgBox(0, "Test5", $linecount & ' ' & $pprimuser) _fileWritetoline($amosrce &"\slmpc.mif", $linecount, " Value = "& $pprimuser,1) Else $test6 = StringStripWS($array2[$linecount + 1], 8) $result6 = StringCompare($string3, $test6, 8) If $result6 = 0 Then GUICtrlSetData($message8, "none") GUICtrlSetData($message9, $pprimuser) $linecount = $linecount + 1 ;MsgBox(0, "Test6", $linecount & ' ' & $pprimuser) _fileWritetoline($amosrce &"\slmpc.mif", $linecount, " Value = "& $pprimuser,0) EndIf EndIf _FileReadToArray($amosrce & "\slmpc.mif", $array4) ;_ArrayDisplay($array4, "Array4") $count = 0 $building = "WILKES-BARRE" For $linecount = 0 To UBound($array4) - 1 $test7 = StringStripWS($array4[$linecount], 8) $result7 = StringCompare($string1, $test7, 2) If $result7 = 0 Then $count = $count + 1 If $count = 8 Then ExitLoop Next $test8 = StringStripWS($array4[$linecount + 2], 8) $result8 = StringCompare($string3, $test8, 2) If $result8 = 0 Then $temp4 = StringStripWS($array4[$linecount + 1], 8) $bu = StringTrimLeft($temp4, 6) GUICtrlSetData($message12, $bu) GUICtrlSetData($message13, $building) $linecount = $linecount + 1 ;MsgBox(0, "Test8", $linecount & ' ' & $building) _fileWritetoline($amosrce &"\slmpc.mif",$linecount, " Value = "& $building,1) Else $test9 = StringStripWS($array4[$linecount + 1], 8) $result9 = StringCompare($string3, $test9, 2) If $result9 = 0 Then GUICtrlSetData($message12, "none") GUICtrlSetData($message13, $building) $linecount = $linecount + 1 ;MsgBox(0, "Test9", $linecount & ' ' & $building) _fileWritetoline($amosrce &"\slmpc.mif",$linecount, " Value = "& $building,0) EndIf EndIf _FileReadToArray($amosrce & "\slmpc.mif", $array3) ;_ArrayDisplay($array3, "Array3") $count = 0 For $linecount = 0 To UBound($array3) - 1 $test10 = StringStripWS($array3[$linecount], 8) $result10 = StringCompare($string1, $test10, 2) If $result10 = 0 Then $count = $count + 1 If $count = 9 Then ExitLoop Next $test11 = StringStripWS($array3[$linecount + 2], 8) $result11 = StringCompare($string3, $test11, 2) If $result11 = 0 Then $lc = 123 $temp = StringStripWS($array3[$linecount + 1], 8) $fl = StringTrimLeft($temp, 6) GUICtrlSetData($message10, $fl) GUICtrlSetData($message11, $floor1) $linecount = $linecount + 1 ;MsgBox(0, "Test11", $linecount & ' ' & $floor1) _fileWritetoline($amosrce &"\slmpc.mif",$linecount, " Value = "& $floor1 ,1) Else $test12 = StringStripWS($array3[$linecount + 1], 8) $result12 = StringCompare($string3, $test12, 2) If $result12 = 0 Then $lc = 123 GUICtrlSetData($message10, "none") GUICtrlSetData($message11, $floor1) $linecount = $linecount + 1 ;MsgBox(0, "Test12", $linecount & ' ' & $floor1) _fileWritetoline($amosrce &"\slmpc.mif",$linecount, " Value = "& $floor1,0) EndIf EndIf _FileReadToArray($amosrce & "\slmpc.mif", $array5) $count = 0 For $linecount = 0 To UBound($array5) - 1 $test13 = StringStripWS($array5[$linecount], 8) $result13 = StringCompare($string1, $test13, 2) If $result13 = 0 Then $count = $count + 1 If $count = 10 Then ExitLoop Next $test14 = StringStripWS($array5[$linecount + 2], 8) $result14 = StringCompare($string3, $test14, 2) If $result14 = 0 Then $lc = 132 $temp7 = StringStripWS($array5[$linecount + 1], 8) $cu = StringTrimLeft($temp7, 6) GUICtrlSetData($message14, $cu) GUICtrlSetData($message15, $pcube) $linecount = $linecount + 1 _fileWritetoline($amosrce &"\slmpc.mif",$linecount, " Value = "& $pcube ,1) Else $test15 = StringStripWS($array5[$linecount + 1], 8) $result12 = StringCompare($string5, $test15, 2) If $result15 = 0 Then $lc = 132 GUICtrlSetData($message14, "none") GUICtrlSetData($message15, $pcube) $linecount = $linecount + 1 _fileWritetoline($amosrce &"\slmpc.mif",$linecount, " Value = "& $pcube,0) EndIf EndIf _FileReadToArray($amosrce & "\slmpc.mif", $array5) ;_ArrayDisplay($array5,"MIF File") Sleep(8000) DriveMapDel($amosrce) _SelfRestart() EndFunc ;==>Modmif Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==>_SelfRestart Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $From = BitAND($wParam, 0xFFFF) Local $Code = BitShift($wParam, 16) Local $Data Switch $Code Case $EN_CHANGE Switch $From Case $cube1 $Data = StringLeft(StringRegExpReplace(StringUpper(GUICtrlRead($From)), '[^A-E]', ''), 1) If $Data Then _WinAPI_SetFocus(GUICtrlGetHandle($cube2)) EndIf Case $cube2, $cube3 $Data = StringLeft(StringRegExpReplace(GUICtrlRead($From), '[^\d]', ''), 2) If (StringLen($Data) = 2) And ($From = $cube2) Then _WinAPI_SetFocus(GUICtrlGetHandle($cube3)) EndIf Case Else Return $GUI_RUNDEFMSG EndSwitch GUICtrlSetData($From, $Data) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND
  5. I am trying to figure out if this is possible. I am using a GUICTRLCreateInout, but I want to have input in the format of A-13-1 when the first character has to be uppercase A,B,C,D, or E then a "-", the a number ranging from 01 to 13 and then a "-" and finally a digit from 01 to 28. I have used the $ES_NUMBER so digits can be type, but I would like to control the input as explained above. Is that possible and how can it be done ? Any assistance would be greatly appreciated.
  6. 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. #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
  7. How would I stop the current instance and start a new one ?
  8. Last question I hope !!!! How can I control or reset the whole gui once you click the last button and the work iss taken care of? I basically want to refresh the whole form as if it was just openened. Any help would be greatly appreciated. Thanks, #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) 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("Building: ", 285, 250, 63, 17) $Label8 = GUICtrlCreateLabel("Floor: ", 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("Building: ", 285, 360, 63, 17) $Label12 = GUICtrlCreateLabel("Floor: ", 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) GUICtrlSetData($computer,"") GUICtrlSetState($computer, $GUI_FOCUS) 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) While StringLen($pprimuser) < 7 $pprimuser=GUICtrlRead($primeuser) ;sleep(4000) WEnd GUIctrlsetstate($floor, $gui_enable) GUICtrlSetState($floor, $GUI_FOCUS) While not ($floor1 = 1 or $floor1=2) $floor1=GUICtrlRead($floor) WEND GUICtrlSetState($Button3, $gui_enable) EndFunc func Modmif() GUICtrlSetState($Button3, $gui_disable) GUISetState($primeuser, $gui_disable) GUISetState($floor, $gui_disable) Dim $array1, $array2, $array3 if FileExists ($amosrce &"\slmpc.mif") Then MsgBox(0, $amosrce &"\slmpc.mif","File exists") Else MsgBox(0, $amosrce &"\slmpc.mif","File does not exists") EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array1) _ArrayDisplay($array1,"MIF File") $string1="Access=Write-Only" $string2="Value=" $string3="EndAttribute" $test1=StringStripWS($array1[21],8) $result=StringCompare($string3, $test1, 2) if $result = 0 then $message6 = GUICtrlCreateLabel("none", 350, 210, 570, 20) $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17) _FileWriteToLine($amosrce &"\slmpc.mif",21," Value = "& '"'&$pcostcenter&'"',0) else $temp=StringStripWS($array1[21],8) $cc=StringTrimLeft($temp,6) msgbox(0,"",$pcostcenter) $message6 = GUICtrlCreateLabel($cc, 350, 210, 570, 20) $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17) _FileWriteToLine($amosrce &"\slmpc.mif",21," Value = "& '"'&$pcostcenter&'"',1) EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array2) _ArrayDisplay($array2,"MIF File") $test2=StringStripWS($array2[39],8) $result2=Stringcompare($string3, $test2,2) if $result = 0 Then $message8 = GUICtrlCreateLabel("none", 350, 230, 570, 20) $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20) _fileWritetoline($amosrce &"\slmpc.mif",39, " Value = "& '"'&$pprimuser&'"',1) 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") ;add some more code for the two remaining fields...... sleep(5000) 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) ;GUICtrlSetData($computer,"") ;GUICtrlSetState($computer, $GUI_FOCUS) EndFunc
  9. I built this gui creating input using GUICTRLCREATE and reading input using GUICRLREAD statements. but I am looking for a way to clear a field or resting the field to nothing once the field has been used. Any help would be greatly aprrecited. #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) 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("Building: ", 285, 250, 63, 17) $Label8 = GUICtrlCreateLabel("Floor: ", 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("Building: ", 285, 360, 63, 17) $Label12 = GUICtrlCreateLabel("Floor: ", 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) While StringLen($pprimuser) < 7 $pprimuser=GUICtrlRead($primeuser) ;sleep(4000) WEnd GUIctrlsetstate($floor, $gui_enable) GUICtrlSetState($floor, $GUI_FOCUS) While not $floor1 > 3 $floor1=GUICtrlRead($floor) WEND GUICtrlSetState($Button3, $gui_enable) EndFunc func Modmif() GUICtrlSetState($Button3, $gui_disable) GUISetState($primeuser, $gui_disable) GUISetState($floor, $gui_disable) Dim $array1, $array2, $array3 if FileExists ($amosrce &"\slmpc.mif") Then MsgBox(0, $amosrce &"\slmpc.mif","File exists") Else MsgBox(0, $amosrce &"\slmpc.mif","File does not exists") EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array1) _ArrayDisplay($array1,"MIF File") $string1="Access=Write-Only" $string2="Value=" $string3="EndAttribute" $test1=StringStripWS($array1[21],8) $result=StringCompare($string3, $test1, 2) if $result = 0 then $message6 = GUICtrlCreateLabel("none", 350, 210, 570, 20) $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17) _FileWriteToLine($amosrce &"\slmpc.mif",21," Value = "& '"'&$pcostcenter&'"',0) else $temp=StringStripWS($array1[21],8) $cc=StringTrimLeft($temp,6) msgbox(0,"",$pcostcenter) $message6 = GUICtrlCreateLabel($cc, 350, 210, 570, 20) $message7 = GUICtrlCreateLabel($pcostcenter, 350, 320, 63, 17) _FileWriteToLine($amosrce &"\slmpc.mif",21," Value = "& '"'&$pcostcenter&'"',1) EndIf _FileReadToArray($amosrce &"\slmpc.mif",$array2) _ArrayDisplay($array2,"MIF File") $test2=StringStripWS($array2[39],8) $result2=Stringcompare($string3, $test2,2) if $result = 0 Then $message8 = GUICtrlCreateLabel("none", 350, 230, 570, 20) $message9 = GUICtrlCreateLabel($pprimuser,350, 340, 570,20) _fileWritetoline($amosrce &"\slmpc.mif",39, " Value = "& '"'&$pprimuser&'"',1) 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") ;add some more code for the two remaining fields...... sleep(5000) 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) EndFunc
  10. I spoke too soon. The ping doesnt work now.
  11. Thanks you very much using GUICtrlRead($computer) instead of $computer fixed it.
  12. 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. #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
  13. I am trying to do a controlclick on a popup to uninstall the novell client: I am using the following code: _rundos("%SystemRoot%\system32\rundll32 nwsetup.dll NWUninstallClient") If not Winactive("Uninstall Novell Client for Windows") then Winactivate("Uninstall Novell Client for Windows") ControlClick("Uninstall Novell Client for Windows", "&Yes", "[CLASS:Button; TEXT:&Yes; Instance:1]") Here is the capture from window info tool: >>>> Window <<<< Title: Uninstall Novell Client for Windows Class: #32770 Position: 24, 157 Size: 389, 119 Style: 0x94C801C5 ExStyle: 0x00010101 Handle: 0x0024011C >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Advanced (Class): [CLASS:Button; INSTANCE:1] ID: 6 Text: &Yes Position: 113, 60 Size: 75, 23 ControlClick Coords: 53, 14 Style: 0x50030001 ExStyle: 0x00000004 Handle: 0x002000DE >>>> Mouse <<<< Position: 193, 253 Cursor ID: 2 Color: 0xD4D0C8 >>>> StatusBar <<<< >>>> Visible Text <<<< &Yes &No Are you sure you want to uninstall the Novell Client for Windows? >>>> Hidden Text <<<< I am trying to click the yes button. Any help would be greatly appreciated. The command to uninstall the novell client is: %SystemRoot%\system32\rundll32 nwsetup.dll NWUninstallClient
  14. Hello, I have written a gui which creates an unattended xp install. During the processing of files while reading in arrays, the gui appears to not be doing anything. What can I do to give the impression that something is going on. There are periods of time that could be interpreted as hangs. Thank in advance for any help.
  15. Sorry I attached the file I manually corrected. Thanks, txtsetp3.txt
  16. I need to sort the enclosed file to be sorted by the number after the "=" sign. The following is a sample that is incorrect. CX_44973.inf= 1027,,,,,,,1027,0,0 ativvpxx.vp= 1028,,,,,,,1028,0,0 ativvaxx.dll= 1028,,,,,,,1028,0,0 ativvaxx.dat= 1028,,,,,,,1028,0,0 ativdkxx.vp= 1028,,,,,,,1028,0,0 ativckxx.vp= 1028,,,,,,,1028,0,0 ativcaxx.vp= 1028,,,,,,,1028,0,0 ativcaxx.cpa= 1028,,,,,,,1028,0,0 atitvo32.dll= 1028,,,,,,,1028,0,0 atipdlxx.dll= 1028,,,,,,,1028,0,0 atioglxx.dll= 1028,,,,,,,1028,0,0 atikvmag.dll= 1028,,,,,,,1028,0,0 atiiiexx.dll= 1028,,,,,,,1028,0,0 atiicdxx.dat= 1028,,,,,,,1028,0,0 atifglpf.xml= 1028,,,,,,,1028,0,0 atidemgx.dll= 1028,,,,,,,1028,0,0 atiddc.dll= 1028,,,,,,,1028,0,0 ati3duag.dll= 1028,,,,,,,1028,0,0 ati2mtag.sys= 1028,,,,,,,1028,0,0 ati2mdxx.exe= 1028,,,,,,,1028,0,0 ati2evxx.exe= 1028,,,,,,,1028,0,0 ati2evxx.dll= 1028,,,,,,,1028,0,0 ati2erec.dll= 1028,,,,,,,1028,0,0 ati2edxx.dll= 1028,,,,,,,1028,0,0 ati2dvag.dll= 1028,,,,,,,1028,0,0 ati2cqag.dll= 1028,,,,,,,1028,0,0 CX_44973.cat= 1027,,,,,,,1027,0,0 This is an example of how it should look. CX_44973.inf= 1027,,,,,,,1027,0,0 CX_44973.cat= 1027,,,,,,,1027,0,0 ativvpxx.vp= 1028,,,,,,,1028,0,0 ativvaxx.dll= 1028,,,,,,,1028,0,0 ativvaxx.dat= 1028,,,,,,,1028,0,0 ativdkxx.vp= 1028,,,,,,,1028,0,0 ativckxx.vp= 1028,,,,,,,1028,0,0 ativcaxx.vp= 1028,,,,,,,1028,0,0 ativcaxx.cpa= 1028,,,,,,,1028,0,0 atitvo32.dll= 1028,,,,,,,1028,0,0 atipdlxx.dll= 1028,,,,,,,1028,0,0 atioglxx.dll= 1028,,,,,,,1028,0,0 atikvmag.dll= 1028,,,,,,,1028,0,0 atiiiexx.dll= 1028,,,,,,,1028,0,0 atiicdxx.dat= 1028,,,,,,,1028,0,0 atifglpf.xml= 1028,,,,,,,1028,0,0 atidemgx.dll= 1028,,,,,,,1028,0,0 atiddc.dll= 1028,,,,,,,1028,0,0 ati3duag.dll= 1028,,,,,,,1028,0,0 ati2mtag.sys= 1028,,,,,,,1028,0,0 ati2mdxx.exe= 1028,,,,,,,1028,0,0 ati2evxx.exe= 1028,,,,,,,1028,0,0 ati2evxx.dll= 1028,,,,,,,1028,0,0 ati2erec.dll= 1028,,,,,,,1028,0,0 ati2edxx.dll= 1028,,,,,,,1028,0,0 ati2dvag.dll= 1028,,,,,,,1028,0,0 ati2cqag.dll= 1028,,,,,,,1028,0,0 CX_44973.cat= 1027,,,,,,,1027,0,0 Thank you in advance for any help provided in resolving my issue. txtsetp3.txt
  17. The problem is that I am not appending to the end of the file, but to a starting line number in the file.
  18. The following function works great, but it seems to overwrite the exising lines in a file. What I need it to do is not woverwrite the line, but add the line to the file starting with line number x. What needs to be done to accomplish this ? Thanks in advance for any help you can provide. Func _FileWriteToLineFromArray($hFile, $avArray, $nStartArray = 0, $nEndArray = -1, $nLineFile = -1) Local $sStringStore, $sRead, $sStartStore, $aSplit, $iCC, $nUBound = $nEndArray, $sEndStore If $nEndArray = -1 Then $nUBound = UBound($nEndArray) - 1 Switch $nLineFile Case -1 For $iCC = $nStartArray To $nUBound $sStringStore &= $avArray & @CRLF Next Return FileWrite($hFile, StringTrimRight($sStringStore, 2)) Case Else If $nLineFile > 1 Then $sRead = FileRead($hFile) $aSplit = StringSplit(StringStripCR($sRead), @LF) For $iCC = 1 To $nLineFile - 1 $sStartStore &= $aSplit[$iCC] & @CRLF Next For $iCC = $nLineFile To $aSplit[0] $sEndStore &= $aSplit[$iCC] & @CRLF Next $sEndStore = StringTrimRight($sEndStore, 2) Else FileClose(FileOpen($hFile, 2)) EndIf For $iCC = $nStartArray To $nUBound $sStringStore &= $avArray[$iCC] & @CRLF Next Return FileWrite($hFile, $sStartStore & StringTrimRight($sStringStore, 2) & $sEndStore) EndSwitch Return SetError(1, 0, 0) EndFunc
  19. Is it possible to write an array of directories to one line of text? If so does anyone have an idea how to accomplish this ? Thanks in advance for any help you can provide.
  20. Holy cow. That is much faster than doing one line at a time using for .. next. Thank you for your help !!!! Awesome job.
  21. I am feeding the following: file to add array array to read to write to file item in array to start from I am feeding 1 feeding -1 for end of array I am feeding a variable which is the starting line number to start the write unfortunately it is not working as of yet. I will continue to mess around with it.
  22. Can you give a brief explanation of each argument ? Thank You !!1
  23. I have text files that I need written to existing files I first read them into an array. The problem is that i determine what line to start writing to then write out one line at a time. Is there a function that you can write an array to a file by indicating the starting line. Second ? is that I need to apend an array to one line is there a way to accomplish this ? Thanks in advance for any help you can provide.
  24. Is there a way to delete duplicate lines in a text file ? I am having problem figuring out how to do that. Any help would be greatly appreciated.
  25. I cant find a function to list a directory structure and assign each subdir to an array. does anyone have an idea on how to accomplish this ? Meaning in you have a root directory d and many subdirectories like d/1/a d/1/a/1 d/1/b I would like to assign each level to an array. Any help you provide would be greatly appreciated.
×
×
  • Create New...