Jump to content

Can't change the Google Chrome window title (app mode)


Recommended Posts

Forgive my English(

Please tell me why I can't change the header of the Google Chrome browser window. Help please.

 

#include <WinAPISysWin.au3>

Run('C:\Program Files\Google\Chrome\Application\chrome.exe --app=https://www.eminem.com')
Sleep(4000) ;wait load web-site

Local $aList = WinList()

; Loop through the array displaying only visable windows with a title.
For $i = 1 To $aList[0][0]
    ;If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
    ConsoleWrite("Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1] & @CRLF)

    If StringInStr($aList[$i][0], 'Eminem | Home') Then

        $hWnd = WinGetHandle("[CLASS:Chrome_WidgetWin_1]")
        WinSetTitle($hWnd, '', 'test test') ;But why doesn't it work?

    EndIf
    ;EndIf
Next

 

Link to comment
Share on other sites

You are using the wrong handle. Winlist already gave you the handle, so there is no need to try to get the handle again. With the right handle your code will work, but browsers do not like to show changed titles, so even when the autoit code works, you will probably not see a changed title.

If StringInStr($aList[$i][0], 'Eminem | Home') Then
        $hWnd = $aList[$i][1]
        MsgBox(Default, "WinGetTitle", WinGetTitle($hWnd, ""))
        WinSetTitle($hWnd, '', 'test test') ;But why doesn't it work?
        If @error then MsgBox(Default, Default, "ërror:" & @error)
        MsgBox(Default, "WinGetTitle", WinGetTitle($hWnd, ""))
    EndIf

 

Link to comment
Share on other sites

"With the right handle your code will work, but browsers do not like to show changed titles, so even when the autoit code works, you will probably not see a changed title."

True, all right.

But is there any way to make the header change in the window itself?

 

#include <WinAPISysWin.au3>

Run('C:\Program Files\Google\Chrome\Application\chrome.exe --app=https://www.eminem.com')
Sleep(4000) ;wait load web-site

Local $aList = WinList()

; Loop through the array displaying only visable windows with a title.
For $i = 1 To $aList[0][0]
    ;If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
    ConsoleWrite("Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1] & @CRLF)

    If StringInStr($aList[$i][0], 'Eminem | Home') Then
        $hWnd = $aList[$i][1]
        MsgBox(Default, "WinGetTitle", WinGetTitle($hWnd, ""))
        WinSetTitle($hWnd, '', 'test test') ;But why doesn't it work?
        If @error Then MsgBox(Default, Default, "ërror:" & @error)
        MsgBox(Default, "WinGetTitle", WinGetTitle($hWnd, ""))
    EndIf
    ;EndIf
Next

 

image.jpg

Edited by SEKOMD
Link to comment
Share on other sites

I didn't think of that.

Indeed it looks like phishing.

I have a program where I write text (an html form is loaded into the browser window to enter text). It currently runs on Internet Explorer, where you can change the header easily. 

Google Chrome has a handy text search and other useful features. That's why I wanted to use the Chrome base (much more convenient).

Link to comment
Share on other sites

  • 2 weeks later...

Is this for internal use where you work or for yourself?  Does it need to be part of an application that is distributed to users?

If this is something you use yourself then you need to create a plugin for chrome and then access that plugin via your autoIT app to inject javascript into the page to make any changes.  This is ONE way.

Chrome has or did have a developer tool that allowed you to take control of chrome but I think they stopped developing it.  You should be able to do an internet search and you will either find the tool in an archive some place or it could still be developed or an alternative to it.  

When it comes to Chrome or any browser you need a helper to access the internals that you then access in some way externally to command the browser.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...