 |
 |

11-24-2003, 09:46 PM
|
 |
Centurion
|
|
Join Date: Jul 2002
Location: Mankato, Minnesota
Posts: 109
|
|
Key Press behind the scenes
|
I have a vb program minimized to the systray and I need it to periodically press enter on one of it's forms without disrupting my work. Does anyone have any idea how to do this?
Thanks,
John
|
__________________
Never Be afraid to try something new remember professionals built the titanic but ametuers built the ark
|

11-24-2003, 09:58 PM
|
 |
Contributor
|
|
Join Date: Oct 2003
Location: Under your bed
Posts: 792
|
|
Quote: Originally Posted by john8675309 I have a vb program minimized to the systray and I need it to periodically press enter on one of it's forms without disrupting my work. Does anyone have any idea how to do this?
Thanks,
John
my best guess whad be to use a timer to keep doin it  or a series of timers 
|
__________________
Please use [vb][/vb] tags when posting.
|

11-24-2003, 10:01 PM
|
 |
Centurion
|
|
Join Date: Jul 2002
Location: Mankato, Minnesota
Posts: 109
|
|
|
that was my plan but I am not sure how I can localize an enter to just a specific program. Do you know how to do this?
--John
|
__________________
Never Be afraid to try something new remember professionals built the titanic but ametuers built the ark
|

11-24-2003, 10:05 PM
|
 |
Contributor
|
|
Join Date: Oct 2003
Location: Under your bed
Posts: 792
|
|
Quote: Originally Posted by john8675309 that was my plan but I am not sure how I can localize an enter to just a specific program. Do you know how to do this?
--John
you could just put what you needed to do in a sub, and call the sub, or i think u can simulate a enter pressed, i kno the keyascii = 13. so if u said
im guessing it would do it  then again im not sure so dont quote me for it 
ahh also forgot to add
try this
SendKeys {ENTER}
|
__________________
Please use [vb][/vb] tags when posting.
|

11-24-2003, 10:08 PM
|
 |
Centurion
|
|
Join Date: Jul 2002
Location: Mankato, Minnesota
Posts: 109
|
|
|
I tried the sendkeys {enter} but it presses enter on any application I am in. I can try the key ascii though. in the mean time is there anything else?
--John
|
__________________
Never Be afraid to try something new remember professionals built the titanic but ametuers built the ark
|

11-24-2003, 10:09 PM
|
 |
Contributor
|
|
Join Date: Oct 2003
Location: Under your bed
Posts: 792
|
|
Quote: Originally Posted by john8675309 I tried the sendkeys {enter} but it presses enter on any application I am in. I can try the key ascii though. in the mean time is there anything else?
--John
well this would be an easier way i guess, u can have it maxmize real quick, send enter , then minimize, but thats he lazy way. and ive run out of ideas 
|
__________________
Please use [vb][/vb] tags when posting.
|

11-24-2003, 10:22 PM
|
 |
Centurion
|
|
Join Date: Jul 2002
Location: Mankato, Minnesota
Posts: 109
|
|
|
I read something about sendinput os that maybe what I am looking for?
--John
|
__________________
Never Be afraid to try something new remember professionals built the titanic but ametuers built the ark
|

11-25-2003, 12:03 AM
|
|
Junior Contributor
|
|
Join Date: Nov 2002
Posts: 357
|
|
I don't get it.
You want your VB app to get the Enter key? Or do you want the app to send an Enter keystroke as if it were typed at the keyboard (to whatever app is active)?
Usually, you trap a keystroke in your VB program with in a KeyPress or KeyDown event, in which you would do your code. Can't you just do that desired code in a Timer event and not depend on a keystroke?
Just trying to understand so that I can help (maybe) 
|
__________________
It looks like ketchup; it tastes like ketchup; but brother, it ain't ketchup!
|

11-25-2003, 02:50 AM
|
|
Newcomer
|
|
Join Date: Nov 2003
Posts: 11
|
|
Quote: Originally Posted by john8675309 I have a vb program minimized to the systray and I need it to periodically press enter on one of it's forms without disrupting my work. Does anyone have any idea how to do this?
Thanks,
John
hmm... if I do not misunderstand you, you can always create a timer, which will call the subroutine of the Enter button of the form in question.
For example, the Form is named Form1 and the button is cmdEnter.
In your timer, you can have
Form1.cmdEnter_Click
You have to make Public the cmdEnter_Click routine.
|
__________________
Regards
Ryan
-------------------------------------------
Code-Lock - Secure Software Protection System for Visual Basic, C# and .NET applications http://www.ChosenBytes.com
|

11-25-2003, 04:54 PM
|
 |
Centurion
|
|
Join Date: Jul 2002
Location: Mankato, Minnesota
Posts: 109
|
|
Quote: Originally Posted by ryan_thian
hmm... if I do not misunderstand you, you can always create a timer, which will call the subroutine of the Enter button of the form in question.
For example, the Form is named Form1 and the button is cmdEnter.
In your timer, you can have
Form1.cmdEnter_Click
You have to make Public the cmdEnter_Click routine.
What I am doing is making a watchguard automatic authentication program. I have a webbrowser control on the form. When the web page loads the submit button on the applet has focus so if I am in the program and hit enter the applet will submit and authenticate me. I would like to have that same routine done every so many hours. So I created a timer and did a sendkeys event every 5 minutes (in the timer). I also made the application avalible to go into the systray. So when the 5 minute mark rolls around it will press enter no matter where I am on my computer. I would like to localize the enter push just to the program. so that it won't disrupt my work.
Side note: it works just fine if my software has focus. if there was a way to make my program get focus every few hours and then return focus where it got it from that would be ok, but I would really like to localize it to just that program so none of what I am doing is disrupted.
Thanks again for all your help
--John
|
__________________
Never Be afraid to try something new remember professionals built the titanic but ametuers built the ark
Last edited by Deadalus; 11-25-2003 at 05:13 PM.
Reason: Fixed tags
|

11-25-2003, 06:09 PM
|
|
Promising Talent
Retired Moderator * Guru *
|
|
Join Date: May 2002
Location: Brussels
Posts: 3,601
|
|
You can use PostMessage to send a Enter to your application without giving it focus. In this case you'll still need to deminimize it though, otherwise the Enter won't have any effect.
Code:
Option Explicit
Private Const WM_KEYDOWN As Long = &H100
Private Const VK_RETURN As Long = &HD
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Timer1_Timer()
Dim intOldState As Integer
intOldState = Me.WindowState
If Me.WindowState = vbMinimized Then
Me.WindowState = vbNormal
DoEvents
End If
PostMessage hwnd, WM_KEYDOWN, VK_RETURN, &H1
DoEvents
Me.WindowState = intOldState
End Sub
Edit: Corrected key name. (It worked with vbKeyReturn too though, because it's the same value.)
|
Last edited by Deadalus; 11-25-2003 at 06:45 PM.
|

11-25-2003, 06:37 PM
|
 |
Ultimate Contributor
Retired Leader * Guru *
|
|
Join Date: Aug 2001
Posts: 5,343
|
|
|
You might be able to use the DOM capabilities of the WebBrowser control to submit the form through code, possibly by manually calling the appropriate 'submit' method in the applet. The DOM can be referenced by using the 'document' property of the WebBrowser, and from there you can access elements on the webpage using the names given to them in HTML.
I've never had experience doing this, but it's food for thought if you feel like doing a little digging.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|