mtmartis Posted March 3, 2010 Share Posted March 3, 2010 I am trying to get a "Please Wait" window to appear and stay up until results I need are returned. Overall goal: Get a confimation box to pop up asking currently logged in user if they are they user who is currently logged in. Click script Gets username queries WMI for Full user name Message Box opens asking " You are about to continue install as "Full name". Are you sure you wish to continue? " Problem is, it takes a while for the results to appear, so I would like to put a 'Please Wait' until the message box appears. This way the user will know the script is "working". Not sure if I need to use the WinWait or what. Any guidance would be appreciated. $Var = GetFullName(@UserName) Func GetFullName($sUserName) $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name = '" & $sUserName & "'", "WQL", 0x10 + 0x20) If IsObj($colItems) then For $objItem In $colItems Return $objItem.FullName Next Else Return SetError(1,0,"") Endif EndFunc MsgBox(0,"","You are about to continue as: " & $var) Link to comment Share on other sites More sharing options...
Fulano Posted March 3, 2010 Share Posted March 3, 2010 Try this:SplashTextOn ("Retrieving Information", "Please wait ...", 200, 100, -1, -1, 32, "Georgia", 12) $Var = GetFullName(@UserName) SplashOff () Func GetFullName($sUserName) $colItems = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE Name = '" & $sUserName & "'", "WQL", 0x10 + 0x20) If IsObj($colItems) then For $objItem In $colItems Return $objItem.FullName Next Else Return SetError(1,0,"") Endif EndFunc MsgBox(0,"","You are about to continue as: " & $var) #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
mtmartis Posted March 4, 2010 Author Share Posted March 4, 2010 Thank you Fulano, it works perfectly,I see what it's doing now, I'm embarrased by the simplicity of it. I had the following, I'm sure the WinWait line is wrong on so many levels. SplashTextOn("IT Services","Please Wait...","125","30","-1","-1",2,"","","") WinWait($Var = GetFullName(@UserName)) SplashOff() Link to comment Share on other sites More sharing options...
Fulano Posted March 4, 2010 Share Posted March 4, 2010 Well ... not on so many levels, but yeah, it'd bork up your script something fierce. Here's why:For some reason, the makers of AutoIt have decided to use the same operator for assignment and testing for equality. So when AutoIt looks at your code it doesn't see this:WinWait (Set $Var to value returned by GetFullName(@UserName))It sees this:WinWait (Is $Var the same as the value returned by GetFullName (@UserName)?)Either way WinWait will be confused, because it expects a window title rather than what you are giving it. Sadly in this case $Var won't be set to GetFullName(@UserName), and anything that expects that to be the case further down the script will be disappointed.I'm not sure why they didn't follow the convention of using a double equals for testing (==) rather than the single, but I'm sure they have their reasons. #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! 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