Author Topic: Perform a Windows Function - [Show] a program using {ACTIVEWINDOWPROCESSID}  (Read 2356 times)

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Perform a Windows Function - [Show] a program using {ACTIVEWINDOWPROCESSID}

I'm using the video player PotPlayer, which it a great program. The problem is, when you allow it to open more than one of it's self, so you can play 2 or more files at once, the process name is the same for all the windows. You could change the windows name, but the moment you say skip to the next song, the windows name changes back to default, which breaks the command again.

The other problem is, the windows titles for each of these open programs aren't always the same. So, there is no way to target 1 of the windows, it always brings the first window open to the forefront.

If I could target the window by Process ID through Perform a Windows Function, then it should work properly.

Or is there another way to do what I want to do.

It would be great if I could target the windows by Process ID

Here is the command I'm using.

Code: [Select]
Set small int (condition) [Seconds] value to 0
Set Text [SITE] to [C:\Running AHK scripts\primary program.txt]
Start Loop While :  Keyboard Key 'F21' Is Pressed
    Set small int (condition) [Seconds] value as incremented by 1
    Write '[Blue] {SMALL:Seconds}' to log
    Pause 0.1 seconds
    Begin Small Integer Compare : [Seconds] Is Greater Than 3
        Begin Text Compare : [{ACTIVEWINDOWTITLE}] Contains 'PotPlayer'
            Pause 0.2 seconds
            Set Text [SITE] to '{ACTIVEWINDOWPROCESSID}'
            Play sound, '{VA_SOUNDS}\confirmed.mp3'
            Write (overwrite), '{TXT:SITE}' to file 'C:\Running AHK scripts\primary program.txt'
            Pause 1 second
        End Condition - Exit when condition met
        Play sound, '{VA_SOUNDS}\318276__jalastram__retro-game-sounds-sfx-69.wav'
        Set Text [Site] to '{ACTIVEWINDOWTITLE}'
        Pause 0.2 seconds
        Write (overwrite), '{TXT:SITE}' to file 'C:\Running AHK scripts\primary program.txt'
        Pause 1 second
    End Condition
End Loop
Begin Small Integer Compare : [Seconds] Is Less Than 3
        Display window '{TXT:SITE}' as [Show]
        Pause 0.05 seconds
    End Condition - Exit when condition met

This allows me to hold the F21 button for 0.3 secs to capture the windows title of my active window. Then whenever I tap the F21 key, it brings that window to the forefront. This works great, and I use to be able to target the process of my video player without a issue, but that video player no longer works properly for my purposes. I switched to Pot Player watch does everything the other player did, except how it handles multiple windows of it's self being opened. You can't target a single window by process, because it sees all of them as the same window. If I can target the ID, then it would solve this issue.

Sorry, if I'm repeating myself, just trying to make you understand what I'm trying to do. :)

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Ok, cool.  So, what I'll add is a way to select by process id (which is an integer value).  I'll also allow *text* variable names and token parsing in the, 'Perform a Window Function' action.  If the text resolves to an integer value, it will search for windows via process id.  The help document says that this box processes tokens, but I don't see any evidence of this (probably copy/paste), so, in it goes.

Note that I'm not extending this to the command/profile/global, 'Send Commands To' ('Target' in the beta), as the overhead for something like that (variables/tokens) would be a large processing penalty for 99.99% those that wouldn't use it (it's all kind of related is why I'm mentioning it).
« Last Edit: March 20, 2018, 07:50:57 PM by Gary »

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Cool! That would be great!