473,473 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

stopping a running script with a keypress

21 New Member
Hey,

I have a problem with a small program that I want to make. It's a script that keeps running by using a Do While loop. I want to stop the script when a certain key is pressed. But the problem is that the keypress sub isn't working because the other sub keeps running. Is there a way of doing this, or is there someone who knows how to replace the do while with the use of a timer or someting, so that I can make a pause between every run of my script.

Thanks already
Dec 10 '07 #1
4 1811
kadghar
1,295 Recognized Expert Top Contributor
Hey,

I have a problem with a small program that I want to make. It's a script that keeps running by using a Do While loop. I want to stop the script when a certain key is pressed. But the problem is that the keypress sub isn't working because the other sub keeps running. Is there a way of doing this, or is there someone who knows how to replace the do while with the use of a timer or someting, so that I can make a pause between every run of my script.

Thanks already
hmmm, try with DoEvents.

HTH
Dec 10 '07 #2
Bullitt
21 New Member
I don't have any experience with that :-s, And I looked on google know but the first pages I found all used DoEvents with visual basic.Net. But is it also working in VB 6, because then I will continue my search.

But s small other question, can I vb executable close another running executable, because otherwise a make a small exe with only the keypress and the code for closing the other program. And in the other program, I just start the second program in the begin. Is this possible and how do I do this, because I can start something with shellexecute but i don't know how to close something.

thanks already fr you're fast support.
Dec 10 '07 #3
kadghar
1,295 Recognized Expert Top Contributor
I don't have any experience with that :-s, And I looked on google know but the first pages I found all used DoEvents with visual basic.Net. But is it also working in VB 6, because then I will continue my search.

But s small other question, can I vb executable close another running executable, because otherwise a make a small exe with only the keypress and the code for closing the other program. And in the other program, I just start the second program in the begin. Is this possible and how do I do this, because I can start something with shellexecute but i don't know how to close something.

thanks already fr you're fast support.
yes it's possible, but its easier using DoEvents
Lets make a little example.

create a label with caption = 1 and write:
Expand|Select|Wrap|Line Numbers
  1. private sub Label1_click()
  2. do
  3.     label1.caption = label1.caption +1
  4.     doEvents
  5. loop
  6. end sub
that will make the label increase its value as crazy when you click on it but you still can work with the rest of the form. That's what DoEvents is for. To do something else while a process is running.

then just put a command button with something like
Expand|Select|Wrap|Line Numbers
  1. private sub command1_click()
  2. end
  3. end sub
and you're done

HTH
Dec 10 '07 #4
Bullitt
21 New Member
Really thank you a lot, you're not only giving me the solution, but also explaining me in short what all things do.

Thanks a lot!!!
Dec 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bart Nessux | last post by:
Can Python be used to stop windows services? I'm writing a script to automaically remove some troublesome Symantec software, but before running the main removal script, I need to kill some...
14
by: Mark | last post by:
Hi, At the top of my php file I have got :- <body onblur="self.focus();"> so when I click off onto another window, my window comes back up in front which is perfect. The problem however, is...
6
by: Dave | last post by:
I have a situation where I want to react to a ctrl-click on a <span> and it works in Netscape and Firefox browsers but in IE I have a problem. In IE I do catch the ctrl-click but IE also renders...
23
by: ern | last post by:
I have a program that runs scripts. If the user types "script myScript.dat" the program will grab commands from the text file, verify correctness, and begin executing the script UNTIL... I need...
1
by: dfaber | last post by:
Aloha! I want to terminate a process/program from within a python script. For example, if I have a program say foo.sh that starts running, then I can run it from within a python script using...
4
by: brian | last post by:
i broke down where i think the problems areas would be. any help would be greatly appreciated. where the file is called <script type="text/javascript" src="k.js"> </script> the beginning...
6
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data...
5
tolkienarda
by: tolkienarda | last post by:
hi all i am trying to stop people from entering anything but numbers into a textbox. i have the code to make sure they have entered a number on each keypress event and now a msgbox appears if they...
2
by: Steve | last post by:
Hi All, I've been trying to come up with a good way to run a certain process at a timed interval (say every 5 mins) using the SLEEP command and a semaphore flag. The basic thread loop was always...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.