使用自定义网址打开一个新的Chrome窗口,然后使用Autohotkey获得相同的窗口吗?

杰克

我正在尝试使用-app标志打开一个Chrome实例,然后将其移至该窗口并通常对其进行处理。这是我的代码:

#!NumpadMult::
{
    Gui, Show , w260 h150, Window title
    Gui, Add, Edit, w100 vCustomUrl, http://
    Gui, Add, Button, default, OK  ; The label ButtonOK (if it exists) will be run when the button is pressed.

    ButtonOk:
    Gui, Submit
    Gui, Destroy
    URL = %customUrl%

    MyWidth = 639
    MyHeight = 389
    Run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --app=data:text/html`,<html><body><script>window.resizeTo(%MyWidth%`,%MyHeight%)`;window.location='%URL%'`;</script></body></html>

    return
}

到目前为止,这是我找到的最好的方式来打开Chrome窗口并四处移动,因为我不知道如何在我不知道标题的特定Chrome窗口上实际执行WinWait。如果我尝试Run吐出一个pidpid则该代码与任何现有的Chrome进程相同,因此我得到的窗口不一定是我创建的窗口。

有任何想法吗?如果需要,我很乐意提供更多信息。

用户名
MyWidth = 639
MyHeight = 389

InputBox, customUrl, Custom Url, Enter an URL., , 1000, 120
if ErrorLevel
    return
run % "chrome.exe" ( winExist("ahk_class Chrome_WidgetWin_1") ? " --new-window " : " " ) customUrl      ; https://autohotkey.com/board/topic/82062-open-google-chrome-in-new-instance/
ID := WinWaitCreated("ahk_class Chrome_WidgetWin_1")
WinWait, ahk_id %ID%
WinMove, ahk_id %ID%,,,,%MyWidth%,%MyHeight%
IfWinNotActive, ahk_id %ID%, ,WinActivate,ahk_id %ID%
return


WinWaitCreated( WinTitle:="", WinText:="", Seconds:=0, ExcludeTitle:="", ExcludeText:="" ) {
    ; HotKeyIt - http://ahkscript.org/boards/viewtopic.php?t=1274
    static Found := 0, _WinTitle, _WinText, _ExcludeTitle, _ExcludeText 
         , init := DllCall( "RegisterShellHookWindow", "UInt",A_ScriptHwnd )
         , MsgNum := DllCall( "RegisterWindowMessage", "Str","SHELLHOOK" )
         , cleanup:={base:{__Delete:"WinWaitCreated"}}
  If IsObject(WinTitle)   ; cleanup
    return DllCall("DeregisterShellHookWindow","PTR",A_ScriptHwnd)
  else if (Seconds <> MsgNum){ ; User called the function
    Start := A_TickCount, _WinTitle := WinTitle, _WinText := WinText
    ,_ExcludeTitle := ExcludeTitle, _ExcludeText := ExcludeText
    ,OnMessage( MsgNum, A_ThisFunc ),  Found := 0
    While ( !Found && ( !Seconds || Seconds * 1000 < A_TickCount - Start ) ) 
      Sleep 16                                                         
    Return Found,OnMessage( MsgNum, "" )
  }
  If ( WinTitle = 1   ; window created, check if it is our window
    && ExcludeTitle = A_ScriptHwnd
    && WinExist( _WinTitle " ahk_id " WinText,_WinText,_ExcludeTitle,_ExcludeText))
    WinWait % "ahk_id " Found := WinText ; wait for window to be shown
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在 Xamarin.Mac 中从其他人打开一个新的自定义窗口

使用 c# 打开一个新的 Outlook 2016 窗口

使用依赖注入在Windows窗体中打开一个新的参数化窗口

打开一个新窗口然后提交表单

尝试打开一个新的 cmd 窗口,然后在其中运行多个命令

如何从窗口管理器的键盘绑定中,在与上次使用的终端相同的目录中打开一个新终端?

我需要使用自定义网址在新窗口中打开LinkedIn共享而不是新标签页

打开一个新窗口

exe打开一个窗口,但窗口卡住然后崩溃

Mac:在Filezilla中使用Sublime文本进行编辑总是会打开一个新的Sublime窗口

我可以使用 cron 启动 Perl 脚本,但我可以让它打开一个窗口吗?

使用javascript按下按钮时,如何打开一个窗口并关闭另一个窗口?

隐身窗口中的chrome.tabs.create在普通窗口中打开一个标签

如果Apple Script没有(或只是信息窗口),则打开一个新的Finder窗口?

如何仅打开一个窗口弹出窗口

使用 MVC 在加载时自动打开一个弹出窗口

使用Pyglet进行多重处理会打开一个新窗口

使用 Tkinter 从这个脚本打开一个窗口

根据页面的当前网址打开一个新窗口

如何使用JSch打开一个会话,关闭该会话,然后使用相同的凭据打开一个新会话?

使用与原始窗口相同的SSH会话打开另一个终端窗口

为什么在 cmd 中使用命令 START 打开 MP3 文件时会打开一个新的 CMD 窗口?

signInWithPopup无法打开弹出窗口。而是打开一个新标签

在 macOS 上,如何从终端打开一个新的 Chrome 窗口而不是一个新的选项卡(即 Bash 命令)

以编程方式打开一个新窗口(或新选项卡),而不总是打开一个弹出窗口

如何打开一个新的空白窗口并使新的空白窗口在 Javascript 中显示警报?

如何自定义一个窗口来拍照

简单的Chrome扩展程序:在新标签页中打开一个网址

如何在多个Chrome窗口中打开一个网页以进行屏幕尺寸测试