如何在Python(2.7)中运行自动热键脚本

2024-10-01 17:25:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Python2.7中运行一个自动热键(ahk)脚本,但似乎没有任何工作。我发现的所有在线资源要么过时,要么过于复杂。在

有人找到一种方法吗?我只想运行几个简单的脚本来激活windows并打开应用程序。E、 g组:

IfWinExist, Command Prompt - python ...
    WinActivate

更新:

我试过下载pyahk:

^{pr2}$

错误:无法加载自动热键.dll在

除了试试这个:

import win32com.client # Import library / module
dll = win32com.client.Dispatch("AutoHotkey.Script") #Creating DLL object?
dll.ahktextdll() #no idea what this is doing...        
dll.ahkExec("WinActivate, Command Prompt - python")

在pwintypes.com_错误类字符串无效


Tags: 方法脚本client应用程序windows错误资源prompt

热门问题