Jump to content

WinSetState Chrome


Recommended Posts

Hi folks

I trying to find solution how to Restore or Maximize my minimized Chrome explorer

So far this doesn't work 4 me:

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_RESTORE )

or this one :

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_MAXIMIZE)

I have win8 so I thought that is why it doesn't work but when I check it on xp it not works as well..

What I am doing wrong?

somehow this one works but I will not have google page all the time

WinSetState("Google - Google Chrome", "",@SW_RESTORE )
Edited by TonyHex
Link to comment
Share on other sites

  • Moderators

TonyHex,

Are you sure that the CLASS you are using refers to the main Chrome GUI and not something smaller within it? :huh:

Chrome_WidgetWin_1 does not sound a likely CLASS for the main GUI to me. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

On windows 7 x64 this works.

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_RESTORE )

And this also works for me.

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_MINIMIZE )

Perhaps you need to use #RequireAdmin, although I'm not sure why you would, but with Win8, I have no experience in using it.

edit: miscopied the second script line, should have been using @SW_MINIMIZE instead of use _RESTORE twice, I have corrected it above.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

On windows 7 x64 this works.

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_RESTORE )

And this also works for me.

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_RESTORE )
Thanks 4 info BrewManNH

Both looks same to me I already tried them nothing happen .

I give it one more try just in case I miss something or typed it wrong at this one pop up at me:

I guess there is something wrong with chrome I have to specify more what I want restore. Cuz I have multiple chrome running in same time

Posted Image

and there is multiple chrome runnig at background :

Posted Image

Link to comment
Share on other sites

Everytime you open a new tab or a new window for Chrome it creates a new program instance, sometimes several. I have several running right now on my system and that scriptlet would minimize the main window of Chrome for me.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Restore worked for me on when I tested it. When you use @SW_RESTORE, what state is the Chrome window in prior to using it, and what happens after you try it with that option?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I staring to be confuse now

I have chrome minimized and I want it to @restore or @maximize or some other way show in desktop.

So after I run this code

WinSetState("[CLASS:Chrome_WidgetWin_1]", "",@SW_RESTORE )

1. when chrome is minimized and has no any page open yet

this will pop up

Posted Image

2. After load some page (google.com) and minimize chrome by hand and run code again this will pop up

Posted Image

3.if I have chrome on screen and run code nothing happen

Link to comment
Share on other sites

Well, I don't have Windows 8 available to test it on, so I can only tell you that it's working with Windows 7, it might very well have to do with something in Win8 or the version of Chrome that you're running.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I get the same as TonyHex on WinXP SP3 .... the maximize does nothing (the window state is changed ... when I click the taskbar icon to restore the window it shows maximized)... however there is a transparent frame shown on the desktop,

Link to comment
Share on other sites

Ah-ha! Think I have found it ,,, there are more than one window with "[CLASS:Chrome_WidgetWin_1]" when chrome is minimized.

$var = WinList()

For $i = 1 to $var[0][0]
; Only display visble windows that have a title
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
WinSetState($var[$i][0],"", @SW_MAXIMIZE)
EndIf
Next

Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf

EndFunc

maximizes Chrome (and all other windows).

Edited by MouseSpotter
Link to comment
Share on other sites

Which is another reason to add to the many already as to why I didn't update to Win8 and only use XP on the computers at work.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Ah-ha! Think I have found it ,,, there are more than one window with "[CLASS:Chrome_WidgetWin_1]" when chrome is minimized.

$var = WinList()

For $i = 1 to $var[0][0]
; Only display visble windows that have a title
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
WinSetState($var[$i][0],"", @SW_MAXIMIZE)
EndIf
Next

Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf

EndFunc

maximizes Chrome (and all other windows).

yes this one work thanks MouseSpotter

Is there any way how to extract chrome only?

I mean how to make it work at chrome only and not all windows?

Link to comment
Share on other sites

Oala......this is realy Lame but it does a job

Local $var = WinList()
For $i = 1 To $var[0][0]
; Only display visble windows that have a title
If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
Local $result = StringInStr($var[$i][0], "Chrome")

if $result > 0 Then
WinSetState($var[$i][0],"", @SW_RESTORE)
EndIf

EndIf
Next

Func IsVisible($handle)
If BitAND(WinGetState($handle), 2) Then
Return 1
Else
Return 0
EndIf

EndFunc ;==>IsVisible
Link to comment
Share on other sites

You can even do this:

Func IsVisible($handle)
Return BitAND(WinGetState($handle), 2)
EndIf

since if statements only care if 0, or not 0 (true)

also, you can use the window handle in:

_WinAPI_GetClassName($hwnd)

to verify the window class, rather than the title...but up to you

edit: small change with no real benefit :)

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...