-
Apr 20th, 2006, 06:14 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Convert Letter To vbKey Equivalent ("a" > vbKeyA)
I am using PostMessage API to send text to a certain program.
I've got my program to work when I use
VB Code:
PostMessage hWnd1, WM_KEYDOWN, vbKeyA, 0
But I need to send a string that will be defined at runtime, so I need a way to do something like
VB Code:
PostMessage hWnd1, WM_KEYDOWN, "something", 0
but that code doesn't work.
I need to send a long value of each letter so I need to know how to convert a letter to its vbKey equivalent
-
Apr 20th, 2006, 06:19 AM
#2
Re: Convert Letter To vbKey Equivalent ("a" > vbKeyA)
-
Apr 20th, 2006, 06:22 AM
#3
Thread Starter
Fanatic Member
Re: Convert Letter To vbKey Equivalent ("a" > vbKeyA)
I tried using WM_SETTEXT earlier when I was still using SendMessage API but it just set the title of the program.
I'll try it out now with PostMessage
EDIT:
I got a 'Type Mismatch' error.
What is the syntax for using WM_SETTEXT?
I was using
VB Code:
PostMessage hWnd1, WM_SETTEXT, "a", 0
But it doesn't even work with
VB Code:
PostMessage hWnd1, WM_SETTEXT, vbKeyA, 0
Last edited by shirazamod; Apr 20th, 2006 at 06:28 AM.
-
Apr 20th, 2006, 06:31 AM
#4
Re: Convert Letter To vbKey Equivalent ("a" > vbKeyA)
Well if you want do it with WM_KEYDOWN then the keycodes are the same as the Ascii values, but it'll all be in the same case:
VB Code:
Dim sText As String, N As Long
sText = "something"
For N = 1 to Len(sText)
PostMessage hWnd1, WM_KEYDOWN, Asc(Mid$(sText, N, 1)), 0
PostMessage hWnd1, WM_KEYUP, Asc(Mid$(sText, N, 1)), 0
Next N
Perhaps try WM_CHAR
-
Apr 20th, 2006, 06:34 AM
#5
Re: Convert Letter To vbKey Equivalent ("a" > vbKeyA)
When using WM_SETTEXT you should be using it this way
VB Code:
PostMessage hwnd1, WM_SETTEXT, 0&, "Text that needs to be sent"
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Apr 20th, 2006, 06:35 AM
#6
Re: Convert Letter To vbKey Equivalent ("a" > vbKeyA)
you'd use WM_SETTEXT by sending the text to the edit box that you want to recieve the text
VB Code:
PostMessage lHwndEdit, WM_SETTEXT, 0&, ByVal "TEST"
-
Apr 20th, 2006, 06:40 AM
#7
Thread Starter
Fanatic Member
Re: Convert Letter To vbKey Equivalent ("a" > vbKeyA)
Thanks bushmobile, that sorted it out!
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
|