473,503 Members | 11,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SendKeys - PostMessage problem

Hi all.

Probably a quick one, I'm using PostMessage to send keys to an applicatoin
but how do I convert the key string to a long values so that I can pass this
to the wParam. The definition is below

Private Declare Auto Function PostMessage Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As Long, _
ByVal lParam As Long) As Boolean

This works -> PostMessage(myWindow, WM_KEYDOWN, Keys.X, 0)

However I need to somehow convert the stirng into the equiv keycodes so I
can do something like

PostMessage(myWindow, WM_KEYDOWN, "x", 0)

Thanks
Paul


Jul 21 '05 #1
2 1847
Hi,
PostMessage(myWindow, WM_KEYDOWN, asc("x"), 0)
Ken
----------------------------
"Paul" <pa******************@vectra-it.co.uk> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
Hi all.

Probably a quick one, I'm using PostMessage to send keys to an applicatoin
but how do I convert the key string to a long values so that I can pass this to the wParam. The definition is below

Private Declare Auto Function PostMessage Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As Long, _
ByVal lParam As Long) As Boolean

This works -> PostMessage(myWindow, WM_KEYDOWN, Keys.X, 0)

However I need to somehow convert the stirng into the equiv keycodes so I
can do something like

PostMessage(myWindow, WM_KEYDOWN, "x", 0)

Thanks
Paul

Jul 21 '05 #2
Nice one, works well.

Thanks
Paul

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uv**************@TK2MSFTNGP11.phx.gbl...
Hi,
PostMessage(myWindow, WM_KEYDOWN, asc("x"), 0)
Ken
----------------------------
"Paul" <pa******************@vectra-it.co.uk> wrote in message
news:eR**************@TK2MSFTNGP10.phx.gbl...
Hi all.

Probably a quick one, I'm using PostMessage to send keys to an applicatoin but how do I convert the key string to a long values so that I can pass

this
to the wParam. The definition is below

Private Declare Auto Function PostMessage Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As Long, _
ByVal lParam As Long) As Boolean

This works -> PostMessage(myWindow, WM_KEYDOWN, Keys.X, 0)

However I need to somehow convert the stirng into the equiv keycodes so I can do something like

PostMessage(myWindow, WM_KEYDOWN, "x", 0)

Thanks
Paul


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5761
by: newsgroups.bellsouth.net | last post by:
I was checking out SAPI, ms's speech recognition api, and thought it would be cool to write a quick app for bf1942 that would recognise voice commands and pass them to the game's commun. So if you...
2
5678
by: RBohannon | last post by:
I need to create a report in MS Word populated with data from A2K. I have been asked to create the report in Word so that parts of it can be edited as necessary later. The data in the report are...
1
7704
by: Bryan | last post by:
I am writing a C# Windows App that updates out Excel reports' modules. The app is complete, but has a problem. The only way MS allows you to unprotect the VBA code in Excel is to do it by hand or...
15
8420
by: James | last post by:
In my code I have a problem in abtaining a windows handle. I do not know the namespace to obtain the windows hanle. here is the code. using System; using System.Collections; using...
12
7166
by: Wilfried Mestdagh | last post by:
Hi, Using P/Invoke I use PostMessage to send a message from one thread to another. I'm pretty sure this has already worked in dotnet. but I've upgraded version 2 few day ago. Now I have an...
3
4443
by: Paul | last post by:
Hi all. Probably a quick one, I'm using PostMessage to send keys to an applicatoin but how do I convert the key string to a long values so that I can pass this to the wParam. The definition is...
3
9445
by: knikkix | last post by:
Hi, I created a form in VB.Net with only one button. This is the code in button click event Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
21
6835
by: one2001boy | last post by:
PostMessage() function returns ERROR_NOT_ENOUGH_QUOTA after running in a loop for 700 times, but the disk space and memory are still big enough. any suggestion to resolve this problem? thanks.
11
47997
by: NVergunst | last post by:
Hello everyone. I have what I believe to be a simple question, yet I can not find anything that is helpful to me. Basically I have an application, that I want to use to control external...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.