Jump to content

Non-focusable GUI does not give focus after calling "evil" functions


Recommended Posts

@mikell

Thank you for your ideas and advice! 👍 This led me in the right direction to develop a workaround to get around some of the undesirable side effects of the "evil" functions, and directed my attention to "_WinAPI_GetGUIThreadInfo()".

Edit: And, as I read in the next post, you also led GokAy in the right direction ("_WinAPI_GetGUIThreadInfo()"). ;)

@GokAy

Thank you very much for your effort, all the tests and your great help to find a solution! :thumbsup:

You worked tirelessly and even when a workaround was available, you didn't give up on finding a real solution. With "_WinAPI_GetGUIThreadInfo()" you hit the bull's eye. (How did you come up with this idea?) :think: This provides a neat solution to get the caret position in an editor when a non-focusable GUI is in the foreground. The best part: (so far) no unwanted side effects, no stealing focus, no "eating" mouse clicks!

Excellent work! Thanks a lot!

Thanks to all contributors! :)

Edited by Professor_Bernd
Link to comment
Share on other sites

16 minutes ago, Professor_Bernd said:

How did you come up with this idea?

I didn't really! :idiot: Just a Google search led me to the CodeProject page, which I linked in this topic earlier.

https://www.autoitscript.com/forum/topic/204723-non-focusable-gui-does-not-give-focus-after-calling-evil-functions/?do=findComment&comment=1471613

At first I didn't check it throughly, so couldn't notice that he wasn't using GetCaretPos but the GetGUIThreadInfo instead. Perhaps you might not have pursued this if Mikell did not make the comment about the AutoIt documentation regarding GETGUIThreadInfo 1 post later.

Anyway, good job, must feel pretty nice now :) 

Edited by GokAy
Link to comment
Share on other sites

@GokAy

FYI. Your solution and my solution are actually almost the same, 👍 because I just noticed that in your "MoveMyForm()" function you can omit the second to last line, because the coordinates are already relative to the screen:

_WinAPI_ClientToScreen(_WinAPI_GetTopWindow ( $_ActiveWin ), $tPoint)

Edited by Professor_Bernd
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...