wysocki Posted July 9 Share Posted July 9 While Chrome browser is maximized, I put my Win11 computer to sleep. But when I wake it up, the browser window is reduced about 3/4 in size and the size can't be changed unless I first click the window restore button (behaves as if it was already maximized). If I maximize it, then close it entirely, then open it again it's fine. Other windows also work fine. So I wrote a script to get the Chrome handle, restore size, and maximize it. The script does what it should when I run it. However, if I schedule the task to run when waking the task does nothing, even though Task Scheduler reports that it ran successfully! I even put code in the script to write to a log file while it runs, but the log file is empty. I trigger task scheduler with System -> Power-Troubleshooter -> 1 and it does get triggered upon wakeup. Just the task does nothing. Why can't the task write to the log file and get my Chrome browser handle to manipulate it when it's run from Task Scheduler? Link to comment Share on other sites More sharing options...
Zedna Posted July 10 Share Posted July 10 1) post your code 2) look here: https://www.autoitscript.com/wiki/FAQ#Why_doesn't_my_script_work_on_a_locked_workstation? Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
wysocki Posted July 10 Author Share Posted July 10 Here's what I had: #include <Misc.au3> #include <array.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> Opt("WinTitleMatchMode",2);match any substring xConsoleWrite("-------------RUNNING--------------" & @CRLF) $hWnd = WinGetHandle("[REGEXPTITLE:(?i)(.* - Google Chrome.*)]") If $hWnd = 0 Then xConsoleWrite("Window not found!" & @CRLF) Exit EndIf $arr = WinGetPos($hWnd, "") $iX = $arr[0] $iY = $arr[1] $iWidth = $arr[2] $iHeight = $arr[3] xConsoleWrite('State ='& WinGetState($hWnd, "") & ' iX ='& $arr[0] & ' iY ='& $arr[1] & ' iW ='& $arr[2] & ' iH ='& $arr[3] & @CRLF) WinMove($hWnd,"",0,0,1000,800) WinSetState($hWnd, "", @SW_MAXIMIZE) xConsoleWrite('New State ='& WinGetState($hWnd, "") & ' iX ='& $arr[0] & ' iY ='& $arr[1] & ' iW ='& $arr[2] & ' iH ='& $arr[3] & @CRLF) Func xConsoleWrite($parm) $f = fileOpen("onwake.log",1) FileWrite($f, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " " & $parm) fileclose($f) EndFunc Thanks for the referral to the FAQ. Sound's interesting, but I don't do anything regarding the active state of the window (do I?). But aside from that, why doesn't the log file get created when it runs? Also, I have tried in the scheduler -> Edit Trigger -> Delay Task: 30 seconds (which is way after the window is available) and still I get no results from the script. How can I get this script to run once the system awakes fully from a sleep? Link to comment Share on other sites More sharing options...
Zedna Posted July 10 Share Posted July 10 I wonder that "Sleep" is not the same as "Locked workstation" ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ioa747 Posted July 11 Share Posted July 11 try with: trigger task scheduler with On workstation unlock to see if it has the same behavior look at the links to see if they fix the original problem https://support.google.com/chrome/thread/154228476/chrome-won-t-maximize-fully-with-recent-windows-11-update?hl=en https://answers.microsoft.com/en-us/windows/forum/all/solved-windows-10-resizing-open-app-windows-after/7c4ab0f1-e550-47d9-9531-649eed3d3e1e I know that I know nothing Link to comment Share on other sites More sharing options...
Solution wysocki Posted July 14 Author Solution Share Posted July 14 @ioa747 : Changing trigger to "on workstation unlock" says it ran successfully when I logged back in after sleeping, but the program didn't create the log file nor fix the size of the Chrome window. And your first link sounded promising since it described my issue exactly. However disabling Touch UI did not fix the issue. The second link didn't seem to be relevant since it involved ALL windows being resized and my issue is only with Chrome. BUT! It did point me to a section of the registry where the monitor data is stored: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration So I backed up then deleted that key and when I rebooted, the keys were correctly rebuilt and my Chrome sizing issue is fixed!!! Thanks for the tip! ioa747 1 Link to comment Share on other sites More sharing options...
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