user2740769
user2740769

Reputation: 11

Sending Application Key via SendKeys.Send

I'm making an app that lets you navigate between items using SendKeys. All works pretty well except when I try to send the Application Key (context menu) to do a right click on the selected item.
I use:

SendKeys.Send("{APPSKEY}");

I get an Error saying 'Keyword "APPSKEY" is not valid.'

I googled it and found it on this website:
http://www.autohotkey.com/docs/commands/Send.htm
But i'm guessing that doesn't work for c#.

is there any other way to do a rightclick on the selected item?
is there a way to tell the app where the item is located to move the mouse there and do a right click?

my program can send MouseClicks:

public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention =
CallingConvention.StdCall)]
    public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint 
    cButtons, uint dwExtraInfo);
    private const int MOUSEEVENTF_LEFTDOWN = 0x02;
    private const int MOUSEEVENTF_LEFTUP = 0x04;
    private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
    private const int MOUSEEVENTF_RIGHTUP = 0x10;

    private void MoveCursor(Point loc)
    {
        this.Cursor = new Cursor(Cursor.Current.Handle);
        Cursor.Position = loc;
        Cursor.Clip = new Rectangle(0, 0, 0, 0);
    }

    private void DoMouseClick(bool isLeft)
    {
        int X = Cursor.Position.X;
        int Y = Cursor.Position.Y;
        if (isLeft) mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)X, (uint)Y, 0, 0);
        else mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, (uint)X, (uint)Y, 0, 0);
    }
}

But in order to simulate a right click on that item the app has to know where it is located.

Upvotes: 0

Views: 898

Answers (1)

lostcitizen
lostcitizen

Reputation: 528

Try

SendKeys.Send("+{F10}");

Regards,

Upvotes: 1

Related Questions