Thanks llewxam for your suggestions here.
I was trying to automate Win10 Defender/Windows Security. AsAdmin, I could use autoIT to launch it, close it, move it but NOTHING worked to click on the controls inside the window, including all combinations of ControlClick to locations on the window. I had read windows UIAutomation was the likely problem and had forgotten about SendKeys.
My goal was to automate the separate key presses to turn off RealTimeProtection VERY OFTEN, since it now [2024] randomly turns itself back on, sometimes only minutes later.
The following opens the Defender window, navigates to the section showing the RTP setting, shrinks the window, and moves to the right lower corner, so I can see if RTP is on or not. The on/off slider is always in view, mainly so I can turn RTP off with one click. My screen resolution is 1600x900 for those WinMove settings
Run(@ComSpec & " /c start windowsdefender: ")
$hwnd = WinWaitActive('Windows Security')
WinActivate($hwnd)
WinSetState('Windows Security', "", @SW_MAXIMIZE)
Sleep(2000)
;============ found \/
If $hwnd > 0 then
WinActivate($hwnd)
Send("{TAB 4}")
Send("{SPACE}")
Sleep(1000) ; Wait to see what happened. REDUCE ALL SLEEPS ONCE THIS WORKS
Send("{TAB 5}")
Send("{SPACE}")
Sleep(2000)
WinMove("Windows Security", "", 1460, 476, 50, 50, 1)
EndIf
;============= found /\