0

こんにちは私はac#アプリケーションとその中に埋め込まれたブラウザを持っています、そのタスクはリンクを見つけてそれを右クリックしてプロパティをクリックすることです!

マウスはプログラムで動くので、右クリックメニューでプロパティを見つける必要があります!

これを行う方法を教えてもらえますか?

右クリック後に「r」を押してみましたが、一部のコンピューターでは機能しませんでした。

だから私はマウスを動かしてそれをする必要があります!

リンクを見つけて右クリックするための私のコードは次のとおりです。

int x = getXoffset(link);
int y = getYoffset(link);
webBrowser1.Document.Window.ScrollTo(x, y);
Linker.Win32.POINT p2 = new Linker.Win32.POINT();
webBrowser1.Focus();
p2.x = webBrowser1.Left + 10;
p2.y = webBrowser1.Top + 5;
Linker.Win32.ClientToScreen(this.Handle, ref p2);
Linker.Win32.SetCursorPos(p2.x, p2.y);
MouseOperations.GetCursorPosition();

MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);

右クリックでプロパティに到達するための他のアイデアは大歓迎です

4

1 に答える 1

0

このコードを使用します:

 [DllImport("user32.dll", SetLastError = true)]
        static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
        public static void PressKey(Keys key, bool up)
        {
            const int KEYEVENTF_EXTENDEDKEY = 0x1;
            const int KEYEVENTF_KEYUP = 0x2;
            if (up)
            {
                keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
            }
            else
            {
                keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            webBrowser1.Navigate("http://google.com");//Your link
            webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); 
        }

        void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //Find your link and right click(automatically by your code)
            webBrowser1.Document.MouseDown += new HtmlElementEventHandler(Document_MouseDown);
        }

        void Document_MouseDown(object sender, HtmlElementEventArgs e)
        {
            if (e.MouseButtonsPressed == MouseButtons.Right)
            {
                Thread.Sleep(1000);
                PressKey(Keys.P, true);
                PressKey(Keys.P, false);
            }
        }
于 2012-08-29T17:26:18.483 に答える