Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 28th, 2008, 04:41 PM
cylas_55 cylas_55 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 3 cylas_55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 31 sec
Reputation Power: 0
Question Send text to a selected window.

Hello,
I am working on a project for a group of hospitals that is trying to make life easy and faster for doctors when using there computer. Basically what has been requested is some kind of a speed dial for basic information such as an address, phone number, email address, username, password, etc. So, for example, if the doctor is in word he/she would go to this program that I created, click the 1 button (speed dial 1), which would copy an address to the clipboard and when the doctor clicks back on word it would paste that address wherever the cursor is. This would also be available for excel, IE, notepad, and basically any application that takes the paste command.

I have asked if the doctors could just then press Ctrl-V but that came back as a no and would add another step.

Right now my program will copy to the clipboard but I have not been able to get it to paste to an application that is clicked on. Is this task possible? And if so can you point me the right direction on how to accomplish this task. Thanks so much!

Reply With Quote
  #2  
Old April 29th, 2008, 12:54 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
That is possible of course. But creating a macro in word would be easier.

That way, you will get rid of automating copy paste to your app and word. Do you know how to create macros?

Reply With Quote
  #3  
Old April 29th, 2008, 11:31 AM
cylas_55 cylas_55 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 3 cylas_55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 31 sec
Reputation Power: 0
Thanks for your reply. I initially thought of doing somthing like that but they want this for any application. So if they are using notepad, Internet explorer, etc. So a macro would not work in this case. I have been playing around with the win32 API but have not had success.

Reply With Quote
  #4  
Old April 29th, 2008, 11:56 AM
LyonHaert's Avatar
LyonHaert LyonHaert is offline
Arcane Scribbler
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2005
Location: Indianapolis, IN
Posts: 1,546 LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 10 h 12 m 31 sec
Reputation Power: 357
Well, it sounds like your application is going to have to handle some sort of event when focus is changed to a different window, find out what window now has focus, and maybe use SendKeys() or something.
__________________
Joel B Fant - LyonHaert.net

2 + 2 is... 10... in base 4

Reply With Quote
  #5  
Old April 29th, 2008, 12:09 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,195 medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)medialint User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1Folding Points: 230955 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Weeks 5 Days 10 h 34 m 36 sec
Reputation Power: 2500
Object Linking and Embedding automation could be a solution for the MS-Office apps and anything else that supports OLE.

Sendkeys is quick and dirty but it's duct tape and will probably end up making a mess eventually. This is especially true in the context of a user control panel and toggling between applications. Inevitable someone is going to get text pasted in the wrong place with variable results depending on how bad that turns out to be. Alas, accidentally overwriting medical test results on a patient with their home address is probably a very bad thing indeed.

Ctrl+V is the best solution
Comments on this post
LyonHaert agrees: I agree, but he already tossed out that suggestion. (nice rep power, a la ACC)
__________________
medialint.com

"Energy has the opportunity to change the climate if it's done right." - Sen. John Ensign, R-Nev. (quoted out of context)

Reply With Quote
  #6  
Old April 30th, 2008, 01:27 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
If you want it powerful other than sendkeys, you can use the combinations of API.

Use SendMessage or PostMessage. Google them for constants.

Use GetFocus() API to get which window has the focus or GetForeGroundWindow() API to get the window on top.

To simulate the alt + tab thing and paste, using FindWindow() API and FindwindowEX() plus ShowWindow() then by adding Postmessage, you can do whatever you like on the said window.

I know this sounds like alien to you. The API posted above are the functions that you might need (although its not complete). Try reading MSDN for better understanding of the API and get lots of samples. At first it is difficult but once you grab the idea of using API, it will help you with your future projects.

Reply With Quote
  #7  
Old April 30th, 2008, 10:31 AM
cylas_55 cylas_55 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 3 cylas_55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 31 sec
Reputation Power: 0
Thanks so much for your reply. I am researching what you have posted above. I am always willing to learn more so this is great. Thanks again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Send text to a selected window.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway