QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: MasterGy on December 06, 2020, 03:50:36 am

Title: active windows
Post by: MasterGy on December 06, 2020, 03:50:36 am
Hi ! What do I need to read to find out if the window is active? Is the program running, but how do I know it is in the background, or you have put it on the taskbar, or you are using that window?
Title: Re: active windows
Post by: Petr on December 06, 2020, 03:58:45 am
Hi. Try this:

Code: QB64: [Select]
  1.     LOCATE 1
  2.     IF _SCREENICON THEN BEEP 'if is program minimalized
  3.     IF _SCREENEXISTS THEN PRINT "Program is created"
  4.         CASE 0: PRINT "Fullscreen OFF"
  5.         CASE 1: PRINT "Fullscreen ON, _STRETCH"
  6.         CASE 2: PRINT "Fullscreen ON, _SQUAREPIXELS"
  7.     END SELECT
  8.  
Title: Re: active windows
Post by: Petr on December 06, 2020, 04:19:23 am
I forgot one very important function!

Code: QB64: [Select]
  1.     LOCATE 1
  2.  
  3.     IF _SCREENEXISTS THEN PRINT "Program is created"
  4.     IF _SCREENICON THEN BEEP 'if is program minimalized
  5.         CASE 0: PRINT "Fullscreen OFF"
  6.         CASE 1: PRINT "Fullscreen ON, _STRETCH"
  7.         CASE 2: PRINT "Fullscreen ON, _SQUAREPIXELS"
  8.     END SELECT
  9.     LOCATE 4
  10.     hasFocus%% = _WINDOWHASFOCUS
  11.     IF hasFocus%% THEN PRINT "This window is active        " ELSE PRINT "This window is not active" 'click to other window for test   (have 2 different program windows on screen and click there)
  12.  
  13.  
Title: Re: active windows
Post by: MasterGy on December 06, 2020, 05:15:59 am
thank you very much, that's exactly what i needed!
Title: Re: active windows
Post by: doppler on December 07, 2020, 12:34:28 pm
And if you wan to know more about other windows open/closed/min/max
https://ritchielawrence.github.io/cmdow/

Please red the very first line at the website.  If you decide to use cmdow, it maybe required to ignore win's security warning and accept it.