2017-03-03 77 views
0

鼠標點擊有兩種常見類型:「單擊」或「雙擊」。
例如,該代碼將模擬鼠標點擊如何在屏幕C上的特定位置模擬四鍵鼠標事件#

private const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002; 
private const UInt32 MOUSEEVENTF_LEFTUP = 0x0004; 
[DllImport("user32.dll")] 

private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData,uint dwExtraInf); 

private void button3_Click(object sender, EventArgs e) 
{ 
int x = 450;//set x position 
int y = 250;//set y position 
Cursor.Position = new Point(x, y); 

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);//make left button down 
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);//make left button up 
} 

的原因,我的問題:在Adobe Acrobat Reader:

  1. 單一的鼠標點擊>>>會放置光標
  2. 雙擊>>>將選擇一個單詞
  3. 三重點擊>>>將選擇整單線
  4. 鼠標點擊>>>將在該頁面中選擇的所有文本

enter image description here

  • Ctrl + A >>>選擇此文件中的所有文本(在所有頁面中)。
  • (請注意,5次點擊不會做任何事情,只是取消選擇。)


    UPDATE

    我發現了一個簡單的解決方案:

    private void button2_Click(object sender, EventArgs e) 
           { 
            button3.PerformClick(); // Single mouse click 
            button3.PerformClick(); // Double mouse click 
            button3.PerformClick(); // Triple mouse click 
            button3.PerformClick(); // Quadrilateral mouse click 
           } 
    
    +0

    鼠標雙擊 https://plus.google.com/u/0/105821605186922664636/posts/125TLBLdicB –

    +0

    三重鼠標點擊https://plus.google.com/u/0/105821605186922664636/posts/8h5bFgL3Ea7 –

    +1

    「四擊」是您想要的術語。您向我們展示您的「簡單解決方案」 - 當您嘗試該解決方案時會發生什麼?你還試過了什麼? – SlimsGhost

    回答

    0

    的OP找到了關於如何模擬「四次點擊」(左鍵單擊4倍,快)的答案,這個片段在C#:

    的,給予對象的引用名爲target事件:

    private void QuadClickButton_Click(object sender, EventArgs e) 
    { 
        target.PerformClick(); // Single mouse click 
        target.PerformClick(); // Double mouse click 
        target.PerformClick(); // Triple mouse click 
        target.PerformClick(); // Quadruple mouse click 
    } 
    
    相關問題