Jump to content

Help in while loop ending


sathish
 Share

Recommended Posts

Hello Guys

I am new to autoit

I need a help, my problem is mentioned below

While 1

If WinActive("MathType Warning") Then

ControlClick("MathType Warning", "OK", "[iD:2]")

EndIf

WEnd

The code is pasted above

Description: The window named MathType Warning will occur unknown number of times while opening a another window, so that i need to send {ENTER} unknown number of times, so how can i do it, the thing is when that window is not there, i have to close the loop and proceed further, simply to say (until MathType Warning disappears)

Edited by sathish
Link to comment
Share on other sites

  • Moderators

sathish,

Welcome to the AutoIt forum. ;)

Please do not bump your own posts within 24 hours. :)

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually - like this. :)

As you have no idea how many times this window will appear, take a look at Adlib in the Help file. It allows you to call a function at regular intervals - you could check every few seconds whether your warning dialog was present and clear it if found. Once you are sure that there will be no more, you can cancel the Adlib function. See what you can come up with - you know where we are if you run into difficulties. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for your kind reply Melba

Sorry I am new to this forum

The thing is i want to know about GOTO loop in autoit, basically i am from perl

Below is my perl code, But the thing is i want it in Autoit

while(1)

{

my $windows = FindWindowLike(undef, "MathType Warning");

if($windows == 1)

{

print F3 "$img: Font Missing in MathType, please checkn";

PushButton("OK");

$windows++;

}

else

{

goto MAIN;

}

}

MAIN:

I think the ExitLoop will work in autoit, but i cant able to understand the concept of Exitloop

Please help

Link to comment
Share on other sites

  • Moderators

sathish,

The thing is i want to know about GOTO loop in autoit

There is no GOTO instruction on AutoIt - it has been declared a "BAD THING" by the Devs. :)

I do not use perl, but if I understand the logic flow correctly, something like this should work for you:

$iDelay = 25 ; Number of seconds to wait before continuing

$iBegin = TimerInit()

; We now enter this loop for $iDelay seconds
While TimerDiff($iBegin) < $iDelay * 1000
    
    ; Check for an error window
    If WinExists("MathType Warning") Then
        ; Click it
        ControlClick("MathType Warning", "", "[TEXT:OK]"
    EndIf
    
    Sleep(10) ; Idle the CPU to stop it overloading
    
WEnd

; After $iDelay seconds you end up here

If there is a maximum number of times the dialog can appear, you could add count and use ExitLoop when you have reached that value. You might want to check the dialog with the Window Info tool to confirm the ID parameters I used - you will find it at "C:\Program Files\AutoIt3\Au3Info.exe" if you did a standard install. :D

Try to develop that and see how you get on. You know where we are if you run into difficulties. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for your reply Melba

your Code

while---

{

; Check for an error window

If WinExists("MathType Warning") Then

; Click it

ControlClick("MathType Warning", "", "[TEXT:OK]"

EndIf

; till this everything is ok, here i want to exit the while loop, thats what i am asking for

; (Else exitloop), when window not available like this i need

Sleep(10) ; Idle the CPU to stop it overloading

WEnd

If you see my perl code, you can undertstand

The script you have given me is working perfectly, but the script should close until all window (MathType Warning) and when the next window (MathType Text) appears

Edited by sathish
Link to comment
Share on other sites

  • Moderators

sathish,

If you see my perl code, you can undertstand

No I cannot - I told you I do not use perl. ;)

But now you have explained further I think this should work:

; Enter an infinite loop
While 1

    ; Check for an error window
    If WinExists("MathType Warning") Then
        ; Click it
        ControlClick("MathType Warning", "", "[TEXT:OK]"
    EndIf
    
    ; Check if the required window appears
    If WinExists("MathType Text") Then
        ; And exit the loop if it does
        ExitLoop
    EndIf

    Sleep(10) ; Idle the CPU to stop it overloading

WEnd

; You end up here when the "MathType Text" window appears

I hope it works for you. :)

Top Tip: Give as much information as you can at the beginning - then we can give you what you want. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks Melba

Still have some problems

I will explain my perl code line by line, then you can understand my problem

while(1); This you know,

{

my $windows = FindWindowLike(undef, "MathType Warning");; Here Winexists is applied

if($windows == 1); If winExists

{

PushButton("OK");;;Send ("OK")

$windows++;; Here the window value is incremented

}

else;

{

goto MAIN;;; Exiting the while loop, when Window does not exist

}

}

MAIN:

Link to comment
Share on other sites

I think the ExitLoop will work in autoit, but i cant able to understand the concept of Exitloop

It exits the loop. There isn't more to understand. See helpfile for details.

Or you could just loop as long as WinExist() is true.

While WinExist()
    ControlSend()
Wend
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...