473,651 Members | 2,793 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(myW indow, WM_KEYDOWN, Keys.X, 0)

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

PostMessage(myW indow, WM_KEYDOWN, "x", 0)

Thanks
Paul


Nov 20 '05 #1
3 4464
Hi,
PostMessage(myW indow, WM_KEYDOWN, asc("x"), 0)
Ken
----------------------------
"Paul" <pa************ ******@vectra-it.co.uk> wrote in message
news:eR******** ******@TK2MSFTN GP10.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(myW indow, WM_KEYDOWN, Keys.X, 0)

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

PostMessage(myW indow, WM_KEYDOWN, "x", 0)

Thanks
Paul

Nov 20 '05 #2
Nice one, works well.

Thanks
Paul

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:uv******** ******@TK2MSFTN GP11.phx.gbl...
Hi,
PostMessage(myW indow, WM_KEYDOWN, asc("x"), 0)
Ken
----------------------------
"Paul" <pa************ ******@vectra-it.co.uk> wrote in message
news:eR******** ******@TK2MSFTN GP10.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(myW indow, WM_KEYDOWN, Keys.X, 0)

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

PostMessage(myW indow, WM_KEYDOWN, "x", 0)

Thanks
Paul


Nov 20 '05 #3
* "Paul" <pa************ ******@vectra-it.co.uk> scripsit:
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


Replace the 'Long' with 'Int32' and pass 'Asc("X")' (untested!).

BTW: Please post only to groups related to your problem!

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #4

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

Similar topics

0
5791
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 say "roger" it would then send f1 f1 to bf1942 for it to send out the roger commun..I'm finding out that directinput is a bitch, uses a low level, so it ignores Sendkeys and sendmessage/postmessage. I've completed everything except sending the...
2
1862
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 below Private Declare Auto Function PostMessage Lib "user32" ( _ ByVal hWnd As IntPtr, _ ByVal Msg As Integer, _ ByVal wParam As Long, _
2
5693
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 in a table with headings for each column, so converting an Access report to a Word doc in RTF doesn't work because only the text is converted, not the table. What I have tried so far, with some success, is to write the report directly in Word....
1
7714
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 sendkeys. I hate using SendKeys, but I am forced to use them. Anyway, I have written a function that will unprotect the VBA code in the current work book. It works about 60% of the time. For some reason it gets out of sync and the SendKeys don't...
15
8442
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 System.Windows.Forms; using System.Runtime.InteropServices; namespace mynamespace
0
890
by: Mark Vergara | last post by:
Hi to All, I wonder how this command is not working CTRL + SHIFT + F8 SendKeys.SendWait("^+{F8}") just to open the form I want to open, is there any missing in the code please correct me if I am wrong Thanks Mark
3
9460
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 Button1.Click AppGlobals.SetHandles(Me.Handle.ToInt64()) Call OpenModel() End Sub
21
6875
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
48031
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 applications. My program will run either embedded within another program or minimized to the system tray. So SendKeys is out because it only works if the controlled application has focus, which it will not. So my conclusion is the windows API. I have...
0
1005
by: rag84dec | last post by:
Hi, i am using win32::guitest package since 2 weeks... but one problem i am finding is putting the values in the PostMessage(); it takes 8 bytes as the last parameter.How to send it as the 8 bytes in perl?? 8 bytes are like this ...lower 4 bytes for the x coordinate and upper 4 bytes for the y coordinate of the windows component in a gui.
0
8352
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.