cyxstudio Posted May 3, 2019 Share Posted May 3, 2019 I have a program on my company's desktop that kept on stealing my focus. So i downloaded a program called API monitor to observe the inner workings of the program and i discovered that it will routinely invoke SetForegroundwindow windows API (i believe its from user32.dll if i remember correctly) to give itself the focus, which is pretty annoying. I have the screenshot on my company's computer but i am posting from home now so i cant upload. I will asap once i get back to my office. My question is can AUtoit do anything about this? can Autoit block the offending program from calling windows API ? or just flat out disable the SetForegroundWindow? Link to comment Share on other sites More sharing options...
orbs Posted May 3, 2019 Share Posted May 3, 2019 i do not think AutoIt can do that natively. however other possible solutions exist: AutoIt can move the offending window off-screen, re-grab the focus when the offending program grabs it, etc. you may want to investigate the configuration of the offending program to see if the focus grabbing can be deactivated or its frequency reduced. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
cyxstudio Posted May 6, 2019 Author Share Posted May 6, 2019 (edited) On 5/3/2019 at 11:49 PM, orbs said: i do not think AutoIt can do that natively. however other possible solutions exist: AutoIt can move the offending window off-screen, re-grab the focus when the offending program grabs it, etc. you may want to investigate the configuration of the offending program to see if the focus grabbing can be deactivated or its frequency reduced. hmm can autoit call this function ?? locksetforgroundwindow https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-locksetforegroundwindow technically it will work right? i just lock up that setforegroundwindow function so no one can call it. heres the pic 0x00411111c is the handle for the offending program. i double checked with autoitInfo Edited May 6, 2019 by cyxstudio Link to comment Share on other sites More sharing options...
RTFC Posted May 6, 2019 Share Posted May 6, 2019 example My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
cyxstudio Posted May 9, 2019 Author Share Posted May 9, 2019 erm thank you RTFC, i created a script using your function and setforegroundwindow no longer shows up on the API monitor it means that function is effectively blocked. However the offending program still steals focus all the same. so i further search the other functions it calls and i found this. WM_setFocus, does it do the same as setforegroundwindow? Link to comment Share on other sites More sharing options...
Bilgus Posted May 9, 2019 Share Posted May 9, 2019 what happens if you minimize or hide the window for the offender thru Autoit? Link to comment Share on other sites More sharing options...
cyxstudio Posted May 14, 2019 Author Share Posted May 14, 2019 On 5/9/2019 at 10:02 PM, Bilgus said: what happens if you minimize or hide the window for the offender thru Autoit? winsetstate @SW_HIDE i tried it, the window will disappear however focus will still be lost , esp annoying if you are typing something . 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