WINDOWHASFOCUS: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
mNo edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
{{PageDescription}} | {{PageDescription}} | ||
* The function returns true (-1) if the current program is the topmost window on the user's desktop and has focus. If the current program is running behind another window, the function returns false (0). | * The function returns true (-1) if the current program is the topmost window on the user's desktop and has focus. If the current program is running behind another window, the function returns false (0). | ||
* [[Keywords_currently_not_supported_by_QB64# | * '''[[Keywords_currently_not_supported_by_QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in macOS versions]]''' | ||
Revision as of 18:47, 13 November 2022
The _WINDOWHASFOCUS function returns true (-1) if the current program's window has focus. Not supported for macOS.
Syntax
- hasFocus%% = _WINDOWHASFOCUS
Description
- The function returns true (-1) if the current program is the topmost window on the user's desktop and has focus. If the current program is running behind another window, the function returns false (0).
- Keyword not supported in macOS versions
Availability
- Build 20170924/68.
Examples
Example: Detecting if the current program has focus. Windows and Linux-only.
DO IF _WINDOWHASFOCUS THEN COLOR 15, 6 CLS PRINT "*** Hi there! ***" ELSE COLOR 0, 7 CLS PRINT "(ain't nobody looking...)" END IF _DISPLAY _LIMIT 30 LOOP |
- Explanation: The program will display "*** Hi There! ***" while the window is the topmost and is being manipulated by the user. If another window, the taskbar or the desktop are clicked, the program window loses focus and the message "(ain't nobody looking...)" is displayed.
See also