GokAy Posted December 28, 2020 Share Posted December 28, 2020 If you don't want Desktop and Windows Explorer to trigger, the CodeProject link had one extra step checking for something like this.. $sActiveProcess = WinGetText (_WinAPI_GetForegroundWindow ( )) if StringInStr($sActiveProcess, "explorer") = 0 and not $sActiveProcess = "" then ; Do Stuff endif JockoDundee and Professor_Bernd 2 Link to comment Share on other sites More sharing options...
Professor_Bernd Posted December 29, 2020 Author Share Posted December 29, 2020 (edited) @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! 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?) 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 December 29, 2020 by Professor_Bernd Link to comment Share on other sites More sharing options...
GokAy Posted December 29, 2020 Share Posted December 29, 2020 (edited) 16 minutes ago, Professor_Bernd said: How did you come up with this idea? I didn't really! 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 December 29, 2020 by GokAy FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
Professor_Bernd Posted December 29, 2020 Author Share Posted December 29, 2020 53 minutes ago, GokAy said: must feel pretty nice now You're right about that, it feels like Christmas! FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
Professor_Bernd Posted December 29, 2020 Author Share Posted December 29, 2020 (edited) @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 December 29, 2020 by Professor_Bernd 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