Jump to content

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? 

Link to comment
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. 

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

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

Link to comment
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 .

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...