4
A
回答
6
下面我們來設置鼠標的位置並進行點擊:
public static void ClickSomePoint() {
// Set the cursor position
System.Windows.Forms.Cursor.Position = new Point(20, 35);
DoClickMouse(0x2); // Left mouse button down
DoClickMouse(0x4); // Left mouse button up
}
static void DoClickMouse(int mouseButton) {
var input = new INPUT() {
dwType = 0, // Mouse input
mi = new MOUSEINPUT() { dwFlags = mouseButton }
};
if (SendInput(1, input, Marshal.SizeOf(input)) == 0) {
throw new Exception();
}
}
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT {
int dx;
int dy;
int mouseData;
public int dwFlags;
int time;
IntPtr dwExtraInfo;
}
struct INPUT {
public uint dwType;
public MOUSEINPUT mi;
}
[DllImport("user32.dll", SetLastError=true)]
static extern uint SendInput(uint cInputs, INPUT input, int size);
只要記住,這可能是非常惱人的用戶。
:)
如果你想單擊窗體上的按鈕,你可以使用'PerformClick()'
方法。
相關問題
- 1. 如何在C上設置鼠標光標位置?
- 2. C#如何獲取屏幕上特定點的座標。 (不是鼠標位置)
- 3. 多屏幕系統C中的鼠標光標位置
- 4. firemonkey設置鼠標光標位置
- 5. 忙光標位置在屏幕上
- 6. 如何將光標置於屏幕外?
- 7. PyGame從位圖設置鼠標光標
- 8. 在mac上的visual studio中設置鼠標光標位置
- 9. 如何在屏幕C上的特定位置模擬四鍵鼠標事件#
- 10. C#如何在屏幕上的特定鼠標位置顯示錶單?
- 11. 如何將屏幕座標轉換爲android中的位置點
- 12. SharpDX如何讓鼠標在遊戲屏幕上的位置
- 13. 將鼠標指針設置爲另一種形式的位置
- 14. 如何在屏幕上只在鼠標位置blit
- 15. 如何在WPF屏幕上獲取鼠標位置?
- 16. 鼠標光標在Javascript中的位置?
- 17. 如何在屏幕上的某個位置模擬鼠標點擊?
- 18. C++ win32設置光標位置
- 19. 如何在Windows Forms C#中僞造鼠標光標位置?
- 20. 設置光標位置
- 21. 設置光標位置
- 22. 如何在背景中檢查鼠標在屏幕上的位置? (Cocoa/Objective C)
- 23. 如何設置鼠標位置?
- 24. 設置鼠標位置
- 25. 在textview上設置光標位置
- 26. 如何讓鼠標在imageview的點擊位置上定位?
- 27. 鼠標光標位置改變
- 28. 如何將光標位置設置爲其默認值
- 29. 屏幕上任意位置的光標下的RGB值
- 30. 在flex中的屏幕上的鼠標位置
立即跳入腦海的問題是'爲什麼'? – 2009-09-08 05:47:45
在我腦海中做點事情。爲什麼? – Sherif 2009-09-08 05:49:09
@MatthewScharley我來這裏是爲了「自動化」.. – 2013-06-08 13:20:38