Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 如何使用cmd打开最小化的chrome_Google Chrome_Cmd_Command_Minimize - Fatal编程技术网

Google chrome 如何使用cmd打开最小化的chrome

Google chrome 如何使用cmd打开最小化的chrome,google-chrome,cmd,command,minimize,Google Chrome,Cmd,Command,Minimize,我正在使用python编写一个脚本,以帮助我管理打开的浏览器页面。 我正在使用os.system(“开始…”)打开chrome,我希望它作为一个最小化的程序打开 我注意到,我不能使用flag/min(我尝试了“start/min chrome www.google.com”)来完成这项工作,不是从python脚本,也不是从命令行本身或运行 有人知道如何打开最小化的chrome窗口吗? 或者可以使用最小化现有chrome窗口的命令(我将打开它,然后最小化它,希望它能足够快让我注意到) 我所发现的就

我正在使用python编写一个脚本,以帮助我管理打开的浏览器页面。 我正在使用os.system(“开始…”)打开chrome,我希望它作为一个最小化的程序打开

我注意到,我不能使用flag/min(我尝试了“start/min chrome www.google.com”)来完成这项工作,不是从python脚本,也不是从命令行本身或运行

有人知道如何打开最小化的chrome窗口吗? 或者可以使用最小化现有chrome窗口的命令(我将打开它,然后最小化它,希望它能足够快让我注意到)

我所发现的就是如何最小化命令行本身。 当我使用cmd中的“start/min记事本”时,flag/min工作得非常好。 不管怎样,我使用的是Windows XP操作系统。

可能会有帮助

根据its,您可以使用“Minimize()”来执行此任务:

def do_test_1():

  "1st Watsup Test"

  app = Application().start_(r"c:\windows\Notepad")
  notepadWindow = app.Notepad

  notepadWindow.Edit1.SetEditText(u"Hello, 鋑ain!", 0, -1)
  sleep(0.8)
  notepadWindow.Edit.SetEditText("\r\nYou still there?")

  sleep(0.2)
  notepadWindow.Edit.SetEditText("\r\nGoing Bye Bye now!!")

  sleep(1)
  notepadWindow.Minimize()

  sleep(1)
  notepadWindow.Restore()

我写这篇文章是为了得到所需的结果

老实说,这可能不是有史以来最好的代码,但经过几个小时的尝试,这确实奏效了

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Const SW_SHOWMAXIMIZED As Integer = 3
Private Const SW_SHOWMINIMIZED As Integer = 2
Private Const SW_SHOWNORMAL As Integer = 1


            ' Start Chrome with a Blank document so we know what the Name will be.
            ' This is a bit of a work around but after trying for hour to get the handle 
            ' the the actual Chrome window that opens this is the only way.
            Process.Start("Chrome.exe", "--new-window --start-fullscreen _Blank")  ' C:\Program Files (x86)\Google\Chrome\Application\

            ' Need to wait until the window has been initalised, the name will not be set until
            ' the page has been loaded. Chrome will take a little while to start and then 
            ' realise that "_Blank" is not a valid URL.
            ' We will loop round for 30 seconds, after the the page will not be opened.
            Dim LongTimeEscapeCounter = 300
            While iHwndOrderStatusScreen = 0 And LongTimeEscapeCounter <> 0
                LongTimeEscapeCounter = LongTimeEscapeCounter - 1
                iHwndOrderStatusScreen = FindWindow(vbNullString, "http://_Blank/ is not available - Google Chrome")
                Sleep(100)
            End While
            Debug.Print("Chrome Handle: " & iHwndOrderStatusScreen.ToString)
            If iHwndOrderStatusScreen = 0 Then
                MsgBox("Failed to find the Google Chrome Handle, reboot the PC and try again.", vbOKOnly + vbExclamation, "Error")
                Exit Sub
            End If

            ' Open the actual page the user wants
            Process.Start("Chrome.exe", txtFileName2.Text)
            Sleep(5000)
            ShowWindow(iHwndOrderStatusScreen, SW_SHOWMINIMIZED)
            Beep()
Private将函数findwindowlib“user32.dll”别名“FindWindowA”(ByVal lpClassName作为字符串,ByVal lpWindowName作为字符串)声明为IntPtr
私有常量SW_最大化为整数=3
私有常量SW_SHOWMINIMIZED为整数=2
私有常量SW_SHOWNORMAL为整数=1
'使用空白文档启动Chrome,以便我们知道名称。
这是一个有点麻烦的工作,但在花了一个小时试图解决这个问题之后
“打开此窗口的实际Chrome窗口是唯一的方法。
Process.Start(“Chrome.exe”,“--新窗口--全屏启动”\u Blank”)'C:\Program Files(x86)\Google\Chrome\Application\
'需要等到窗口初始化后,名称才会设置,直到
'页面已加载。Chrome需要一段时间才能启动,然后
'请意识到“_Blank”不是有效的URL。
“我们将循环30秒,然后页面将无法打开。
Dim长时间逸出计数器=300
而iHwndOrderStatusScreen=0和LongtimeScapeCounter 0
LongtimeScapeCounter=LongtimeScapeCounter-1
iHwndOrderStatusScreen=FindWindow(vbNullString,“http://_Blank/ 不可用-谷歌浏览器“)
睡眠(100)
结束时
打印(“Chrome句柄:”&iHwndOrderStatusScreen.ToString)
如果iHwndOrderStatusScreen=0,则
MsgBox(“未能找到Google Chrome句柄,请重新启动电脑并重试。”,vbOKOnly+VBEquipment,“错误”)
出口接头
如果结束
'打开用户想要的实际页面
Process.Start(“Chrome.exe”,txtFileName2.Text)
睡眠(5000)
显示窗口(iHwndOrderStatusScreen,SW_显示最小化)
哔()

Kev

我是否需要安装应用程序模块?我复制了你写的东西并导入了他在脚本中导入的所有东西,即从时间导入sys导入睡眠导入os导入os导入os.path从应用程序导入application,WindowNotFoundError,我得到了一个编译错误:“ImportError:没有名为application的模块”在windows环境中,只需运行以下行即可添加库:set PYTHONPATH=;%PYTHONPATH%和lib也可以通过运行setup安装到“site packages”目录。py.Oh,lib可以通过使用:hg clone从Google代码中检索,您需要Mercurial来获取它。我安装了pywinauto,但我不太确定它是如何工作的。当我导入模块并在python解释器中编写“app=Application().start(r“c:\windows\Notepad”)”时,我得到了以下错误:“回溯(最近一次调用):文件“”,第1行,在NameError中:名称“aplication”未定义“无论如何,如果有一个答案是通过cmd命令,我会很高兴,因为我可能会编写一个应该使用它的批处理脚本。事实上,上述示例在我这方面运行得不太好,在3个测试中,我删除了第3个测试及其导入“WindowNotFoundError”,以便可以执行,但它应该能够解决窗口最小化问题。我已在此处发布修改后的代码:。