Jump to content

need help looping this


gcue
 Share

Recommended Posts

i have a script that prompts a user on a remote machine before taking a screenshot.

then i put in a sleep(5000)

after the pause i check to see if the screenshot was taken (if *.jpg exists)

if *.jpg doesnt exist i shoot back an error that a screenshot could not be taken.

problem is if the user doesnt respond in 5 seconds then i error out.

the reason i had this for 5 seconds is because i have a version of this application that doesn't prompt the user - but now with prompt im not sure how to handle this.

-thanks.

[autoitscript]

Func Open()

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe") Then

FileDelete ( "\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe")

EndIf

FileCopy ("sc.exe", "\\" & GUICtrlRead($asset) & "\c$\temp",1)

RunWait(@ScriptDir & "\psexec.exe " & "\\" & GUICtrlRead($asset) & " -d -i c:\temp\sc.exe" )

Sleep(5000)

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg") Then

MsgBox(16, "Remote Screenshot", 'Permission for screenshot denied by ' & GUICtrlRead($asset))

Call("Cleanup")

EndIf

If FileExists ( "\\" & GUICtrlRead($asset) & "\c$\temp\" & "*" & GUICtrlRead($asset) & "*.jpg") Then

FileMove("\\" & GUICtrlRead($asset) & "\c$\temp\" & "*" & GUICtrlRead($asset) & "*.jpg", @ScriptDir & "\Screenshots\")

Run(@WindowsDir & "\explorer.exe " & @ScriptDir & "\Screenshots")

Else

MsgBox(16, "Remote Screenshot", 'Unable to take a screenshot from ' & GUICtrlRead($asset) &@CRLF & _

''&@CRLF & _

'Probable KNOWN reasons:'&@CRLF & _

''&@CRLF & _

'1. Asset is on CAD screen.'&@CRLF & _

'2. Bloomberg is the active window.')

EndIf

Call("Cleanup")

EndFunc

Func Cleanup()

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe") Then

FileDelete ( "\\" & GUICtrlRead($asset) & "\c$\temp\sc.exe")

EndIf

If FileExists ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg") Then

FileDelete ("\\" & GUICtrlRead($asset) & "\c$\temp\noss.flg")

EndIf

EndFunc

[/autoitscript]

Link to comment
Share on other sites

Try doing something like this:

Dim $MsgRes
$MsgRes = MsgBox(16+4, "Remote Screenshot", 'Unable to take a screenshot from ' & GUICtrlRead($asset) &@CRLF & ''&@CRLF & 'Probable KNOWN_ reasons:'&@CRLF & ''&@CRLF & '1. Asset is on CAD screen.'&@CRLF & '2. Bloomberg is the active window.' & @CRLF & 'Would You Like To Try Again?')
If $MsgRes = 6 Then Open()

This will prompt the person with a Yes/No MessageBox and record the answer to the message box in the variable $MsgRes If they click Yes $MsgRes will be set to 6 and that will recall the function.

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Link to comment
Share on other sites

thanks!

Try doing something like this:

Dim $MsgRes
$MsgRes = MsgBox(16+4, "Remote Screenshot", 'Unable to take a screenshot from ' & GUICtrlRead($asset) &@CRLF & ''&@CRLF & 'Probable KNOWN_ reasons:'&@CRLF & ''&@CRLF & '1. Asset is on CAD screen.'&@CRLF & '2. Bloomberg is the active window.' & @CRLF & 'Would You Like To Try Again?')
If $MsgRes = 6 Then Open()

This will prompt the person with a Yes/No MessageBox and record the answer to the message box in the variable $MsgRes If they click Yes $MsgRes will be set to 6 and that will recall the function.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...