GamerZG Posted April 21, 2017 Posted April 21, 2017 hi everyone... i wondering is it possible make func inside script to check window title and show GUI only when that window is active. if not active then script not show anything. let me explain more: example... if u make some script binded to notepad (ONLY), script show fixed notification on screen (with info about hotkeys) and if u switch window (ALT+TAB or clicked in taskbar) then that notification should be gone until u switch back to notepad. i hope i explained ok... sorry about my english... is not perfect...
genius257 Posted April 21, 2017 Posted April 21, 2017 Hi @GamerZG. I think _WinAPI_SetWinEventHook is what you are looking for. With the $EVENT_SYSTEM_FOREGROUND and/or $EVENT_SYSTEM_SWITCHSTART A example in c# from stackoverflow: Detect active window changed using C# without polling Hope this helps. To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
LerN Posted April 21, 2017 Posted April 21, 2017 Maybe: While 1 if not WinExists("New Text Document (2).txt - Notepad") Then ContinueLoop Else ; your code here msgbox(0,"","Found notepad") ExitLoop EndIf WEnd
genius257 Posted April 21, 2017 Posted April 21, 2017 15 minutes ago, LerN said: Maybe: While 1 if not WinExists("New Text Document (2).txt - Notepad") Then ContinueLoop Else ; your code here msgbox(0,"","Found notepad") ExitLoop EndIf WEnd i would suggest adding Sleep to avoid high CPU usage To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
LerN Posted April 21, 2017 Posted April 21, 2017 While 1 if not WinExists("New Text Document (2).txt - Notepad") Then sleep(100) ContinueLoop Else ; your code here msgbox(0,"","Found notepad") ExitLoop EndIf WEnd
GamerZG Posted April 22, 2017 Author Posted April 22, 2017 (edited) thx @LerN and @genius257 ill try WinAPI_SetWinEventHook but it seems lil complicated for me now... meanwhile i made some simple code with check every 1 sec if window is active... thats alternative for now... #include <AutoItConstants.au3> Local $TITLE = "Notepad" While 1 Notification1() If not WinActive ($TITLE) Then SplashOff() EndIf If not WinExists ($TITLE) Then Exit 0 EndIf Sleep(1000) WEnd Func Notification1() SplashImageOn("Splash Screen", "notif1.bmp", 300, 150, 1000, 0, $DLG_NOTITLE) EndFunc now i trying to figure how to put notification splash screen in top-right corner (or middle-right) depending on resolution Edited April 22, 2017 by GamerZG
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