|
-
July 15th, 2007, 03:25 PM
#1
Problem with SendKeys ... please help!
Hi!
I'm trying to write a simple tool for my personal Use. But I'm facing trouble in making it to work as desired.
What I'm trying to do is: When the program is started, it will register Ctrl + Alt + Shift + F12 as Hotkey. Application minimizes itself to System tray. In this state, when you select some text in another application (such as MS Word), I want this application to grab the selected text into Clipboard and then create a new Text file & write this Clipboard text to it.
The Problem is: SendKeys "^c" works only when the Hotkey is pressed for the very first time. After that, SendKeys does not produce desired result. I added Debug.Print in Hotkey Pressed even and noticed that Hotkey is pressed correctly; so there is no problem with RegisterHotkey. The problem I see is with SendKeys.
I request you to please download the Project from following URL:
http://www.orbitfiles.com/download/id1642485529
I also tried GetForegroundWindow and SetForegroundWindow to make sure that this program itself does not gain focus. (project files on above link does not contain these API test code.) I tried adding a Timer control with Interval = 20 and declared a Long var. I collected Window's Handle in this var on TimerControl_Timer event; later used the same with SetForegroundWindow before SendKeys. But even this method could not fetch the desired result.
Actually I always faced this problem and never could really found a work-around for this. So, it looks like there is some error in my method itself and so I decided better to talk experts like you all and get my techniques corrected!
Please let me know where I'm going wrong. Why SendKeys works only for the very first time when Hotkey is pressed? Why it stops working after that? Any solution for this?
Waiting for your valuable reply ...
Regards,
Ruturaaj.
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
|