Python calls win32pai to operate cmd, pythonwin32pai
Example:
# Coding = utf-8import subprocessfrom time import * import win32apiimport win32conimport win32guisubprocess. popen ('C: \ windows \ system32 \ cmd.exe ') sleep (1) a = 65; B = 66; C = 67; d = 68; e = 69; f = 70; g = 71; h = 72; I = 73; j = 74; k = 75l = 76; m = 77; n = 78; o = 79; p = 80; q = 81; r = 82; s = 83; t = 84; u = 85; v = 86 w = 87; x = 88; y = 89; z = 90; I = 97; ii = 98; iii = 99; iv = 100; five = 101; vi = 102vii = 103; viii = 104; ix = 105; zero = 0; # defines the encoding of common buttons n = win32gui. findWindow ('lelewindowclass', None) # Find the window opened. findwindow (x, y) x indicates the class name, and y indicates the window title p = win32gui. setForegroundWindow (n) # obtain the pointer win32api. keybd_event (d, 0, 0) win32api. keybd_event (s, 0, 0) win32api. keybd_event (m, 0, 0) win32api. keybd_event (o, 0, 0) win32api. keybd_event (v, 0, 0) win32api. keybd_event (e, 0, 0) win32api. keybd_event (13, 0, 0, 0) win32api. keybd_event (13,0, win32con. KEYEVENTF_KEYUP, 0) win32api. keybd_event (13, 0, 0, 0) win32api. keybd_event (13,0, win32con. KEYEVENTF_KEYUP, 0) win32api. keybd_event (,) # tool used to simulate keyboard input to obtain window information: Microsoft Spy ++
The above python method for calling win32pai to operate cmd is all the content that I have shared with you. I hope you can give me a reference and support me a lot.