在NSIS中调用两个浏览器窗口时,如何确保最后一个获得焦点?
我有这个 nsis 脚本,
……
nsExec::Exec "openFirstWindow.exe" ;HERE This exe will open a FIRST WINDOW to whatever url
Pop $exe_return_code
StrCmp $exe_return_code "0" exe_success
Goto exe_done
exe_success:
;HERE is the call to the SECOND WINDOW
UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "http://www.google.ca"' '' ''
exe_done:
,
问题是,随机地,我在前台获得 FIRST 窗口,在后面获得 SECOND 窗口 有时我会在第一窗口前面看到第二窗口。
我的猜测是,这是由于 FIRST 窗口需要随机时间打开并且 如果SECOND窗口在FIRST窗口之前完成打开,则FIRST窗口将获得焦点并位于顶部。
有谁有解决方案来确保SECOND窗口具有焦点?
谢谢你!
I have this nsis script,
...
nsExec::Exec "openFirstWindow.exe" ;HERE This exe will open a FIRST WINDOW to whatever url
Pop $exe_return_code
StrCmp $exe_return_code "0" exe_success
Goto exe_done
exe_success:
;HERE is the call to the SECOND WINDOW
UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "http://www.google.ca"' '' ''
exe_done:
...
The problem is that randomly, I get the FIRST window in foreground and the SECOND behind,
and sometimes I get the SECOND window in front of the FIRST.
My guess is that it is due to the FIRST window taking random time to open and
if the SECOND window finishes opening before the FIRST one, then the FIRST one will get the focus and be on top.
Does anyone have a solution to make sure that the SECOND window has focus ?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是一个简单的问题,因为打开网页是异步的:您不知道加载何时完成。一个优雅的解决方案是从浏览器获取第一页已加载的反馈,但这需要大量工作,因为您必须支持每个浏览器。顺便说一句,你强制使用 IE,这不是一个好主意,你应该使用用户的默认浏览器
也许一些 AutoIt< /a> 脚本可以监视并等待浏览器窗口/选项卡打开。
或者只需在两次通话之间等待几秒钟。
编辑
请参阅这篇文章 还有这个
This is not a simple problem, because opening a web page is asynchronous: you don't know when the loading has finished. An elegant solution would be to have a feedback from the browser that the first page has loaded, but it's a lot of work since you'd have to support every browser. By the way you force the use of IE, it's not a good idea, you should use the user's default browser
Maybe some AutoIt script can watch and wait for the browser window/tab to open.
Or simply wait for a few seconds between both calls.
EDIT
See this post and this one too
使用这个简单的循环将所需的窗口置于前面。 (我使用了 Exec,但与 UAC 和 nsExec 配合使用效果很好)
Use this simple loop to bring required window in the front. (I used Exec, but works fine with UAC and nsExec)