首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python win32com SendKeys失败

Python win32com SendKeys失败
EN

Stack Overflow用户
提问于 2016-02-08 21:49:54
回答 1查看 2.6K关注 0票数 2

我试着做按钮按下测试,每次我做的时候,它在某个地方失败了。总是有两个(或更多)小写字母相邻或两个大写字母的地方。为什么会这样呢?

代码语言:javascript
复制
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("notepad")
shell.AppActivate("Notepad")


def a():
    shell.SendKeys("{a}", 0)


def A():
    shell.SendKeys("{A}", 0)


def b():
    shell.SendKeys("{b}", 0)


def B():
    shell.SendKeys("{B}", 0)


def c():
    shell.SendKeys("{c}", 0)


def C():
    shell.SendKeys("{C}", 0)


def d():
    shell.SendKeys("{d}", 0)


def D():
    shell.SendKeys("{D}", 0)


def e():
    shell.SendKeys("{e}", 0)


def E():
    shell.SendKeys("{E}", 0)


def f():
    shell.SendKeys("{f}", 0)


def F():
    shell.SendKeys("{F}", 0)


def g():
    shell.SendKeys("{g}", 0)


def G():
    shell.SendKeys("{G}", 0)


def h():
    shell.SendKeys("{h}", 0)


def H():
    shell.SendKeys("{H}", 0)


def i():
    shell.SendKeys("{i}", 0)


def I():
    shell.SendKeys("{I}", 0)


def j():
    shell.SendKeys("{j}", 0)


def J():
    shell.SendKeys("{J}", 0)


def k():
    shell.SendKeys("{k}", 0)


def K():
    shell.SendKeys("{K}", 0)


def l():
    shell.SendKeys("{l}", 0)


def L():
    shell.SendKeys("{L}", 0)


def m():
    shell.SendKeys("{m}", 0)


def M():
    shell.SendKeys("{M}", 0)


def n():
    shell.SendKeys("{n}", 0)


def N():
    shell.SendKeys("{N}", 0)


def o():
    shell.SendKeys("{o}", 0)


def O():
    shell.SendKeys("{O}", 0)


def p():
    shell.SendKeys("{p}", 0)


def P():
    shell.SendKeys("{P}", 0)


def q():
    shell.SendKeys("{q}", 0)


def Q():
    shell.SendKeys("{Q}", 0)


def r():
    shell.SendKeys("{r}", 0)


def R():
    shell.SendKeys("{R}", 0)


def s():
    shell.SendKeys("{s}", 0)


def S():
    shell.SendKeys("{S}", 0)


def t():
    shell.SendKeys("{t}", 0)


def T():
    shell.SendKeys("{T}", 0)


def u():
    shell.SendKeys("{u}", 0)


def U():
    shell.SendKeys("{U}", 0)


def w():
    shell.SendKeys("{w}", 0)


def W():
    shell.SendKeys("{W}", 0)


def x():
    shell.SendKeys("{x}", 0)


def X():
    shell.SendKeys("{X}", 0)


def y():
    shell.SendKeys("{y}", 0)


def Y():
    shell.SendKeys("{Y}", 0)


def z():
    shell.SendKeys("{z}", 0)


def Z():
    shell.SendKeys("{Z}", 0)


def enter():
    shell.SendKeys("{ENTER}", 0)

a(), A(), b(), B(), c(), C(), d(), D(), e(), E(), f(), F(), g(), G(), h(), H(), i(), I(), j(), J(), k(), K(),
l(), L(), m(), M(), n(), N(), o(), O(), p(), P(), q(), Q(), r(), R(), s(), S(), t(), T(), u(), U(), w(), W(),
x(), X(), y(), Y(), z(), Z(), enter(),

预期产出:"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUwWxXyYzZ“

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-11 15:36:52

在每次按下修复问题后添加time.sleep(0.03)及以上。仍然不知道为什么记事本没有正确解释键。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35280012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档