Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 5.15 KB | None | 0 0
  1. Global Const $VK_OEM_PLUS = 0xBB
  2. Global Const $VK_OEM_MINUS = 0xBD
  3. Global Const $VK_OEM_3 = 0xC0
  4. Global Const $VK_TAB = 0x9
  5. Global Const $VK_ESC = 0x1B
  6. Global Const $VK_F5 = 0x74
  7. Global Const $VK_F12 = 0x7B
  8.  
  9.  
  10. Dim $hWnd = WingetHandle("window name")
  11.  
  12.  
  13. _SendKeys($hWnd, "123123123"); using send keys
  14. _ArrowKey($hWnd, "UP"); using arrow key
  15. _MouseClick($hWnd, "Left", 300,167, 1, 0); using mouseclick
  16.  
  17.  
  18.  
  19.  
  20.  
  21. Func _MakeLong($LoWord, $HiWord)
  22.     Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
  23. EndFunc
  24. Func _MouseClick($hWnd, $button, $x, $y, $times = 1, $delay = 0)
  25.     Local $ret, $ix
  26.     $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
  27.     If $ret[0] = 0 Then
  28.         SetError(-1)
  29.         Return
  30.     EndIf
  31.     $button = StringLower($button)
  32.     If $button = "left" Then
  33.         For $ix = 1 To $times
  34.             $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", _MakeLong($x, $y))
  35.             If $ret[0] = 0 Then
  36.                 SetError(-2)
  37.                 Return
  38.             Else
  39.                 $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
  40.                 If $ret[0] = 0 Then
  41.                     SetError(-3)
  42.                     Return
  43.                 EndIf
  44.             EndIf
  45.             Sleep($delay)
  46.         Next
  47.     ElseIf $button = "right" Then
  48.         For $ix = 1 To $times
  49.             $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", _MakeLong($x, $y))
  50.             If $ret[0] = 0 Then
  51.                 SetError(-4)
  52.                 Return
  53.             Else
  54.                 $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", _MakeLong($x, $y))
  55.                 If $ret[0] = 0 Then
  56.                     SetError(-5)
  57.                     Return
  58.                 EndIf
  59.             EndIf
  60.             Sleep($delay)
  61.         Next
  62.     Else
  63.         SetError(-6)
  64.         Return
  65.     EndIf
  66. EndFunc
  67.  
  68. Func _SendKeys($hWnd, $keys)
  69.     If $hWnd <= 0 Or StringLen($keys) = 0 Then
  70.         SetError(-1)
  71.         Return False
  72.     EndIf
  73.     $keys = StringUpper($keys)
  74.     $keys = StringReplace($keys, "`", Chr($VK_OEM_3))
  75.     $keys = StringReplace($keys, "~", Chr($VK_OEM_3))
  76.     $keys = StringReplace($keys, "-", Chr($VK_OEM_MINUS))
  77.     $keys = StringReplace($keys, "=", Chr($VK_OEM_PLUS))
  78.     $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
  79.     $keys = StringReplace($keys, "{TAB}", Chr(0x9))
  80.     $keys = StringReplace($keys, "{ESC}", Chr($VK_ESC))
  81.     $keys = StringReplace($keys, "{F5}", Chr($VK_F5))
  82.     $keys = StringReplace($keys, "{F12}", Chr($VK_F12))
  83.     $keys = StringReplace($keys, "{SHIFT}", "+")
  84.     Local $i, $ret
  85.     Local $shiftdown = False
  86.     For $i = 1 To StringLen($keys)
  87.         If StringMid($keys, $i, 1) = "+" Then
  88.             DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
  89.             DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
  90.             $shiftdown = True
  91.             Sleep(1)
  92.             ContinueLoop
  93.         Else
  94.             $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
  95.             If IsArray($ret) Then
  96.                 DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
  97.                 Sleep(1)
  98.                 DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
  99.             EndIf
  100.         EndIf
  101.         If $shiftdown Then
  102.             Sleep(1)
  103.             DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
  104.             $shiftdown = False
  105.         EndIf
  106.     Next
  107.     Return True
  108. EndFunc
  109.  
  110. Func _ArrowKey($hWnd, $key)
  111.     If $hWnd <= 0 Or ($key <> "left" And $key <> "right" And $key <> "up" And $key <> "down") Then
  112.         SetError(-1)
  113.         Return
  114.     EndIf
  115.     Local $wParam, $lParam, $ret
  116.     If $key = "left" Then
  117.         $wParam = 0x25
  118.         $lParam = 0x14B0001
  119.     ElseIf $key = "right" Then
  120.         $wParam = 0x27
  121.         $lParam = 0x14D0001
  122.     ElseIf $key = "down" Then
  123.         $wParam = 0x28
  124.         $lParam = 0x1500001
  125.     ElseIf $key = "up" Then
  126.         $wParam = 0x26
  127.         $lParam = 0x1480001
  128.     EndIf
  129.     $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", $wParam, "int", $lParam)
  130.     If $ret[0] = 0 Then
  131.         MsgBox(16, "_ArrowKey Error", "There was an error posting the WM_KEYDOWN message")
  132.         SetError(-2)
  133.         Return
  134.     EndIf
  135.     Sleep(2)
  136.     $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", $wParam, "int", ($lParam + 0xC0000000))
  137.     If $ret[0] = 0 Then
  138.         MsgBox(16, "_ArrowKey Error", "There was an error posting the WM_KEYUP message")
  139.         SetError(-3)
  140.         Return
  141.     EndIf
  142. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement