Jump to content
cyxstudio

Can Autoit block a program from calling windows API?

Recommended Posts

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? 

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites
Posted (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

 

setforegroundwindow.png

Edited by cyxstudio

Share this post


Link to post
Share on other sites

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?

 

wm_setfocus.png

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
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

×
×
  • Create New...