Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Sending R keystroke to audacity from game



  • Please log in to reply
16 replies to this topic
FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

I use Audacity to record my voice when I make gaming videos, but the R hotkey in audacity only works when it is the active window.  I need to make a script that sends R to audacity when I press F9, so that Audacity and FRAPS can begin recording at the same time.

 

I've figured out I need to use ControlSend to do this, but I cant seem to make it work.  How would I need to do this?



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Try:

 

 

CapsLock::
IfWinExist, ahk_class wxWindowClassNR
ControlSend, , r, ahk_class wxWindowClassNR
Return


FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

 

Try:

 

 

CapsLock::
IfWinExist, ahk_class wxWindowClassNR
ControlSend, , r, ahk_class wxWindowClassNR
Return

 

Nope that doesn't seem to work.  Ugh this is proving to be more trouble than I thought it would be.



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Strange, this works on my machine without audacity having focus. Have you checked the ahk_class of your specific Audacity version? Use windows spy to find that.



FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

Strange, this works on my machine without audacity having focus. Have you checked the ahk_class of your specific Audacity version? Use windows spy to find that.

Yeah it comes up the same as the one you used in your script.  It works when Audacity is in focus, but not without.



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Strange. I opened Audacity again to verify that I am not crazy and now, second time that I started Audacity, the script isn't working for me as well! Where I am SURE it worked like a dream before.



FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

Strange. I opened Audacity again to verify that I am not crazy and now, second time that I started Audacity, the script isn't working for me as well! Where I am SURE it worked like a dream before.

Yeah this is pretty wierd.  It has to be a problem with Audacity's settings, as the script seems fine, but then again I'm really not sure.  I changed the script to type something into calculator and that works just fine, so the problem has to be with Audacity.



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Could you try this: This works for me even after I reloaded Audacity.

B.t.w. there is a strange mix-up with the button names, I had to use 9 instead of 8  from the spy window.

 

 

CapsLock::
IfWinExist, ahk_class wxWindowClassNR
ControlClick,wxWindowClassNR9, ahk_class wxWindowClassNR
Return


FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

 

Could you try this: This works for me even after I reloaded Audacity.

 

 

 

CapsLock::
IfWinExist, ahk_class wxWindowClassNR
ControlClick,wxWindowClassNR9, ahk_class wxWindowClassNR
Return

 

That one works fine, but now I can't toggle on and off with one script unfortunately.  Oh well this is close enough.  I really don't know why ControlSend doesn't work out of focus.  Thanks.



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

When you bring up the audacity control window grab it's instance id (its ahk_id) and try using that instead of the window class. From its id you can control or extract all the information you need to control the window. With mine I send and alt-T then R and it drops right into record mode. One thing you might check is your setting for the DetecthiddenWindows command (just to be sure).


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

When you bring up the audacity control window grab it's instance id (its ahk_id) and try using that instead of the window class. Could be the class isn't what you expect it to be. From its id you can control or extract all the information you need to control the window.

From where exactly should I get the ID?  Sorry I'm not very good at this type of thing (despite going to study Computer Science p_p



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Why wouldn't you be able to toggle recording on/off? Just add a Toggle := !Toggle , an IF Toggle and another controlclick on button 6 (not tested)



FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

Why wouldn't you be able to toggle recording on/off? Just add a Toggle := !Toggle , an IF Toggle and another controlclick on button 6 (not tested)

What I meant by that was when I pressed my hotkey, the script sent t (my hotkey for the pause button) and r to Audacity, meaning that when I pressed it, it stopped recording if it was already.

Never mind, saw what you mean.



FireGaming
  • Members
  • 10 posts
  • Last active: Apr 14 2013 11:28 AM
  • Joined: 13 Apr 2013

Mmm I can't figure out how to get the ID, but the ControlClick thing is close enough to a solution.  Thanks for all the help guys.

 

This is the script I ended up with, and it works just fine.

 

F9::
IfWinExist, ahk_class wxWindowClassNR
Toggle := !Toggle
ControlClick,wxWindowClassNR9, ahk_class wxWindowClassNR
IF NOT Toggle
ControlClick,wxWindowClassNR6, ahk_class wxWindowClassNR
Return

Edit:

...Urgh or not.  It minimizes the game I'm playing when I use this script.  

 

I tried getting the ID and using that, but no difference is made it seems.  This is starting to look impossible,



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013
Gotta love it.I checked the help file and found this...

Audacity can currently only be used with scripting if you compile a separate plug-in module from SVN Development Code called "mod-script-pipe", as well as compile Audacity itself. See the Wiki Developer Guide for help. You'll also need the scripting language Perl to try out the examples.
We may provide a ready-compiled mod-script-pipe at some future time. If you just want to use scripting but don't want to do the developer steps then you will need to wait for that to be released. Feel free to let us know if you would like ready-to-go scripting in Audacity, and what you would use it for.

Clicking the proper controls unfortunately appears to be the only workable way to control Audacity at the moment.

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.