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

H

Hiten

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
 
K

Kerem Gümrükcü

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

--
 
H

Hiten

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


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."


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 -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top