2012-06-17 103 views
0

我想知道是否可以按住Shift鍵同時點擊鼠標。單擊時按住Shift?

它看起來simmilar這樣: - 如果你可以模擬鼠標點擊與SendKeys.SendWait功能 - SendKeys.SendWait(+{Mouseclick}); 到目前爲止,我已經叫API「的User32.dll」調用鼠標點擊:

public const int MOUSEEVENTF_LEFTDOWN = 0x2; 
public const int MOUSEEVENTF_LEFTUP = 0x4; 
public const int MOUSEEVENTF_MIDDLEDOWN = 0x20; 
public const int MOUSEEVENTF_MIDDLEUP = 0x40; 
public const int MOUSEEVENTF_RIGHTDOWN = 0x8; 
public const int MOUSEEVENTF_RIGHTUP = 0x10; 
[DllImport("User32.dll")] 
public static extern int mouse_event(int dwFlags, int dx, int dy, int cButton, int dwExtra); 

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); 
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); 

但是;是否可以同時按住Shift鍵?

問候,DotTutorials

回答

2

您應該能夠使用keybd_event功能來模擬Shift鍵。例如:

public const int MOUSEEVENTF_LEFTDOWN = 0x2; 
public const int MOUSEEVENTF_LEFTUP = 0x4; 
public const int MOUSEEVENTF_MIDDLEDOWN = 0x20; 
public const int MOUSEEVENTF_MIDDLEUP = 0x40; 
public const int MOUSEEVENTF_RIGHTDOWN = 0x8; 
public const int MOUSEEVENTF_RIGHTUP = 0x10; 
public const byte KEYBDEVENTF_SHIFTVIRTUAL = 0x10; 
public const byte KEYBDEVENTF_SHIFTSCANCODE = 0x2A; 
public const int KEYBDEVENTF_KEYDOWN = 0; 
public const int KEYBDEVENTF_KEYUP = 2; 
[DllImport("User32.dll")] 
public static extern int mouse_event(int dwFlags, int dx, int dy, int cButton, int dwExtra); 
[DllImport("user32.dll", EntryPoint="keybd_event", CharSet=CharSet.Auto, ExactSpelling=true)] 
public static extern void keybd_event(byte vk, byte scan, int flags, int extrainfo); 

// shift down 
keybd_event(KEYBDEVENTF_SHIFTVIRTUAL, KEYBDEVENTF_SHIFTSCANCODE, KEYBDEVENTF_KEYDOWN, 0); 
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); 
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); 
// shift up 
keybd_event(KEYBDEVENTF_SHIFTVIRTUAL, KEYBDEVENTF_SHIFTSCANCODE, KEYBDEVENTF_KEYUP, 0); 
+0

謝謝你,你沒必要付出太多的努力到答案,但感謝大時間! – dotTutorials

+0

感謝這真的幫了我,一個問題..你在哪裏找到我不能在谷歌做正確的查詢keycodes。 – winthers

相關問題