Author Topic: Check window title  (Read 1175 times)

Bunny

  • Newbie
  • *
  • Posts: 25
Check window title
« on: December 01, 2018, 12:53:01 PM »
Is there a way to check if the topmost/front window contains .bgsm in the title and do something if it does or stop all commands if it doesn't?
Current system specs.
CPU: Ryzen 7 2700x
GPU: gtx 1080 ti
Ram: 32 GB

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Check window title
« Reply #1 on: December 01, 2018, 03:05:21 PM »
First I'd say you should test out your window of interest with something like this:

Code: [Select]
Write [Blue] '{ACTIVEWINDOWTITLE}' to log

...which will output the window title to the VA event log. Something like .bgsm sounds like it might be a file extension (I could be wrong of course), and windows titles don't usually contain extensions. If that's NOT the case then something like this should work:

Code: [Select]
// Define text of interest that you want to search for
Set Text [MyText] to '*.bgsm*'

// Check if active window contains the text of interest
Begin Text Compare : [{WINDOWFOREGROUND:MyText}] Equals '1'
    // Output info to event log
    Write [Blue] 'Your window was found!' to log
End Condition

You can check out page 142 of the Help Document for more info about the {WINDOWFOREGROUND:} token.

Bunny

  • Newbie
  • *
  • Posts: 25
Re: Check window title
« Reply #2 on: December 02, 2018, 07:39:20 AM »
WINDOWFOREGROUND doesn't work

I'm using this (https://www.nexusmods.com/fallout4/mods/3635) to mod bgsm files for fallout 76.
Current system specs.
CPU: Ryzen 7 2700x
GPU: gtx 1080 ti
Ram: 32 GB

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: Check window title
« Reply #3 on: December 02, 2018, 10:13:45 AM »
WINDOWFOREGROUND has a known issue that is that if there is more than one instance of your searched target app open, it may fail.  Make sure you only have one instance of your target open.

Welcome back, Bunny!

Bunny

  • Newbie
  • *
  • Posts: 25
Re: Check window title
« Reply #4 on: December 02, 2018, 10:23:49 AM »
Dang, that sucks.

I have an idea around it.
Current system specs.
CPU: Ryzen 7 2700x
GPU: gtx 1080 ti
Ram: 32 GB