dogscripter

Another topic about exiting from a loop function

4 posts in this topic

#1 ·  Posted

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted

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)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

-snip-

Here u go the source code.

Edited by Jos

Share this post


Link to post
Share on other sites

#4 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.