473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Timed Recurring Key Press

I am looking at writing a program that presses a key ('A') every minute in whatever the focused window is. I am having trouble working out what command to use in the timer1_timer sub so that it presses A and then restarts the timer, what I have at the moment dosn't work. I am using Visual Basic 2005 Express

Here is the code

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     'timer enabled on click of start button
  3.     Private Sub cmdStart_Click()
  4.         Timer1.Enabled = True
  5.     End Sub
  6.     'timer stopped on click of end button
  7.     Private Sub cmdEnd_Click()
  8.         Timer1.Enabled = False
  9.     End Sub
  10.  
  11.     'send keys is activated every time the timer event occurs
  12.     'Restarts the timer
  13.     Private Sub Timer1_Timer()
  14.         SendKeys.Send("A")
  15.         Timer1.Enabled = True
  16.     End Sub
  17.  
  18.     Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
  19.  
  20.     End Sub
  21.     'Creates buble tooltip on mouse hover
  22.     Private Sub cmdStart_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdStart.MouseHover
  23.         toolTip.SetToolTip(cmdStart, "Click here to start the timer")
  24.     End Sub
  25.     'Creates bubble tooltip on mouse hover
  26.     Private Sub cmdEnd_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEnd.MouseHover
  27.         toolTip.SetToolTip(cmdEnd, "Click here to stop the timer")
  28.     End Sub
  29.    End Class
  30.  
Dec 28 '06 #1
2 2542
willakawill
1,646 1GB
I am looking at writing a program that presses a key ('A') every minute in whatever the focused window is. I am having trouble working out what command to use in the timer1_timer sub so that it presses A and then restarts the timer, what I have at the moment dosn't work. I am using Visual Basic 2005 Express

Here is the code

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     'timer enabled on click of start button
  3.     Private Sub cmdStart_Click()
  4.         Timer1.Enabled = True
  5.     End Sub
  6.     'timer stopped on click of end button
  7.     Private Sub cmdEnd_Click()
  8.         Timer1.Enabled = False
  9.     End Sub
  10.  
  11.     'send keys is activated every time the timer event occurs
  12.     'Restarts the timer
  13.     Private Sub Timer1_Timer()
  14.         SendKeys.Send("A")
  15.         Timer1.Enabled = True
  16.     End Sub
  17.  
  18.     Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
  19.  
  20.     End Sub
  21.     'Creates buble tooltip on mouse hover
  22.     Private Sub cmdStart_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdStart.MouseHover
  23.         toolTip.SetToolTip(cmdStart, "Click here to start the timer")
  24.     End Sub
  25.     'Creates bubble tooltip on mouse hover
  26.     Private Sub cmdEnd_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEnd.MouseHover
  27.         toolTip.SetToolTip(cmdEnd, "Click here to stop the timer")
  28.     End Sub
  29.    End Class
  30.  
Hi. You are mixing your compilers :)
vb6 and vb2005 are different beasts. vb2005 is .NET

You have 2 cmdStart_Click event handlers in your code. In .NET you will need to go with the flow. Select the control name at the top left of the IDE and select the event handler at the top right. Let .NET do the work.
Dec 28 '06 #2
I never realised, would explain why thing where different, I just though it was an updated version of VB since i last used it!! ill post in the .NET forums, thanks
Dec 29 '06 #3

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

Similar topics

5
by: Shabam | last post by:
I'm having a calendar feature developed whereby users can add recurring events. These recurring events can have start and end dates, meaning they will recur only within a date range. For...
5
by: gil | last post by:
I initially tried building a coded system where numbers 1 through 10 referenced a certain type of recurring appointment, and would then call a specific function for each, but as more appointments...
2
by: Javaman59 | last post by:
I have a GUI which is monitoring a real-time device. I have several timed actions, such as periodic polling of the device, and indicators which flash for a fixed period. My first implementation...
5
by: Sachin Surana | last post by:
We use HttpWebRequest to send the request at a URL. But some times the method GetResponse throws a time out exception. But when we check the IIS logs, there is no such entry. So the request never...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
1
by: steve | last post by:
Hi All I am writing a program for a gymnasium for membership control It is the first time I have had to deal with appointment diaries and I want to know the best way to store recurring...
2
by: nepdae | last post by:
Please forgive me, this is a long one. My 11-user Access 2000 database is having recurring corruption problems. The symptoms include the following: 1) corrupted fields in recently created or...
12
by: owestcot | last post by:
I'm working on a simple video game program that will require timed responses. The easiest example I can think of would be something like: char ans; // answer to question (can't remember the...
1
by: TC | last post by:
Hi, I have an app that is going to require recurring diary entries, it's a relatively simple app but I have no idea how to go about the recurring entry side of things. The functionality needs to...
0
by: =?Utf-8?B?TWVlbWEgSnVkeQ==?= | last post by:
I have a Verizon Palm Treo 755p and use Outlook 2002 on my new HP Pavilion (Vista 64-bit). When I was syncing on my old XP PC, everything worked fine. On the Vista PC, when I finally got it to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.