Jump to content

How can Autoit receive a variable from Foobar2000


Bakiki
 Share

Recommended Posts

Hi

I'm a newbie and I'm trying to write a simple macro that will will be able to manipulate variables such as %_artist% , "%_ablum%,%_path%, etc  that be can sent via a feature in Foobar2000 called run services. With this feature I can type i.e.

 

"C:Program Files '('x86')'Mp3tagMp3tag.exe" "%_path%" to open the MP3TAG application from within Foobar2000 ......

 

But I can't work out how I read the same "%_path%" variable within an autoit macro.

Sorry if ths is crushingly obvious but I have not been able to find anything through searching this forum?

Thanks for any assistant.

 

Link to comment
Share on other sites

If these are environment variables, and it appears they are, then use EnvGet("_artist"). as an example. to get that value.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You will only be able to access them if Foobar2000 is exporting them.

The only option I can think of would be to configure Foobar2000 to call your script with all of the variables you need passed on the command line.  The your script can use $CmdLine[] to access them.

Link to comment
Share on other sites

Thanks for all your suggestions.

I do belive that Foobar2000 is already exporting these. I'm not sure if it is using the commandline but here is an example of the Foobar2000 calling google and sending an artist variable

http://www.google.com/search?q=$replace(%artist%, ,+)&ie=utf-8

Surely if a url is able to receive this I should be able to access it with autoit...?

Thanks again

Link to comment
Share on other sites

Have FooBar2000 call out in this fashion

"c:\path_to_autoit_script\MyScript.exe" "%_path%" "%_artist%" "%_album%"

Then use something like the following in your script

$path = $CmdLine[1]
$artist = $CmdLine[2]
$album = $CmdLine[3]

Be sure to read the "Running Scripts" page in the "Using AutoIt" section of the help file.  It will describe the proper use of the $CmdLine variable.

Link to comment
Share on other sites

Fantastic! This is what I needed... Thank you for taking the time to point me in the right direction.

I have just one more question. I'm having a problem with the cmdline  2 & 3 not showing anything for  %_artist%" "%_album%

$path = $CmdLine[1]
$artist = $CmdLine[2]
$album = $CmdLine[3]
"c:\path_to_autoit_script\MyScript.exe" "%_path%" "%_artist%" "%_album%"

Is there sometime wrong with the syntax?

Link to comment
Share on other sites

I was just gonna say, that "%_path%", is the parameter passed (on the command-line) to whatever executable file you are running.

Enclosed with quotes like that, you are only going to get one parameter - $CmdLine[1]

Perhaps all the detail is in that one parameter, but you need to split it to get the individual parts?

If there is some divider present, then you can use the _StringSplit command.

EDIT

Oops, just noticed your other parameters on the command-line - "%_artist%" "%_album%"

If you are not getting an error for $CmdLine[2] and $CmdLine[3], then the values are just blank data.

Are you sure, that those two parameters start with an underslash?

My recollection of Foobar2000 is that they don't, but I've never used them in the context you are, only for the command-line for conversions.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Bakiki,

I have never used FooBar2000, so I am entirely unfamiliar with how external programs are called, or what variables are available.

The example I gave is only an illustration of how to use the $CmdLine variable to retrieve data passed on the command line to the script, as a way for you to get the values FooBar2000's variables, and I used the variable names that you provided in a previous post.

As TheSaint pointed out, either the variables are blank, or you are possibly mistyping a variable name on the FooBar2000 side.

Make sure you also look at the help file section I referenced.  It is very clear and easy to follow.

Link to comment
Share on other sites

Before this thread is forgotten.

How would I send a commandline from another autoit macro to be received by another Autoit exe. I searched around and found commands that call the cmd.exe (which I don't want) and I've also come across StdinWrite...  But so doesn't seem to worked for me. What I'm I missing? 

To send

Local $sendvariable = "Hello"

Local $directory = "D:AUTOITFoob.exe"

StdinWrite($directory, $sendvariable)

 

Received by other exe

$receivedvariable = $CmdLine[1]

 

Thank you

 

 

Link to comment
Share on other sites

  • Moderators

Are you trying to communicate between two applications at the same time throughout the entire duration (or any length of time other than initial start up)?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

In addition and related to what SmOke_N said.

Is your second executable already running, or are you wanting to start it at a certain point and just pass a value once.

If the latter, then you use the same type of command-line approach as the one to run your AutoIt program from Foobar2000.

If it is already running, then you could have a value written to either a file (i.e. an INI file etc) or to the Windows Registry, or learn how to use stdIn.

Writing to file or registry by your first program, is very simple, and you just have your second running program check for the value at intervals you specify in it. Myself, I'm fond of the INI file approach, for it is quick and easy.

P.S. Don't fool with the Windows' Registry, unless you are pretty confident about how it works.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...