Jump to content

Another topic about exiting from a loop function


Recommended Posts

Hello everyone, I'm new user, this is my first post so welcome  :) I hope to have a great time.

So, I always read about interesting topics and learned many things, even if my programming skill is like 1/10 compared to some usere here, but I'm kinda happy of the small work I'm doing with autoit overall.

Yesterday I started a new project, implementing the GUI interface with KODA with some buttons, for the first time.. very intuitive and easy to understand I must say. Though, I ran into a problem, I searched on web, there are many topics even here but because of my low knowledge I don't understand the solution at 100% .

Basically time ago I made a very simple bot kinda like this that was running on background: My aim was to press "W" every 1minute on the Notepad application, until closed from the tray icon bar.

while 1=1
    ControlSend("Notepad", "", "", "{w}")
    sleep (60000) ; waits 1 minute
WEnd

Now I want to do the same function, but controlled by two buttons, start and stop so I created

$startbutton = GUICtrlCreateButton("Start", 145, 88, 49, 25)
$stopbutton = GUICtrlCreateButton("Stop", 145, 115, 49, 25)

Case $startbutton
    Call ("loop")

Where "loop" is the loop function created before the "GUI while 1".

Problem obviously is when i click start, it calls the function "loop" who has itself a while 1=1 and a sleep inside, so the only way to stop it closing the program with alt f4, the

Case $stopbutton

can't operate since the program is running a while loop with a sleep, outside the gui table.

Any easy way to fix this? I maybe be succesfull with an hotkey, but I want to press a "stop" button somewhere in the form, rather then pressin a physical key on my keyboard.

Hope you understand me, thanks for any help, appreciated! Have a good day.

Link to comment
Share on other sites

Post your whole script.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Developers
41 minutes ago, dogscripter said:

bots\autoit\wow\wow bot\whb.kxf

You nearly made it generic enough ... but forgot that file path. Oh well ... shit happens so here goes:

@dogscripter,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. (there is also a link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...