Jump to content

Recommended Posts

Hi Guys

After searching this site and some experimenting, i have come up with code that does what i want,   ie closing the are you sure msg box in the form of yes and no after expressing the desire to close my program, its really annoying as i do this 20-30 times a day.

WinWait("[CLASS:#32770]", "&Yes")
ControlClick("[CLASS:#32770]", "&Yes", "Button1")

however as it stands i can only use it once before script disappears from my task bar and i have to run the script again from autoit editor.

Could someone help me keep the script alive and give me some hints on how i could perhaps use a hotkey press to activate and deactivate the script.

perhaps control ca for on and esc for off.

As i say the code itself works flawlessly its stopping starting and maintaining readiness i am struggling with.

Any and all help really appreciated.

 

 

 

Edited by invis2
Link to comment
Share on other sites

31 minutes ago, invis2 said:

WinWait("[CLASS:#32770]", "&Yes")
ControlClick("[CLASS:#32770]", "&Yes", "Button1")

If that is your entire script, it will execute, then wait until that WinWait is true (it becomes true as soon as that window exists), then continues to the ControlClick. As there is no further script after that, the script stops at that point.

What you need is a loop so that this procedure is repeated forever. Try putting your code in a loop:

While 1
    WinWait("[CLASS:#32770]", "&Yes")
    ControlClick("[CLASS:#32770]", "&Yes", "Button1")
     
    sleep(50) ; avoid high cpu usage
WEnd

Just like your script, it will execute, wait for that window, click that control once the window appears, but instead of exiting, the WEnd will make the script go back to the While as long as the expression that the While evaluates is true. (And "1" is a true expression so this will repeat forever.) Check the helpfile for "Language Reference - Loop Statements".

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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