I have made an AHK script that adds metadata to video clips within Avid Media Composer (video editing software). It does this by entering all the necessary sub-menu's and sends mouse clicks to locations on the screen that make a laborious task easy when needing to do it over and over all day.

However, i want the script to only run within Avid Media Composer and nothing else. There are other storage systems connected to the machine and i wouldn't want the script going into other files/folders accidentally doing who knows what to important data.

I tried using #IfWinActive but i'm not very experienced and not sure why i cant get it to work.

Here's what i need to do:

If 'Avid Media Composer' is the active window, run 'My Code'. If anything other than Avid Media Composer is the active window, Msgbox 'Avid Media Composer must be the active window to run this task'.

-

Window Title, Class and Process

Avid Media Composer Mojo DX

ahk_class Qt5QWindowIcon

ahk_exe AvidMediaComposer.exe

-

My Code:

F3::

 {
    BlockInput, MouseMove
    Hotkey, LButton, DummyLabel, On
    Hotkey, RButton, DummyLabel, On
    Hotkey, MButton, DummyLabel, On
    Sleep, 20
    Send, {LAlt}
    Sleep, 20
    Send, {Right}
    Sleep, 200
    Send, {Right}
    Sleep, 20
    Send, {Right}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Right}
    Sleep, 20
    Send, {Enter}
    Sleep, 100
    MouseClick, Left, 107, 30
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Down}
    Sleep, 20
    Send, {Enter}
    Sleep, 100
    MouseClick, Left, 346, 38
    Sleep, 200
    Send, ^v
    Sleep, 200
    Send, {Enter}
    Sleep, 200
    Send, {Enter}
    Sleep, 200
    MouseClick, Left, 91, 102
    Sleep, 100
    MouseClick, Left, 92, 100
    Sleep, 100
    MouseClick, Left, 143, 154
    Sleep, 100
    Send, {Down}
    BlockInput, MouseMoveoff
    Hotkey, LButton, DummyLabel, Off
    Hotkey, RButton, DummyLabel, Off
    Hotkey, MButton, DummyLabel, Off

 }
return

DummyLabel:
return

What is the correct code for this series of commands to run only within Avid Media Composer itself and nothing else?

Many thanks for any help in advance.

up vote 1 down vote accepted

You should have a look at the following references :

According to your info the following three are all possible :

SetTitleMatchMode, 2
#IfWinActive Avid Media Composer

#IfWinActive ahk_class Qt5QWindowIcon

#IfWinActive ahk_exe AvidMediaComposer

Example :

SetTitleMatchMode, 2
#IfWinActive Notepad
F3:: MsgBox, IN
return
#IfWinNotActive Notepad
F3:: MsgBox, OUT
return
  • Hi there, thanks for your answer. i will give it a go. Shall i just add this to the top of my script before everything else? – Myles Sep 13 at 12:33
  • 1
    Yes. You can even have consecutive #IfWinActive commands in the script, each pertaining to what follows it. – harrymc Sep 13 at 12:41
  • I just tried a test where i wrote #IfWinActive Avid Media Composer then followed by code beneath it for Msgbox, This is Avid. Then beneath that i also wrote #IfWinNotActive Avid Media Composer followed by code beneath it for Msgbox, This is NOT Avid. However, when i run it i get both message boxes show up when i press the hotkey whether i'm inside or outside the Avid Media Composer software – Myles Sep 13 at 12:49
  • never mind i figured it out. This worked. Will do a few more tests and mark as answered if all is good. – Myles Sep 13 at 12:55
  • Everything upvoted + Question Answered. Thanks – Myles Sep 13 at 17:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.