Jump to content

How to do this without a GoTo Function?


Recommended Posts

I know the new functions are so much better, but I miss the simplicity of the GoTo function =).

I'm having a slight problem and I have no idea how to go around it without the use of GoTo. My new script is a little buggy, for some reason sometimes it misses key presses. It's very rare but I cannot have any mistakes as they could result in the wrong key press sequence.

Anyway below is an example of want I want to use to check if the action took place. The action key is pressed resulting in the movement of the mouse highlighting the next button. I want to use this mouse movement to my advantage and use it to check if the action took place. Ok here how I'm doing this.

Action

Send("{ENTER}");
check();

Check

Func check()
$counter = 0;
Do
Sleep(100);
$pos = MouseGetPos();
$counter = $counter + 1;

If $counter = 15 Then
exit;
EndIf

Sleep(100);
Until $pos[0] = 269 AND $pos[1] = 63;
$counter = 0;
EndFunc

The above will press ENTER and check if the mouse has moved as a result of a succesful key press. If the mouse has moved, the script will continue. If not then the script will exit.

I want to go one more step with this. Instead of exiting the script, I want it to re-do the action. So if the key press is missed, it'll try again and then and only then after a 2nd unsuccesful attempt I want it to exit.

If I could use the GoTo function, an unsucessfull attempt would just go back before the Action and run it a 2nd time but without it I don't know how to continue. I have an idea but I don't know how to go about doing this. If I can get the script to remember the action (store it in memory) and then be able to use the last stored action in my check function, it would be able to redo the last action.

Any ideas how I would be able to store the wanted action into memory in order to use it later in the script?

Edited by ravenfyre
Link to comment
Share on other sites

I know the new functions are so much better, but I miss the simplicity of the GoTo function =).

I'm having a slight problem and I have no idea how to go around it without the use of GoTo.  My new script is a little buggy, for some reason sometimes it misses key presses.  It's very rare but I cannot have any mistakes as they could result in the wrong key press sequence.

Anyway below is an example of want I want to use to check if the action took place.  The action key is pressed resulting in the movement of the mouse highlighting the next button.  I want to use this mouse movement to my advantage and use it to check if the action took place.  Ok here how I'm doing this.

Action

Send("{ENTER}");
check();

Check

Func check()
$counter = 0;
Do
Sleep(100);
$pos = MouseGetPos();
$counter = $counter + 1;

If $counter = 15 Then
exit;
EndIf

Sleep(100);
Until $pos[0] = 269 AND $pos[1] = 63;
$counter = 0;
EndFunc

The above will press ENTER and check if the mouse has moved as a result of a succesful key press.  If the mouse has moved, the script will continue.  If not then the script will exit.

I want to go one more step with this.  Instead of exiting the script, I want it to re-do the action.  So if the key press is missed, it'll try again and then and only then after a 2nd unsuccesful attempt I want it to exit.

If I could use the GoTo function, an unsucessfull attempt would just go back before the Action and run it a 2nd time but without it I don't know how to continue.  I have an idea but I don't know how to go about doing this.  If I can get the script to remember the action (store it in memory) and then be able to use the last stored action in my check function, it would be able to redo the last action.

Any ideas how I would be able to store the wanted action into memory in order to use it later in the script?

I like

do

mystuff

until this happens

some prefer

while 1

if this happens then

exitloop

endif

wend

; Rick

Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Link to comment
Share on other sites

Take a look at the ContinueLoop keyword as well.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

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