473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

PostMessage in C# with ALT + C key and CTL + S key

Hi,

Please can any one help on how to send ALT+C and CLT+ S key press key
press event to the running application, i tried all possible what I
was able to search on net but not got the result.

Below if the code

public const UInt32 WM_CHAR = 0x0102;
public const UInt32 WM_SYSKEYDOWN = 0x0104;
public const UInt32 WM_KEYDOWN = 0x0100;

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, uint
wParam, uint lParam);

public void SendCutomMessage(IntPtr hwnd)
{
PostMessage(hwnd,WM_SYSKEYDOWN ,(unit)'C',0); // For ALT+C
wparam and lparam are correct?
PostMessage(hwnd,WM_SYSKEYDOWN ,(unit)'S',0); // For CLT+S
wparam and lparam are correct?
}

Thanks in advance.....
Hitendra Patel
Sep 20 '08 #1
2 6000
Hi Hitendra,

first of all: What OS are you using: XP and Lower or
Vista based, since there is a big difference and a big
security border you have to pass on Vista. On Vista
you cant just send Keystrokes and Messages to other
Windows and processes as you did in the past,...

See here:

[User Interface Privilege Isolation]
http://en.wikipedia.org/wiki/User_In...lege_Isolation

This must be done, since it was a big security whole
if you knew how to "leverage" it,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Hiten" <hi********@gmail.comschrieb im Newsbeitrag
news:16**********************************@a29g2000 pra.googlegroups.com...
Hi,

Please can any one help on how to send ALT+C and CLT+ S key press key
press event to the running application, i tried all possible what I
was able to search on net but not got the result.

Below if the code

public const UInt32 WM_CHAR = 0x0102;
public const UInt32 WM_SYSKEYDOWN = 0x0104;
public const UInt32 WM_KEYDOWN = 0x0100;

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, uint
wParam, uint lParam);

public void SendCutomMessage(IntPtr hwnd)
{
PostMessage(hwnd,WM_SYSKEYDOWN ,(unit)'C',0); // For ALT+C
wparam and lparam are correct?
PostMessage(hwnd,WM_SYSKEYDOWN ,(unit)'S',0); // For CLT+S
wparam and lparam are correct?
}

Thanks in advance.....
Hitendra Patel
Sep 20 '08 #2
Hi Kerem,
Thanks for your reply, OS is WindowsXP and Vista but not ran it on
Vista till now,
I want to send Alt + C and Ctl+S keys to an application without
bringing
it front (say they are minimized).
Please guide on this,

Thanks
Hitendra
On Sep 20, 8:31*pm, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Hi Hitendra,

first of all: What OS are you using: XP and Lower or
Vista based, since there is a big difference and a big
security border you have to pass on Vista. On Vista
you cant just send Keystrokes and Messages to other
Windows and processes as you did in the past,...

See here:

[User Interface Privilege Isolation]http://en.wikipedia.org/wiki/User_Interface_Privilege_Isolation

This must be done, since it was a big security whole
if you knew how to "leverage" it,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project:http://www.codeplex.com/restarts
Latest Open-Source Projects:http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Hiten" <hitendr...@gmail.comschrieb im Newsbeitragnews:16******************************** **@a29g2000pra.googlegroups.com...
Hi,
Please can any one help on how to send ALT+C and CLT+ S key press key
press event to the running application, i tried all possible what I
was able to search on net but not got the result.
Below if the code
public const UInt32 WM_CHAR = 0x0102;
public const UInt32 WM_SYSKEYDOWN = 0x0104;
public const UInt32 WM_KEYDOWN = 0x0100;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, uint
wParam, uint lParam);
public void SendCutomMessage(IntPtr hwnd)
{
* * * PostMessage(hwnd,WM_SYSKEYDOWN ,(unit)'C',0); // For ALT+C
wparam and lparam are correct?
* * * PostMessage(hwnd,WM_SYSKEYDOWN ,(unit)'S',0); // For CLT+S
wparam and lparam are correct?
}
Thanks in advance.....
Hitendra Patel- Hide quoted text -

- Show quoted text -
Sep 21 '08 #3

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

Similar topics

2
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...
15
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
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...
2
by: Lenster | last post by:
When using PostMessage to post myself a message, the msg and wparam parameters somehow get swapped over. They are in the correct order when calling PostMessage but by the time wndproc handles the...
3
by: Max M. Power | last post by:
When I use the SendMessage API I can sucessfully send and receive a user defined message. When I use the PostMessage API I can NOT sucessfully send and receive the same user defined message. ...
11
by: seattleboatguy | last post by:
I am trying to send a message from a visual c++ user-thread to the main window, so the main window can update text on the window to reflect what the user-thread is doing. I have tried 2 different...
3
by: easoftware | last post by:
In my ComboBox, I am trying to post the CBN_EDITCHANGE message after the CBN_SELCHANGE is received, but I am having no luck. I can trap for the CBN_SELCHANGE message, but I cannot post the...
3
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...
10
by: Sergei | last post by:
Can anyone explain why PostMessage to a Windows Form is considered unsafe and raises InvalidOperationException? I can get rid of that setting CheckForIllegalCrossThreadCalls to false and...
21
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.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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
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...

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.