Jump to content

Not closing


Recommended Posts

I have a script that works everytime I test it on my machine. So I compiled it.

I have in wrapped up inside another exe created in a different language.

When launched through there 80% of the time it doesn't do what it is supposed to do.

I've tried changing the "matchmodes" to 1, 2, and 3 but doesn't seem to help.

I've tried adding various amounts of 'sleep' between actions in case it was going to fast?

The code is shown below.

Basically I want to kick off an uninstall, during this process I get two prompts that I can't get rid of using a command line. I want those to say yes, uninstall this product, and ok to the final dialog.

The first dialog No is highlighted to begin with. I tried doing an alt Y to select yes, but didn't work so now I do a tab and enter.

Like I said if I run this script stand alone it works, so not sure why when launched through another exe it doesn't? I'm even trying to regain focus if that is the reason?

What I see though is the uninstall starts, the first dialog kicks off and then just sits there... the autoit icon in the tray and will just cntinue to sit there for ever. even with my ",60" there it never will do (or maybe it already did too soon) the tab, enter? If I press it myself, then it continues then if it is less than 60 seconds, when the other dialog opens it does work.

So I'm guessing even though I don't see it, and even though I'm specifying the text, for some reasont he tab, enter is going to soon?

Anyway if anyone has some suggestions for me please let me know.

OH and sometimes if this runs on a machien I get a prompt saying that this product can't be uninstalled because it is not installed... I tried doing the AdlibEnable("myadlib1") thing but couldn't get it to work, in fact nothign worked when I tried it? My guess is I don't really know how to have it work? I tried putting the function call at the top of the script so it would start listening from the begining, but then it wouldn't do the rest of my script if it was installed, ... Do I need to put an exit right below the adlibenable? or does that exit the whole script?

Thanks,

AutoItSetOption ( "TrayIconDebug", 1)

Opt ( "WinTitleMatchMode", 2 )

Opt ( "WinTextMatchMode", 2 )

Run ("rundll32 C:\PROGRA~1\Novell\NOVELL~1\nippppi.dll,iPrintAdminRightsCheck", "", @SW_MAXIMIZE)

Sleep (1000)

WinWait ("iPrint", "This will remove iPrint from your computer. Do you wish to proceed?", 60)

WinActivate ("iPrint", "This will remove iPrint from your computer. Do you wish to proceed?")

Send ("{TAB}")

Sleep (300)

Send ("{ENTER}")

WinWait ("iPrint", "iPrint has been successfully uninstalled from your machine.", 60)

WinActivate ("iPrint", "iPrint has been successfully uninstalled from your machine.")

Sleep (500)

Send ("{ENTER}")

Exit

Link to comment
Share on other sites

Welcome to the forums.

My first suggestion is to use the AutoIt Window Info tool (AU3Info.exe) to get the exact window text and the control names of the buttons you wish to press.

Interacting directly with the controls is much more reliable than sending keys, and doesn't require the window to be active or visible.

The following code should serve as an example of ControlClick() and AdlibEnable().

AutoItSetOption("TrayIconDebug", 1)
Opt("WinTitleMatchMode", 2)
Opt("WinTextMatchMode", 2)

local $sWinTitle = "iPrint"
Local $sPromptText = "This will remove iPrint from your computer. Do you wish to proceed?"
Local $sConfirmText = "iPrint has been successfully uninstalled from your machine."

AdlibEnable("_CheckForError")
Run("rundll32 C:\PROGRA~1\Novell\NOVELL~1\nippppi.dll,iPrintAdminRightsCheck", "", @SW_MAXIMIZE)

WinWait($sWinTitle, $sPromptText, 60)
If WinExists($sWinTitle, $sPromptText) Then
    ControlClick($sWinTitle, $sPromptText, "Button1"); Use AU3Info to get the control name
    WinWait($sWinTitle, $sConfirmText, 60)
    If WinExists($sWinTitle, $sConfirmText) Then
        ControlClick($sWinTitle, $sConfirmText, "Button1"); Use AU3Info to get the control name
    EndIf
EndIf

Func _CheckForError()
    Local $sErrorText = "product is not installed"; Replace this with the message text
    If WinExists($sWinTitle, $sErrorText) Then
        ControlClick($sWinTitle, $sErrorText, "Button1"); Use AU3Info to get the control name
        Exit
    EndIf
EndFunc  ;==>_CheckForError

Edit: AutoIt syntax coloring... I guess it's been awhile.

Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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...