SOLVED: Windows Scripting - KeyShortcut.Trigger doesn't work

Hi There,

I’m trying WaveLab 9 Pro on Windows 8.1 64 bits.
I like the software very much. I think it’s brilliant (it also looks really great now…)

Scripting is very important to me. So far everything I’ve tried (both Windows JScripts and the internal scripting) works great, except the Trigger method of the KeyShortcut object. This one is so important…

It just doesn’t do anything. the object is created and the method is recognized and called. I know that, because when I tried sending it only the shortcut string as the only argument, it reported an error, because both arguments are mandatory.

Is there a known issue with this part of the Windows Scripting interface?
Here’s an example code for the part that doesn’t work:

var sc = WScript.CreateObject(“WaveLab9_0_64.KeyShortcut”);
sc.Trigger(“Wave”, “Ctrl+Down”);

or, alternatively:
sc = new ActiveXObject(“WaveLab9_0_64.KeyShortcut”);
sc.Trigger(“AudioMontage”, “Ctrl+A”);

Both ways of creating the WaveLab objects and calling their methods work for everything else I’ve tried…

Thanks and All the Best,
Asaf

OK, I found out why it wasn’t working, and a way to get around the problem.
The method Trigger of the object KeyShortcut works if and only if WaveLab’s window has the focus (as opposed to the rest of the API, which works regardless of which application currently has the focus.)
The focus goes to the GUI (HTA) or the console (csript) in the code I wrote.

So to get around the problem, before using the method I added (this time the lines are in VBScript, though it works in JScript as well):

Dim ObjShell :Set ObjShell = CreateObject(“Wscript.Shell”)
ObjShell.AppActivate(“WaveLab”)

Which sets “WaveLab” as the active application, meaning that its window has the focus.
Then it works!

I ran into another scripting issue, where once I call the Wave.Close() method, I can’t reopen the same Audio File using the Wave.Open method.
(But for the time being, I can do with just not closing, if I might want to reopen…)

My deep appreciation for PG and Steinberg for this fantastic software!

Asaf

Good that you found the solution. I had not the time yet to look at it.