gpt4 book ai didi

python - 如何在 pyautoit 中带来一个始终出现在背景而不是前景中的窗口?

转载 作者:可可西里 更新时间:2023-11-01 09:33:18 26 4
gpt4 key购买 nike

当我点击一个新窗口按钮时,它总是在 Windows 7 64 位操作系统的后台打开。

对于我的自动化任务,我需要将该窗口置于前台。

以下是我的 pyautoit 代码:

autoit.send("{TAB 2}")
sleep(3)
autoit.send("{ENTER}") # After this step new window appears in background
Wnd = autoit.win_wait("[CLASS:#32770]", 15)
autoit.win_activate(Wnd)
sleep(5)
autoit.send("{ENTER}")

我试过 win_wait 和 win_activate,如下所示:

Wnd = autoit.win_wait("[CLASS:#32770]", 15) 
autoit.win_activate(Wnd)

但我收到以下错误:

WindowsError: exception: access violation reading 0x00000001

然后我尝试了“regedit”选项,如下面的 URL 所示:

http://ask.brothersoft.com/when-i-open-a-program-window-sometimes-it-opens-in-the-background-instead-of-the-foreground-253939.html

但是没有用。我仍然看到同样的问题。

有人可以帮我解决这个问题吗?

最佳答案

我会这样做:

AutoIt.Send("{TAB 2}")
Sleep(3)
AutoIt.Send("{ENTER}")
AutoIt.WinWaitActive("[CLASS:#32770]", 15)
AutoIt.WinActivate("[CLASS:#32770]")
Sleep(5)
AutoIt.Send("{ENTER}")

Or use Alt-Tabs

AutoIt.Send("{TAB 2}")
Sleep(3)
AutoIt.Send("{ENTER}")
Sleep(1)
AutoIt.Send("{ALT DOWN}")
AutoIt.Send("{TAB}")
AutoIt.Send("{ALT UP}")
Sleep(5)
AutoIt.Send("{ENTER}")

也不要使用 CLASS,只需使用窗口的名称,如:

AutoIt.WinWaitActive("Setup", 15)

关于python - 如何在 pyautoit 中带来一个始终出现在背景而不是前景中的窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33010882/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com