SEKOMD Posted July 31, 2022 Posted July 31, 2022 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
OJBakker Posted July 31, 2022 Posted July 31, 2022 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 SEKOMD 1
SEKOMD Posted July 31, 2022 Author Posted July 31, 2022 (edited) "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 Edited July 31, 2022 by SEKOMD
Subz Posted July 31, 2022 Posted July 31, 2022 The title is managed within the webpage itself, using the --app switch to hide the address bar and then change the title of the page is highly suspect, it's common phishing tactic.
SEKOMD Posted August 1, 2022 Author Posted August 1, 2022 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).
iAmNewbe Posted August 13, 2022 Posted August 13, 2022 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now