|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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! |
|
#2
|
||||
|
||||
|
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? |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
||||
|
||||
|
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
__________________
medialint.com "Energy has the opportunity to change the climate if it's done right." - Sen. John Ensign, R-Nev. (quoted out of context) |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Send text to a selected window. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|