.NET Programming
--
Questions
--
Followers
Top Experts
It seems this application doesn't see Alt or Control combinations using
.nets SendKeys.Send
or windows APIs:SendMessage, SendInput, keybd_event, or SetKeyboardState
most of these methods work fine when sending a "normal" key
but when a combination is send the application reacts as if the Alt key was not sent
I have been looking all over the place and it seems it might be because the application the receive the key events uses directx
Any one have any experience with this type of issue.........fyi im working in C#
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Key Code
SHIFT +
CTRL ^
ALT %
To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+EC".
http://msdn2.microsoft.com/en-us/library/system.windows.forms.sendkeys(vs.71).aspx
SendKeys.Send "C" --> will send  C
SendKeys.Send "^C" --> will send ctrl+C






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
using System.Runtime.InteropServ
hWnd = Win32.FindWindow(strClassN
if (hWnd != 0)
{
  bWindow = Win32.SetForegroundWindow(
  System.Windows.Forms.SendK
}
      public class Win32
      {
           [DllImport("user32.dll")]
           public static extern int FindWindow(
                 string lpClassName,  // class name
                 string lpWindowName  // window name
                 );
           [DllImport("user32.dll")]
           public static extern bool SetForegroundWindow(int hWnd);
      }
works with normal key sends, its just when you try and send something like Alt+3 or Sendkeys.send("%(3)")
the direct x application only sees the 3
I spent got portion of time trying to get sendkeys to work as I thought perhaps i was useing wrong
Then I moved on to the APIs listed above.
Another posibly interesting note is spy++ does not see any keyboard messages go to the app

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
So something like this: "%{3}"
used sendinput api and put a delay in between the down and up messages






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
By the way: did you try SendKeys.SendWait or only SendKeys.Send ?
(In the program I've written with the sendkeys I also used small delays between every sendkeys)
sendinput  alt keydown
sendinput  3  keydown
sleep 50
sendinput 3 keyup
sendinput alt keyup
Computer101
EE Admin

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
.NET Programming
--
Questions
--
Followers
Top Experts
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.