Author Topic: active windows  (Read 2443 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
active windows
« 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?

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: active windows
« Reply #1 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.  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: active windows
« Reply #2 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.  

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: active windows
« Reply #3 on: December 06, 2020, 05:15:59 am »
thank you very much, that's exactly what i needed!

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: active windows
« Reply #4 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.