Google Answers Logo
View Question
 
Q: VB.NET - Pasting a TimeDate Stamp to Active Window ( No Answer,   3 Comments )
Question  
Subject: VB.NET - Pasting a TimeDate Stamp to Active Window
Category: Computers > Programming
Asked by: thelama-ga
List Price: $5.00
Posted: 26 May 2005 09:01 PDT
Expires: 25 Jun 2005 09:01 PDT
Question ID: 525896
I need to "more easily" enter a timestamp into various applications
that don't offer this functionality (i.e notepad, Outlook Task,
Calendar, Notes, etc).

Here's what I have that puts the time and date into clipboard:
//
Public Sub Main()
Dim TheDate As String = Date.Now.ToString
Clipboard.SetDataObject(TheDate, True)
End Sub
//

With this I can run the program from a shortcut, place the cursor
where I want to enter the timedate stamp and CTRL-V to paste it in.

Question: How can I enhance this programatically to identify the
active window (i.e. an Outlook Task Comment area) and have the program
automatically paste the time/date whereever the cursor is?
Answer  
There is no answer at this time.

Comments  
Subject: Re: VB.NET - Pasting a TimeDate Stamp to Active Window
From: mhani-ga on 26 May 2005 16:41 PDT
 
I wouldn't recommend using the Clipboard to transfer data between applications. 

You can identify the foreground active window by calling the API
function GetForegroundWindow and you can use the message WM_GETTEXT to
get its name.

Then when you need to write the current date/time in that window,
emulate the keyboard keys by using the .NET class
System.Windows.Forms.SendKeys. Use the function SendKeys.Send() to
send the date/time string to the active application.

~Hani
Subject: Re: VB.NET - Pasting a TimeDate Stamp to Active Window
From: willcodeforfood-ga on 27 May 2005 15:19 PDT
 
In Notepad you can get a timestamp by pressing F5.
Subject: Re: VB.NET - Pasting a TimeDate Stamp to Active Window
From: thelama-ga on 28 May 2005 05:43 PDT
 
Thanks Hani, while trying to figure things out (I'm a real novice at
VB.NET), I saw references to your point of not using clipboard, but
could not figure out the actual coding structure to make
GetForegroundWindow and WM_GETTEXT work properly - kept getting
compile errors.

Thanks willcodeforfood, didn't know that about Notepad - regretably,
my need for this utility is primarily focused on Outlook which doesn't
have that ability.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy