473,239 Members | 1,608 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,239 software developers and data experts.

Trying to make program to press a button every X minutes.

5
Heres what ive got so far 0.o im more of a beginner Though =[

Dim Tim As Integer
Dim Often As Integer
Dim EndT As Integer

Private Sub cmdStart_Click()
Do 'Loop
If Tim = Often Then
SendKeys "A"
Tim = 0
End If
Loop Until tmrEndT = EndT

End Sub

Private Sub Form_Load()
txtEndT.Text = EndT
tmrTim = Tim
txtTim.Text = Often
End Sub



Im trying to make the program send the key A like it is being pressed or like if i opened notepad it would keep typing A every "often" for a total time of EndT
Nov 6 '06 #1
7 4906
willakawill
1,646 1GB
Heres what ive got so far 0.o im more of a beginner Though =[

Dim Tim As Integer
Dim Often As Integer
Dim EndT As Integer

Private Sub cmdStart_Click()
Do 'Loop
If Tim = Often Then
SendKeys "A"
Tim = 0
End If
Loop Until tmrEndT = EndT

End Sub

Private Sub Form_Load()
txtEndT.Text = EndT
tmrTim = Tim
txtTim.Text = Often
End Sub



Im trying to make the program send the key A like it is being pressed or like if i opened notepad it would keep typing A every "often" for a total time of EndT
Hi. I think you are trying to use the timer control. This code works
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdStart_Click ()
  2.    Timer1.Interval = CInt(Me.txtOften.Text) 'interval in milliseconds
  3.    Timer1.Enabled = True
  4. End Sub
  5.  
  6. Private Sub cmdEnd_Click()
  7.    Timer1.Enabled = False
  8. End Sub
  9.  
  10. 'code is activated every time the timer event occurs
  11. Private Sub Timer1_Timer ()
  12.    SendKeys "A"
  13. End Sub
  14.  
  15.  
  16.  
Nov 6 '06 #2
imhiya
5
Hi. I think you are trying to use the timer control. This code works
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdStart_Click ()
  2.    Timer1.Interval = CInt(Me.txtOften.Text) 'interval in milliseconds
  3.    Timer1.Enabled = True
  4. End Sub
  5.  
  6. Private Sub cmdEnd_Click()
  7.    Timer1.Enabled = False
  8. End Sub
  9.  
  10. 'code is activated every time the timer event occurs
  11. Private Sub Timer1_Timer ()
  12.    SendKeys "A"
  13. End Sub
  14.  
  15.  
  16.  

can you explain the bold lines please ^^
Nov 6 '06 #3
imhiya
5
can you explain the bold lines please ^^

Btw is sendkey same as Keypress? cos i dont want it to type it i want it to think the button is being pressed on the keyboard
Nov 6 '06 #4
willakawill
1,646 1GB
can you explain the bold lines please ^^
You put a timer control on your form. The timer control interval must be set. In this example the timer is called Timer1 which is the default name for it when you add it to your form.

Put a button to start the process on your form called cmdStart. The click event of this button will set the timer interval in milliseconds to whatever time interval you want. (1,000 milliseconds is one second). The maximum is 67,000 milliseconds which is just over a minute.

The timer works when it is enabled so we set the enabled property to true when the start button is clicked.

We set the enabled property to false when the end button is clicked.

SendKeys will continually type the letter 'A' into any app that has the focus. If you test it with notepad you will see 'AAAAAAAA' continuing until the end button is clicked.

I am not sure about your second question. Do you want to see the letter 'A' or whatever you choose in the notepad?
Nov 6 '06 #5
imhiya
5
You put a timer control on your form. The timer control interval must be set. In this example the timer is called Timer1 which is the default name for it when you add it to your form.

Put a button to start the process on your form called cmdStart. The click event of this button will set the timer interval in milliseconds to whatever time interval you want. (1,000 milliseconds is one second). The maximum is 67,000 milliseconds which is just over a minute.

The timer works when it is enabled so we set the enabled property to true when the start button is clicked.

We set the enabled property to false when the end button is clicked.

SendKeys will continually type the letter 'A' into any app that has the focus. If you test it with notepad you will see 'AAAAAAAA' continuing until the end button is clicked.

I am not sure about your second question. Do you want to see the letter 'A' or whatever you choose in the notepad?
i got it to work ^.^ i put another text box for the button or letter i want to press for example i put {Tab} and it will press Tab. Also i make it so it times the txtOften by 1000 so i can set how many seconds i want :) Btw how do i make so it can go over 67k or just over a minute? Btw credits to you :P
Nov 6 '06 #6
Killer42
8,435 Expert 8TB
Btw is sendkey same as Keypress? cos i dont want it to type it i want it to think the button is being pressed on the keyboard
In a way, they are opposites. SendKey is the function you perform to send a key, while KeyPress is the event which is triggered when Windows says that the user pressed a key (and possibly when it receives the one you just sent).
Nov 6 '06 #7
Killer42
8,435 Expert 8TB
i got it to work ^.^ i put another text box for the button or letter i want to press for example i put {Tab} and it will press Tab. Also i make it so it times the txtOften by 1000 so i can set how many seconds i want :) Btw how do i make so it can go over 67k or just over a minute? Btw credits to you :P
One thing you could do is have it wait one second at a time (interval around 1,000), and count the elapsed time yourself. You might need to use a static variable to track the time since the last trigger.
Nov 6 '06 #8

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

Similar topics

3
by: aToaster | last post by:
Hey guys, I'm just getting the hang of Python and Tkinter and I could use some help. I wrote most of the gui for my calculator program, well I haven't gotten around to putting in the...
2
by: Just Me | last post by:
Need to write a program that wakes up every 15 minutes and does something. I guess I could just create a Windows application and schedule it to run every 15 minutes. Or I could have a program...
3
by: Dodger | last post by:
I've been working on this little doohickey for a bit now... (please ignore the speed issues of some of the queries -- things aren't all optimised up in mysql yet) ...
0
by: south622 | last post by:
I'm taking a beginning Java course and I'm stuck in week eight of a nine week course. If anyone could help me I would greatly appreciate it. This assignment was due yesterday and each day I go past...
1
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
4
by: boris.merryweather | last post by:
Hi, I'm VERY new to C#. I've bought a book (always a bad move) called "Build a Program Now. Visual C#" by Patrice Pelland. I got to chapter 4 without difficulty. I then started the project in...
2
Atran
by: Atran | last post by:
Hello: I have two programs (Windows Forms). I want to make the second program runs when I press a button in the first program. So when the user go to run the second program, I want the second...
5
by: clairelee0322 | last post by:
I am a C++ beginner and I am working on a C++ project that calucates the phone bill. I got stuck on how to make every 60 minutes into one hour.. Like if the user enter 1000 (10:00) and it asks for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.