|
-
Nov 19th, 2002, 06:54 AM
#1
Thread Starter
Member
Passing text to another application (RESOLVED)
I am attempting to write an program which will send text to another application. The other application contains a textbox. In this case I am trying to write a poetry reader for a chat group - to save having to enter each line manually.
questions is - how do I find the running application - and how do i find and enter text into the textbox....
I am relatively new to VB - and am trying to teach myself - but this has me stumped. =/
thanks in advance
Last edited by dark.journey; Nov 20th, 2002 at 11:07 AM.
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Nov 19th, 2002, 07:27 AM
#2
Thread Starter
Member
thanks to the FAQ by "The Hobo" I have solved the first problem - I have managed to find the find window HWND - (not sure how to use it yet - but hope to real fast.)
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Nov 19th, 2002, 08:38 AM
#3
New Member
If You Know What App or Window Was ACTIVE ...
Hi !
If You Know The Name Of Active Window You Can Find Hwnd Of It ! With These Codes !
'---------------------------------------
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private sub cmdFind_click()
Dim Handle as Long
' For Exm : Handle=FindWindow(Class Here , Name Here) {You Can Find Class With API SPY Or Spy++ And Find Name That Wrote Top Of Windows}
Handle=FindWindow("Calculator",vbNullString)
MSGBOX (Handle)
End Sub
-
Nov 19th, 2002, 09:43 AM
#4
Thread Starter
Member
old hex thanks - that works a real treat - i have found the window classname now - which makes things easier as the caption is ever changing - i also found the textbox classname - but have no idea how to implement the idea i have of transferring text from a vb program to the text input window of the chat client
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Nov 19th, 2002, 01:28 PM
#5
PowerPoster
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long
Private Const WM_SETTEXT As Long = &HC
SendMessage hwndTextBox, WM_SETTEXT, 0&, "MY String"
-
Nov 19th, 2002, 02:06 PM
#6
Thread Starter
Member
thanx ami - I think this one is going to take some working on =/ - guess you cant just "dive in at the deep end" - i really needed this too - thought it would be soooo simple - lol - welp - I guess simple is relative =)
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Nov 19th, 2002, 02:55 PM
#7
New Member
Possble sidebar but...
I am a little behind in this. I can find the handle and I understand how to use the SendMessage. My problem is getting the textbox handle.
I am in a different situation, I think. What I am trying to do is send the text message to a window that is for a terminal emulator. I don't think it is windows based and therefore may not have a textbox as such. What I would like to do is just send the string of characters to where the cursor is currently positioned in that window.
Using the "Notepad", when I sent the message to the handle of the window it was sent to the caption. I also have an idea for a work around if it is not possible to send the text as described.
So my questions are:
1. Is it possible, and how can you send a message to where the cursor is in the window.
2. If that is not possible then how can I send a CTRL V to the window so that I can paste from the clipboard. I think I can get the information to the clipboard.
Craig
One step above an Expert Novice
-
Nov 19th, 2002, 08:45 PM
#8
Thread Starter
Member
Originally posted by amitabh
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long
Private Const WM_SETTEXT As Long = &HC
SendMessage hwndTextBox, WM_SETTEXT, 0&, "MY String"
ok i used this and managed to update the window caption - are there any special variable names I need to use to find the object that I am after - in this case - a textbox?
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Nov 20th, 2002, 01:57 AM
#9
PowerPoster
Do you have Spy++? If yes, then find out the class name of the textbox. After that, use this code to find the handle to the text box.
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpszClassName As String, _
ByVal lpszWindowCaption As String) As Long
Dim hwndTxtBox As Long
hwndTxtBox = FindWindowEx("<Window handle>", 0&, "<text box class name>", vbNullString)
This assumes that you have only one text box, other wise you might try replacing the vbNullString with whatever is in the textbox.
-
Nov 20th, 2002, 09:19 AM
#10
Thread Starter
Member
Originally posted by amitabh
Do you have Spy++? If yes, then find out the class name of the textbox. After that, use this code to find the handle to the text box.
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpszClassName As String, _
ByVal lpszWindowCaption As String) As Long
Dim hwndTxtBox As Long
hwndTxtBox = FindWindowEx("<Window handle>", 0&, "<text box class name>", vbNullString)
This assumes that you have only one text box, other wise you might try replacing the vbNullString with whatever is in the textbox.
Thank You so much amitabh this works perfectly - I was up till 4am looking for just this piece of information - I appreciate your help very much =)
*follow the white rabbit neo*
.¸¸.·´¯`·.¸.·>dark journey<·.¸¸.·´¯`·.¸.
To accomplish great things, we must dream as well as act.
Anatole France (1844 - 1924)
-
Nov 20th, 2002, 09:39 AM
#11
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
|