here2share

# auto_output.py

Apr 20th, 2021 (edited)
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.21 KB | None | 0 0
  1. # auto_output.py
  2.  
  3. import win32api
  4. import win32con
  5. import ctypes
  6. import time
  7.  
  8. VK_CODE = {
  9.     'backspace':0x08,
  10.     'tab':0x09,
  11.     'clear':0x0C,
  12.     'enter':0x0D,
  13.     'shift':0x10,
  14.     'ctrl':0x11,
  15.     'alt':0x12,
  16.     'pause':0x13,
  17.     'caps_lock':0x14,
  18.     'esc':0x1B,
  19.     'spacebar':0x20,
  20.     'page_up':0x21,
  21.     'page_down':0x22,
  22.     'end':0x23,
  23.     'home':0x24,
  24.     'left_arrow':0x25,
  25.     'up_arrow':0x26,
  26.     'right_arrow':0x27,
  27.     'down_arrow':0x28,
  28.     'select':0x29,
  29.     'print':0x2A,
  30.     'execute':0x2B,
  31.     'print_screen':0x2C,
  32.     'ins':0x2D,
  33.     'del':0x2E,
  34.     'help':0x2F,
  35.     '0':0x30,
  36.     '1':0x31,
  37.     '2':0x32,
  38.     '3':0x33,
  39.     '4':0x34,
  40.     '5':0x35,
  41.     '6':0x36,
  42.     '7':0x37,
  43.     '8':0x38,
  44.     '9':0x39,
  45.     'a':0x41,
  46.     'b':0x42,
  47.     'c':0x43,
  48.     'd':0x44,
  49.     'e':0x45,
  50.     'f':0x46,
  51.     'g':0x47,
  52.     'h':0x48,
  53.     'i':0x49,
  54.     'j':0x4A,
  55.     'k':0x4B,
  56.     'l':0x4C,
  57.     'm':0x4D,
  58.     'n':0x4E,
  59.     'o':0x4F,
  60.     'p':0x50,
  61.     'q':0x51,
  62.     'r':0x52,
  63.     's':0x53,
  64.     't':0x54,
  65.     'u':0x55,
  66.     'v':0x56,
  67.     'w':0x57,
  68.     'x':0x58,
  69.     'y':0x59,
  70.     'z':0x5A,
  71.     'numpad_0':0x60,
  72.     'numpad_1':0x61,
  73.     'numpad_2':0x62,
  74.     'numpad_3':0x63,
  75.     'numpad_4':0x64,
  76.     'numpad_5':0x65,
  77.     'numpad_6':0x66,
  78.     'numpad_7':0x67,
  79.     'numpad_8':0x68,
  80.     'numpad_9':0x69,
  81.     'multiply_key':0x6A,
  82.     'add_key':0x6B,
  83.     'separator_key':0x6C,
  84.     'subtract_key':0x6D,
  85.     'decimal_key':0x6E,
  86.     'divide_key':0x6F,
  87.     'F1':0x70,
  88.     'F2':0x71,
  89.     'F3':0x72,
  90.     'F4':0x73,
  91.     'F5':0x74,
  92.     'F6':0x75,
  93.     'F7':0x76,
  94.     'F8':0x77,
  95.     'F9':0x78,
  96.     'F10':0x79,
  97.     'F11':0x7A,
  98.     'F12':0x7B,
  99.     'F13':0x7C,
  100.     'F14':0x7D,
  101.     'F15':0x7E,
  102.     'F16':0x7F,
  103.     'F17':0x80,
  104.     'F18':0x81,
  105.     'F19':0x82,
  106.     'F20':0x83,
  107.     'F21':0x84,
  108.     'F22':0x85,
  109.     'F23':0x86,
  110.     'F24':0x87,
  111.     'num_lock':0x90,
  112.     'scroll_lock':0x91,
  113.     'left_shift':0xA0,
  114.     'right_shift ':0xA1,
  115.     'left_control':0xA2,
  116.     'right_control':0xA3,
  117.     'left_menu':0xA4,
  118.     'right_menu':0xA5,
  119.     'browser_back':0xA6,
  120.     'browser_forward':0xA7,
  121.     'browser_refresh':0xA8,
  122.     'browser_stop':0xA9,
  123.     'browser_search':0xAA,
  124.     'browser_favorites':0xAB,
  125.     'browser_start_and_home':0xAC,
  126.     'volume_mute':0xAD,
  127.     'volume_Down':0xAE,
  128.     'volume_up':0xAF,
  129.     'next_track':0xB0,
  130.     'previous_track':0xB1,
  131.     'stop_media':0xB2,
  132.     'play/pause_media':0xB3,
  133.     'start_mail':0xB4,
  134.     'select_media':0xB5,
  135.     'start_application_1':0xB6,
  136.     'start_application_2':0xB7,
  137.     'attn_key':0xF6,
  138.     'crsel_key':0xF7,
  139.     'exsel_key':0xF8,
  140.     'play_key':0xFA,
  141.     'zoom_key':0xFB,
  142.     'clear_key':0xFE,
  143.     '+':0xBB,
  144.     ',':0xBC,
  145.     '-':0xBD,
  146.     '.':0xBE,
  147.     '/':0xBF,
  148.     '`':0xC0,
  149.     ';':0xBA,
  150.     '[':0xDB,
  151.     '\\':0xDC,
  152.     ']':0xDD,
  153.     "'":0xDE}
  154. VK_CODE1 = {
  155.     'A':'a',
  156.     'B':'b',
  157.     'C':'c',
  158.     'D':'d',
  159.     'E':'e',
  160.     'F':'f',
  161.     'G':'g',
  162.     'H':'h',
  163.     'I':'i',
  164.     'J':'j',
  165.     'K':'k',
  166.     'L':'l',
  167.     'M':'m',
  168.     'N':'n',
  169.     'O':'o',
  170.     'P':'p',
  171.     'Q':'q',
  172.     'R':'r',
  173.     'S':'s',
  174.     'T':'t',
  175.     'U':'u',
  176.     'V':'v',
  177.     'W':'w',
  178.     'X':'x',
  179.     'Y':'y',
  180.     'Z':'z',
  181.     ')':'0',
  182.     '!':'1',
  183.     '@':'2',
  184.     '#':'3',
  185.     '$':'4',
  186.     '%':'5',
  187.     '^':'6',
  188.     '&':'7',
  189.     '*':'8',
  190.     '(':'9',
  191.     '=':'+',
  192.     '<':',',
  193.     '_':'-',
  194.     '>':'.',
  195.     '?':'/',
  196.     '~':'`',
  197.     ':':';',
  198.     '{':'[',
  199.     '|':'\\',
  200.     '}':']',
  201.     '"':"'"}
  202. class Point(ctypes.Structure):
  203.     _fields_=[("x",ctypes.c_long),("y",ctypes.c_long)]
  204. def mouse_get_point():
  205.     po=Point()
  206.     ctypes.windll.user32.GetCursorPos(ctypes.byref(po))
  207.     return int(po.x),int(po.y)
  208. def mouse_down():
  209.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  210. def mouse_up():
  211.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  212. def mouse_click(x=None,y=None):#Simulate mouse click
  213.     if not x is None and not y is None:
  214.         mouse_move(x,y)
  215.         time.sleep(0.05)
  216.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  217.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  218. def mouse_rclick(x=None,y=None):#Simulate mouse click
  219.     if not x is None and not y is None:
  220.         mouse_move(x,y)
  221.         time.sleep(0.05)
  222.     win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
  223.     win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
  224. def mouse_dclick(x=None,y=None):#Simulate mouse double click
  225.     if not x is None and not y is None:
  226.         mouse_move(x,y)
  227.         time.sleep(0.05)
  228.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)#Press the left mouse button
  229.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)#Release the left mouse button
  230.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
  231.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
  232. def mouse_move(x,y):
  233.     ctypes.windll.user32.SetCursorPos(x, y)#Move the mouse to the corresponding position but do not click
  234. def key_autoinput(str_input=''):#Automatically recognize the up-shift key and down-file build and output
  235.     for c in str_input:
  236.         if c in VK_CODE1:
  237.             win32api.keybd_event(VK_CODE['shift'],0,0,0)#Button
  238.             win32api.keybd_event(VK_CODE[VK_CODE1[c]],0,0,0)#Button
  239.             win32api.keybd_event(VK_CODE['shift'],0,win32con.KEYEVENTF_KEYUP,0)#Release the button
  240.             win32api.keybd_event(VK_CODE[VK_CODE1[c]],0,win32con.KEYEVENTF_KEYUP,0)#Release the button
  241.             time.sleep(0.05)#Delay1second
  242.         else:
  243.             win32api.keybd_event(VK_CODE[c],0,0,0)#Button
  244.             win32api.keybd_event(VK_CODE[c],0,win32con.KEYEVENTF_KEYUP,0)#Release the button
  245.             time.sleep(0.05)#Delay1second
  246.            
  247. def key_continput(str_input=''):#Contact Press the button and release continuously
  248.     for c in str_input:
  249.         if c in VK_CODE1:
  250.             #win32api.keybd_event(VK_CODE['shift'],0,0,0)#Key
  251.             win32api.keybd_event(VK_CODE[VK_CODE1[c]],0,0,0)#Button
  252.             #win32api.keybd_event(VK_CODE['shift'],0,win32con.KEYEVENTF_KEYUP,0)#Release the key
  253.             #win32api.keybd_event(VK_CODE[VK_CODE1[c]],0,win32con.KEYEVENTF_KEYUP,0)#Release the key
  254.             time.sleep(0.05)#Delay1second
  255.         else:
  256.             win32api.keybd_event(VK_CODE[c],0,0,0)#Button
  257.             #win32api.keybd_event(VK_CODE[c],0,win32con.KEYEVENTF_KEYUP,0)#Release the key
  258.             time.sleep(0.05)#Delay1second
  259.     for c in str_input:    
  260.         if c in VK_CODE1:
  261.             win32api.keybd_event(VK_CODE[VK_CODE1[c]],0,win32con.KEYEVENTF_KEYUP,0)#Release the button
  262.             time.sleep(0.05)#Delay1second
  263.         else:
  264.             win32api.keybd_event(VK_CODE[c],0,win32con.KEYEVENTF_KEYUP,0)#Release the button
  265.             time.sleep(0.05)#Delay1second
  266. def key_shift_down():
  267.     win32api.keybd_event(VK_CODE["shift"],0,0,0)#Press the shift key
  268. def key_shift_up():
  269.     win32api.keybd_event(VK_CODE["shift"],0,win32con.KEYEVENTF_KEYUP,0)#Press the shift key
  270.  
  271. #if __name__ == "__main__":
  272.     #mouse_click(1024,470)
  273.     #str_input = '~!@#$a%^d&*(s)_s+{}f|":h?>A<'
  274.     #key_autoinput(str_input)
  275.     #key_continput(("ctrl","a"))
Add Comment
Please, Sign In to add comment