surreal Posted November 6, 2009 Share Posted November 6, 2009 im having a few issues with my gui that i cannot figure out. i have a splash during the ping process, incase it takes awhile the user does not think the program has hung, and keeps them from clicking connect twice. when i click on connect the splash will popup and display querying network if the correct name is entered and the ping is successful then the splash goes away and the txt will change and turn green. but: if you enter in a remote computer name that is incorrect and the ping is unsuccessful then the splash will not go away, but the txt does change. i think is has to do where i putting the code, not sure. thanks everyone for your help with this! d@ve expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> #include <HKCUReg.au3> ;===Checks Local OSVersion Create Var User Friendly================================================ $OS = @OSVersion $OS = StringReplace($OS, "WIN_VISTA", "Windows Vista") $OS = StringReplace($OS, "WIN_XP", "Windows XP") $OS = StringReplace($OS, "WIN_2000", "Windows 2000") ;===Determines Documents Location According To OS++================================================ $OSDOC = @OSVersion If $OSDOC = "WIN_VISTA" Then $DOC = "\Users\" If $OSDOC = "WIN_XP" Then $DOC = "\Documents and Settings\" EndIf $OSDF = @OSVersion If $OSDF = "WIN_VISTA" Then $DF = "Documents" If $OSDF = "WIN_XP" Then $DF = "My Documents" EndIf GUICreate("", 330, 145, -1, -1) ;===GUI Network Computer To Tranfer From=========================================================== GUICtrlCreateGroup("System", 10, 10, 190, 75) GUICtrlCreateLabel("Computer Name:", 20, 25) $cnTarget = GUICtrlCreateInput(@ComputerName, 20, 40, 120, 20) $cnMessage = GUICtrlCreateLabel("Enter computer name or ip address", 20, 64, 175, 15) $cnButton = GUICtrlCreateButton("Connect", 145, 35, 50, 25, $WS_GROUP) ;===GUI Network User Profile======================================================================= GUICtrlCreateGroup("Profile:", 10, 90, 190, 45) $prCombo = GUICtrlCreateCombo("", 20, 105, 175, 20) ;===GUI Group What To Migrate====================================================================== GUICtrlCreateGroup("Tranfer", 210, 10, 110, 80) $BoxMap = GUICtrlCreateCheckbox("Mapped Drives", 220, 25) $BoxPrinter = GUICtrlCreateCheckbox("Printers", 220, 45) $BoxWireless = GUICtrlCreateCheckbox("Wireless", 220, 65) ;===GUI Start Function============================================================================= $StartButton = GUICtrlCreateButton("Start", 230, 100, 65, 30, $WS_GROUP) GUISetState(@SW_SHOW) ;===Start Of GUIGetMsg============================================================================= While 1 $msg = GUIGetMsg() Select ;===Case For Exit GUI============================================================================== Case $msg = $GUI_EVENT_CLOSE $Close = MsgBox(4, "", "Are you sure you want to exit?") If $Close = 6 Then GUIDelete() Exit EndIf ;===Case For Connect=============================================================================== Case $msg = $cnButton If GUICtrlRead($cnTarget) = '' Then GUICtrlSetData($cnMessage, 'Target machine must be entered') GUICtrlSetColor($cnMessage, 0xFF0000) ContinueLoop EndIf Connect() Case $msg = $StartButton StartButton() EndSelect WEnd ;===Function For Remote System InfoBox============================================================= Func Connect() Local $Separator = "------------------------------" SplashTextOn("", "Querying Network", 165, 40, -1, -1, 2, "", 9) Sleep(1000) If Ping(GUICtrlRead($cnTarget)) Then $strComputer = GUICtrlRead($cnTarget) $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") SplashOff() If Not IsObj($objWMIService) Then GUICtrlSetData($cnMessage, 'Failed to connect to system') GUICtrlSetColor($cnMessage, 0xFF0000) Return EndIf ;===WMI BIOS $colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_Bios") $message = "System Info for " & $strComputer & @CRLF & $Separator & @CRLF & @CRLF For $objItem In $colItems1 $message &= "Dell Asset Number: " & $objItem.SerialNumber & @CRLF & _ "Manufacturer: " & $objItem.Manufacturer & @CRLF & @CRLF Global $surreal = $objItem.SerialNumber Global $RemoteName = $strComputer Next ;===WMI NETWORK $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For $objItem In $colItems2 $message &= "IP Address: " & $objItem.IPAddress(0) & @CRLF & _ "IP Subnet: " & $objItem.IPSubnet(0) & @CRLF & @CRLF Next ;===WMI SYSTEM $colItems3 = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") For $objItem In $colItems3 $message &= "Model: " & $objItem.Model & @CRLF & _ "Computer Name: " & $objItem.Name & @CRLF & _ "Last User: " & $objItem.UserName & @CRLF Global $RemoteUser = $objItem.UserName Next GUICtrlSetData($cnMessage, 'Connected, select user profile') GUICtrlSetColor($cnMessage, 0x008000) MsgBox(64, "System Information", $message) Else GUICtrlSetData($cnMessage, 'Target system could not be contacted') GUICtrlSetColor($cnMessage, 0xFF0000) Return EndIf Profile() EndFunc ;==>Connect ;===Function For Remote Profile Load=============================================================== Func Profile() Local $combo_string = "" $FolderList = _FileListToArray("\\" & GUICtrlRead($cnTarget) & "\c$" & $DOC, "*", 2) For $i = 1 To $FolderList[0] Switch $FolderList[$i] Case "All Users", "Default User", "LocalService", "NetworkService" ContinueLoop Case Else If $i = $FolderList[0] Then $combo_string &= $FolderList[$i] Else $combo_string &= $FolderList[$i] & "|" EndIf EndSwitch Next GUICtrlSetData($prCombo, $combo_string) EndFunc ;==>Profile ;===Function For Checkbox Actions================================================================== Func StartButton() ;===Mapped Drives If GUICtrlRead($BoxMap) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Drives") Mapped() EndIf ;===Printers If GUICtrlRead($BoxPrinter) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Printers") Printers() EndIf ;===Wireless Settings If GUICtrlRead($BoxWireless) = $GUI_CHECKED Then DirCreate("c:\Temp\Migrate\Wireless") EndIf SoundPlay(@WindowsDir & "\media\tada.wav",1) $Success = MsgBox(4, "", "Migration Was Successful. Do You Want To Exit?") If $Success = 6 Then Exit EndFunc ;==>StartButton ;===Function For Save Printer Info File============================================================ Func Printers() Local $passet = GUICtrlRead($cnTarget) Local $pLocation = 'c:\Temp\Migrate\Printers\Printers.txt' $pFile = FileOpen($pLocation, 10) For $i = 1 To 25 $p = _HKCU_EnumVal("\\\" & $passet & "\Software\Microsoft\Windows NT\CurrentVersion\Devices", $i) $iProdp = 1 For $n = 1 To $p[0][0] $iProdp *= $p[$n][2] If $p[$n][2] = 0 Then $ppath = _HKCU_Read("\\\" & $passet & "\\" & $p[$n][1], "Devices") EndIf If StringRegExp($p[$n][1], "^\\\\(?!\\)") Then FileWriteLine($pFile, $p[$n][1] & "," & $ppath[1][1]) EndIf Next If $iProdp <> 0 Then ExitLoop Next EndFunc ;==>SavePrinter ;===Function For Mapped Drives===================================================================== Func Mapped() Local $asset = GUICtrlRead($cnTarget) Local $mapLocation = 'c:\Temp\Migrate\Drives\Drives.txt' $mapFile = FileOpen($mapLocation, 10) For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $asset & "\Network", $i) $iProd = 1 For $j = 1 To $b[0][0] $iProd *= $b[$j][2] If $b[$j][2] = 0 Then $path = _HKCU_Read("\\\" & $asset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") FileWriteLine($mapFile, $b[$j][1] & "," & $path[1][1]) EndIf Next If $iProd <> 0 Then ExitLoop Next EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2009 Moderators Share Posted November 6, 2009 surreal,A quick look at your script suggests that you only use SplashOff if the ping is successful. You need to add another SplashOff after the Else in line 109.Could I suggest using Tidy (Ctrl-T in SciTE or under the <Tools> menu)? It is then immediately obvious that the only SplashTextOn is on a different indent to the SplashOff. 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...
surreal Posted November 6, 2009 Author Share Posted November 6, 2009 that did the trick, thank you, i will use tidy 4 now on, thanks again d@ve 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