PAB Posted October 7, 2021 Posted October 7, 2021 Good evening, I have been having trouble with getting a Batch Script to click "OK" after the Batch Command has finished . . . On investigation, I came across this site which might help me resolve this. Here is the part of the Batch Command that I am having trouble with . . . cleanmgr.exe /VeryLowDisk /d C Everything else in the Batch Script is automated and runs without ANY problems. Is there a way that I can incorporate an Autoit Command to replicate [ virtual ] pressing the "OK" button please? Stay SAFE, Best Regards.
PAB Posted October 7, 2021 Author Posted October 7, 2021 Sorry, I could NOT find a way to edit my above post. I should have mentioned that "OK" is obviously the ONLY option available, so the focus is on it. By that, I mean that getting the Script to replicate pressing ENTER, will also work. Thanks.
SkysLastChance Posted October 7, 2021 Posted October 7, 2021 (edited) https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm ControlSend("Disk Space Notification","","",("{ENTER}")) ? Edited October 7, 2021 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott
Subz Posted October 7, 2021 Posted October 7, 2021 You could also use /sageset, /sagerun switches for example the code below should be the same as running "cleanmgr.exe /VeryLowDisk" (untested). The script would be the same checking every box in cleanmgr and then clicking ok, without any dialogue. note: sageset/sagerun doesn't support the /d option. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ Use StateFlagsxxxx, where xxxx is 0 - 9999 Local $sStateFlags = "StateFlags0100" Local $sVolumeCacheRoot = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches" Local $sVolumeCacheKey Local $i = 1 While 1 $sVolumeCacheKey = RegEnumKey($sVolumeCacheRoot, $i) If @error Then ExitLoop ;~ Uncomment line below to write to registry ;~ RegWrite($sVolumeCacheRoot & "\" & $sVolumeCacheKey, $sStateFlags, "REG_DWORD", 2) $i += 1 WEnd ;~ Uncomment to run cleanmgr ;~ Run("cleanmgr.exe /sagerun:100")
ad777 Posted December 18, 2021 Posted December 18, 2021 (edited) try this code: ControlClick("Disk Space Notification","","Button1") or what subz say's: #RequireAdmin Local $sStateFlags = "StateFlags" Local $sVolumeCacheRoot = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches" Local $sVolumeCacheKey Local $i = 1 $Drive = InputBox("Drive Disk:","(C or D or E etc.')","default") While 1 If @error Then ExitLoop $sVolumeCacheKey = RegEnumKey($sVolumeCacheRoot, $i) if $sVolumeCacheKey = "" Then ExitLoop $inputValue = InputBox($sVolumeCacheKey,"Enter '1' or '0' ","default") RegWrite($sVolumeCacheRoot & "\" & $sVolumeCacheKey, $sStateFlags, "REG_DWORD", $inputValue) $i += 1 WEnd Run("cleanmgr.exe /d "&$Drive) Edited December 18, 2021 by ad777 none
levila Posted December 31, 2021 Posted December 31, 2021 You can try this code, it will wait until the popup notification appear and auto closed it. Do Sleep(1000) Until WinActive("Title") While WinActive("Title") ControlClick("Title", "", "[TEXT:OK]") ExitLoop WEnd
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