如何使用 NSIS 在后台打开第二个 Internet Explorer 窗口

发布于 2024-11-08 20:36:21 字数 374 浏览 2 评论 0原文

这是一个简单的问题,但找不到简单的答案......
我正在 NSIS 中编写脚本,我需要在 Internet Explorer 中打开两个窗口

所以我用...
UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_1' '' ''
然后...
UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_2' '' ''

但我希望 $url_2 在 $url_1 的后面/后台打开
我快要疯了...感谢您的帮助!

ps。只要它启动一个新的 IE 窗口,我就不会被迫使用 UAC::Exec 。

this is a simple question, but can't find an easy answer ...

I am writing a script in NSIS and I need to open two windows in Internet Explorer

So I use ...

UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_1' '' ''

then...

UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_2' '' ''

But I would like the $url_2 to be opened BEHIND/in the background of the one with $url_1

I'm going crazy there... Thanks for any help !

ps. I'm not forced to use UAC::Exec as long as It starts a new IE window.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ヤ经典坏疍 2024-11-15 20:36:21

答案非常简单:只需切换打开窗口的顺序:

UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_2' '' ''
then...
UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_1' '' '' 

因此 $url_2 将位于 $url_1 之后,因为它稍后打开...

编辑

如果您希望在前面有一些确切的窗口必须知道它的名称(IE 在完全加载后将名称设置为窗口)。

使用这个简单的循环将所需的窗口置于前面。 (我使用了 Exec,但与 UAC 和 nsExec 配合使用效果很好)

; This Window is opened as first
Exec '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "www.google.sk"' # $url_1
; This is opened later
Exec '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "www.unsigned-softworks.sk/installer"'  # $url_2

CheckWindow:
  Sleep 500 ; Wait some time (miliseconds)

  ; Find by Window class and by Window name 
  FindWindow $1 "IEFrame" "Google - Windows Internet Explorer" 
  # This name must be known in compile time!!!
  # Get this name by running $url_1 in IE

  ; If window is not found (not loaded!) search again 
  IntCmp $1 0 CheckWindow Continue Continue

Continue:
  # If found (opened & loaded), bring $url_1 to front
  System::Call "User32::SetForegroundWindow(i) b ($1)"

The answer is pretty simple: just switch order of opening windows:

UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_2' '' ''
then...
UAC::Exec '' '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "$url_1' '' '' 

So the $url_2 will be behind $url_1 because it is opened later...

Edit

If you wish to have some exact window in the front you must know it's name (IE set name to window after it is fully loaded).

Use this simple loop to bring required window in the front. (I used Exec, but works fine with UAC and nsExec)

; This Window is opened as first
Exec '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "www.google.sk"' # $url_1
; This is opened later
Exec '"$PROGRAMFILES\Internet Explorer\iexplore.exe" "www.unsigned-softworks.sk/installer"'  # $url_2

CheckWindow:
  Sleep 500 ; Wait some time (miliseconds)

  ; Find by Window class and by Window name 
  FindWindow $1 "IEFrame" "Google - Windows Internet Explorer" 
  # This name must be known in compile time!!!
  # Get this name by running $url_1 in IE

  ; If window is not found (not loaded!) search again 
  IntCmp $1 0 CheckWindow Continue Continue

Continue:
  # If found (opened & loaded), bring $url_1 to front
  System::Call "User32::SetForegroundWindow(i) b ($1)"
倚栏听风 2024-11-15 20:36:21

最好的选择是用 C++ 编写自己的插件并使用 CreateProcess()SetForgroundWindow()

The best option is for you to write your own plugin in c++ and use a combination of CreateProcess() and SetForgroundWindow().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文