Advertisement
TrunghieuTH10

Click_WinAPI_PostMessage

Nov 12th, 2015
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.28 KB | None | 0 0
  1. #RequireAdmin
  2. ;Trunghieuth10 - http://facebook.com/trunghieuth10
  3.  
  4. #include <WinAPI.au3>
  5. Global Const $API_MOUSEMOVE              = 0x200
  6. Global Const $API_LBUTTONDOWN            = 0x201
  7. Global Const $API_LBUTTONUP              = 0x202
  8. Global Const $API_MBUTTONDOWN            = 0x207
  9. Global Const $API_MBUTTONUP              = 0x208
  10. Global Const $API_RBUTTONDOWN            = 0x204
  11. Global Const $API_RBUTTONUP              = 0x205
  12. Global Const $API_NCLBUTTONDOWN          = 0xA1
  13. Global Const $API_LBUTTONDBLCLK          = 0x203
  14. Global Const $API_MBUTTONDBLCLK          = 0x209
  15. Global Const $API_RBUTTONDBLCLK          = 0x206
  16. Global Const $API_LBUTTON                = 0x1
  17. Global Const $API_MBUTTON                = 0x10
  18. Global Const $API_RBUTTON                = 0x2
  19. Global Const $API_SETREDRAW              = 0xB
  20. Global Const $API_ERASEBKGND             = 0x14
  21. Const $API_CONTROL                       = 0x8
  22.  
  23. Func _MouseClick_WinAPI($hwnd, $x=0, $y=0, $button='Left', $click = 1)
  24.         $lParam = ($y * 65536) + ($x)
  25.         For $k = 1 To $click
  26.                 Switch $button
  27.                         Case $button='Left'
  28.                                 _WinAPI_PostMessage($hwnd, $API_LBUTTONDOWN, $API_LBUTTON,$lParam)
  29.                                 _WinAPI_PostMessage($hwnd, $API_LBUTTONUP, 0,$lParam)
  30.                         Case $button='Left Double'
  31.                                 _WinAPI_PostMessage($hwnd, $API_LBUTTONDOWN, $API_LBUTTON,$lParam)
  32.                                 _WinAPI_PostMessage($hwnd, $API_LBUTTONUP, 0,$lParam)
  33.                                 _WinAPI_PostMessage($hwnd, $API_LBUTTONDBLCLK, $API_LBUTTON,$lParam)
  34.                                 _WinAPI_PostMessage($hwnd, $API_LBUTTONUP, 0,$lParam)
  35.                         Case $button='Middle'
  36.                                 _WinAPI_PostMessage($hwnd, $API_MBUTTONDOWN, $API_MBUTTON,$lParam)
  37.                                 _WinAPI_PostMessage($hwnd, $API_MBUTTONUP, 0,$lParam)
  38.                         Case $button='Middle Double'
  39.                                 _WinAPI_PostMessage($hwnd, $API_MBUTTONDOWN, $API_MBUTTON,$lParam)
  40.                                 _WinAPI_PostMessage($hwnd, $API_MBUTTONUP, 0,$lParam)
  41.                                 _WinAPI_PostMessage($hwnd, $API_MBUTTONDBLCLK, $API_MBUTTON,$lParam)
  42.                                 _WinAPI_PostMessage($hwnd, $API_MBUTTONUP, 0,$lParam)
  43.                         Case $button='Right'
  44.                                 _WinAPI_PostMessage($hwnd, $API_RBUTTONDOWN, $API_RBUTTON,$lParam)
  45.                                 _WinAPI_PostMessage($hwnd, $API_RBUTTONUP, 0,$lParam)
  46.                         Case $button='Right Double'
  47.                                 _WinAPI_PostMessage($hwnd, $API_RBUTTONDOWN, $API_RBUTTON,$lParam)
  48.                                 _WinAPI_PostMessage($hwnd, $API_RBUTTONUP, 0,$lParam)
  49.                                 _WinAPI_PostMessage($hwnd, $API_RBUTTONDBLCLK, $API_RBUTTON,$lParam)
  50.                                 _WinAPI_PostMessage($hwnd, $API_RBUTTONUP, 0,$lParam)
  51.                         Case $button='Move'
  52.                                 _WinAPI_PostMessage($hwnd, $API_MOUSEMOVE, 0,$lParam)
  53.                                 _WinAPI_PostMessage($hwnd, $API_MOUSEMOVE, 0,$lParam)
  54.                 EndSwitch
  55.         Next
  56. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement