Looking for a method to trigger when ANY window opens

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
OldGeek
Junior Coder
Posts: 30
Joined: Thu Oct 30, 2014 11:49 am
Location: Upstate NY, USA

Looking for a method to trigger when ANY window opens

Post by OldGeek » Fri Jun 28, 2024 7:09 pm

I know this is going to cause some feedback but here I go. I was trying to create something like the new "Recall" feature in the new Windows Copilot. But to start by just capturing a image of the screen when a new window opens.
[OKAY: let the sk?tstorm begin]
MS v15 | Windows 11 Pro | NY, USA

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Looking for a method to trigger when ANY window opens

Post by JRL » Fri Jun 28, 2024 9:23 pm

This could get really complicated, depending on what you want to accomplish. Let's start with easy.

Code: Select all

Let>msg_xpos=0
Let>msg_Ypos=0

Message>Macro Scheduler Message

//Discover current Active Window
GetActiveWindow>vTitleA,vXpos,vYpos
/////////////////////////////

Label>Loop
  //Closes the script when the message window is closed
  IfWindowOpen>Macro Scheduler Message
  Else
    GoSub>Quit
  EndIf
  ///////////////////////////////////////////////
  
  //Small wait to prevent high CPU
  Wait>0.01
  ////////////////////////////
  
  //Acquire name of current active window and then compare to previous current active window
  GetActiveWindow>vTitle,vXpos,vYpos
  
  //If names are the same nothing has changed, do nothing
  If>vTitle=vTitleA
  Else
  
    //If names are different,  Do something.
    //In this case display the name in the message box.
    SetControlText>Macro Scheduler Message,TMemo,1,vTitle
    
    Let>vTitleA=vTitle
  EndIf
Goto>Loop


SRT>Quit
  Exit>0
END>Quit

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts