python calls the win32pai method that operates on cmd

  • 2020-06-03 07:04:08
  • OfStack

Examples are as follows:


#coding=utf-8
import subprocess
from time import *
import win32api
import win32con
import win32gui
subprocess.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=75
l=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=102
vii=103;viii=104;ix=105;zero=0;

# Defines the code of the commonly used keys 
n=win32gui.FindWindow('ConsoleWindowClass',None)

# Look for an open window, findwindow ( x,y ) x It's the category name, y It's the window title 
p=win32gui.SetForegroundWindow(n)

# To obtain a pointer 
win32api.keybd_event(d,0,0,0)
win32api.keybd_event(s,0,0,0)
win32api.keybd_event(m,0,0,0)
win32api.keybd_event(o,0,0,0)
win32api.keybd_event(v,0,0,0)
win32api.keybd_event(e,0,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(13,0,0,0)
# Analog keyboard input 

 Tools for obtaining window information: Microsoft Spy++ 

Related articles: