Sign in to follow this  
Followers 0
Enjoy

Help needed with Send-keys and While-Loop

8 posts in this topic

Hello,

we want to uninstall a program without typing any key.

Therefore we try to use the following Script. It runs very good until the main uninstall dialog should be closed via sending the ENTER-key. Where is the mistake??

Another problem is that the While-Loop will never end, although the process IsUn0407.exe isn't running anymore.

How would you do this via AdlibEnable for example??

;---Our previous code ---

While 1
    Sleep(500)
        ;Commit any message for deleting not used files...
         If WinWaitActive("Freigegebene Datei") Then
                 Send("!j")
     EndIf
        ;Commit the dialog where you can see, what the uninstall-process do (e.g. where the marks will be set when this certain action was done) [I hope you know what I mean.]
     If WinActive("Programme vom Computer entfernen") Then
         Sleep(1000)
            Send("{ENTER}")
        EndIf
     If NOT ProcessExists("IsUn0407.exe") Then
        Exit
    EndIf
Wend

;---Rest of code ---

Please help us, we are trying it for the last two days...

enjoy

Share this post


Link to post
Share on other sites



While 1
         If WinWaitActive("Freigegebene Datei") Then
                    Send("!j")
        EndIf
        If NOT ProcessExists("IsUn0407.exe") Then
        Exit
    EndIf
Wend
I removed the lines not neccessary to reproduce the problem.

I think your problem is WinWaitActive. I think you want to use WinActive.

Share this post


Link to post
Share on other sites

You also may want to search the help file for "control". Things like controlclick allow you to click a button without having to worry about the window having the focus. I found it far better than sending keys when practical.


CheersNobby

Share this post


Link to post
Share on other sites

hello sugi,

this loop is already working. we want to send the ENTER-Key to the last Dialog of uninstallation, where check marks are.

hello nobby,

ControlClick does not work, we checked every possibilty.

Enjoy.

Share this post


Link to post
Share on other sites

hello sugi,

this loop is already working. we want to send the ENTER-Key to the last Dialog of uninstallation, where check marks are.

hello nobby,

ControlClick does not work, we checked every possibilty.

The loop is not working or sending {ENTER} would work. WinWaitActive blocks the loop until the specified window comes up.

Besides I'm pretty sure ControlClick will work. Try the command ControlClick('Programme vom Computer entfernen', '', 'OK').

Share this post


Link to post
Share on other sites

Hello Enjoy,

Try inserting this code below the first EndIf. The 2nd If statement may not be true when executed too early.

WinWaitActive("Programme vom Computer entfernen")

Share this post


Link to post
Share on other sites

We got it:

While ProcessExists("IsUn0407.exe")
    While WinActive("Freigegebene Datei")
        If WinWaitActive("Freigegebene Datei") Then
           Sleep(500)
           Send("!j")
            EndIf
    Wend
    WinActivate("Programme vom Computer entfernen")
    If WinActive("Programme vom Computer entfernen") Then
         Sleep(5000)
            Send("{SPACE}")
        EndIf
     If NOT ProcessExists("IsUn0407.exe") Then
         MsgBox (4096,"test","Kill Script")
        Exit
    EndIf   
Wend

The point was to set Sleep(5000) before sending the SPACE, beacause the OK-Button was inactive !

Thanks for all replies !

Enjoy.

Share this post


Link to post
Share on other sites

We got it:

While WinActive("Freigegebene Datei")
        If WinWaitActive("Freigegebene Datei") Then
           Sleep(500)
           Send("!j")
               EndIf
    Wend
There's still the same bug in it. Now you're telling AutoIt to loop while a specific window is active and then if this window is active wait until the window that's already active is active.

Your solutions (adding a While, increasing the Sleep) are only dirty workarounds for this one small bug and are likely to cause problems e.g. if a computer is slower as you thought.

Share this post


Link to post
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
Sign in to follow this  
Followers 0