|
-
Jan 15th, 2005, 10:15 AM
#1
Thread Starter
Member
Cancel button help
Well, this is similar to my other thread. Anyways, I want to have a "stop" or "cancel" button, that immediately stops the loop where it is. Not when it finishes.
Here is my current code:
VB Code:
Private Sub start_Click()
stopp = True
Do Until stopp = False
If stopp = False Then
Exit Do
End If
DoEvents
EventPause ("5")
SendKeys ("message")
EventPause ("1")
SendKeys ("message1")
EventPause ("1")
SendKeys ("message2")
EventPause ("1")
SendKeys ("message3")
EventPause ("1")
SendKeys ("message4")
EventPause ("1")
SendKeys ("message5")
EventPause ("1")
SendKeys ("message6")
EventPause ("1")
SendKeys ("message7")
EventPause ("1")
SendKeys ("message8")
EventPause ("1")
SendKeys ("message9")
EventPause ("1")
SendKeys ("message10")
EventPause ("1")
SendKeys ("message11")
EventPause ("1")
DoEvents
Loop
End Sub
'Cancel button
Private Sub Command1_Click()
stopp = False
End Sub
However, this only stops the loop once it is completed and back to the start. Maybe I am using DoEvents wrong? Could somone please modify my code so the split second the "stop" button is pushed the loop stops?
Again: it stops fine, but only once the loop is completed. I want to stop mid-loop the second the stop button is pushed.
Thanks!
-
Jan 15th, 2005, 10:26 AM
#2
Re: Cancel button help
if you put your stopp test between every line it will stop befor the next
VB Code:
Private Sub start_Click()
stopp = True
Do Until stopp = False
If stopp = False Then Exit Do
DoEvents
EventPause ("5")
If stopp = False Then Exit Do
SendKeys ("message")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message1")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message2")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message3")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message4")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message5")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message6")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message7")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message8")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message9")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message10")
EventPause ("1")
If stopp = False Then Exit Do
SendKeys ("message11")
EventPause ("1")
If stopp = False Then Exit Do
DoEvents
Loop
End Sub
rgds pete
-
Jan 15th, 2005, 10:30 AM
#3
Thread Starter
Member
Re: Cancel button help
What if one of my SendKeys were say 1,000 charectors+ and it took a fair bit of time, and I wanted to stop mid-way through the send keys?
If possible I want to be able to stop the EXACT second without it processing anything further... possible?
Isn't there like a "Kill" all active processes in the program, so it stops everything and just returns to idle?
-
Jan 15th, 2005, 10:43 AM
#4
Re: Cancel button help
if you want to stop in the middle of prossesing a single instruction, there maybe a way to do it useing an api call
the only other way is to end your program, which is not a good way to do anything and other members here will say don't do that, otherwise it has to finish each instruction before it can process the next, exit loop
p.
-
Jan 15th, 2005, 10:46 AM
#5
Thread Starter
Member
Re: Cancel button help
Any idea what the API call is?
-
Jan 15th, 2005, 11:01 AM
#6
Re: Cancel button help
sorry can't help with that, only said there maybe an api
the only way i can think of to make it work would be to put it in a timer, so that it is looping separatly to the loop you are processing
p.
-
Jan 15th, 2005, 02:36 PM
#7
Re: Cancel button help
You would want Sendmessage. Find it here
http://www.mentalis.org/apilist/SendMessage.shtml
EDIT: I thought that this might help you.
You could have a generic subroutine that sends your values a character at a time, all the while checking for the STOP flag.
Last edited by dglienna; Jan 15th, 2005 at 06:39 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|