Audiosurf: Ride Your MusicAudiosurfAddonsDEVELOPERS: (mod info) WM_COPYDATA command interface
Pages: [1] 2 3 4
Print
Author Topic: DEVELOPERS: (mod info) WM_COPYDATA command interface  (Read 4589 times)
Dylan
Developer
Administrator
Hero Member
*****
Posts: 925



View Profile WWW Email
« on: April 10, 2008, 01:19:16 AM »

This information applies to anyone progamming their own application who would like to be able to control Audiosurf from it.

With the latest beta patch, you can control Audiosurf from an external app by sending WM_COPYDATA messages to the Audisourf window.

For c/c++, you can send a WM_COPYDATA with something like this:
Code:
//get Audiosurf's window handle
HWND hwndTargetWin = FindWindow(NULL,"Audiosurf");

//create the command message and data struct
char* str = "asconfig freerideautoadvance false";
COPYDATASTRUCT cds;
cds.cbData = strlen(str)+1;
cds.lpData = (void*)str;

SendMessage(hwndTargetWin, WM_COPYDATA, 0, (LPARAM)&cds);

Audiosurf can receive commands once it has gotten to the character selection screen. There's also quickstart commands (explained below) that can be sent while Audiosurf is loading.




COMMANDS:
ascommand reloadtextures
ascommand reloadsounds
ascommand playsongcurrentcharacter c:\my music\nin\the way out is through.mp3
ascommand playsongmono c:\music\somesong.mp3
ascommand playsongpointman c:\music\somesong.mp3
ascommand playsongdoublevision c:\music\somesong.mp3
ascommand playsongmonopro c:\music\somesong.mp3
ascommand playsongvegas c:\music\somesong.mp3
ascommand playsongeraser c:\music\somesong.mp3
ascommand playsongpointmanpro c:\music\somesong.mp3
ascommand playsongpusher c:\music\somesong.mp3
ascommand playsongdoublevisionpro c:\music\somesong.mp3
ascommand playsongninjamono c:\music\somesong.mp3
ascommand playsongeraserelite c:\music\somesong.mp3
ascommand playsongpointmanelite c:\music\somesong.mp3
ascommand playsongpusherelite c:\music\somesong.mp3
ascommand playsongdoublevisionelite c:\music\somesong.mp3
ascommand playsongfreeride d:\music\09 Eternal Life.wma
ascommand setwindowpositionsize 100,100,640,480
ascommand setwindowalwaysontop
ascommand setwindowalwaysontopnoborder
ascommand runwithoutfocus (if you set the window as always on top, this gets set automatically)
ascommand closeaudiosurf
ascommand gotocharacterscreen
ascommand minimize
ascommand maximize
ascommand gofullscreen
ascommand restorenormalwindowstyle (puts the window back to default style and cancels "runwithoutfocus")




In addition to the command strings, you can configure some of Audiosurf's settings.
CONFIGS:
asconfig roadvisible true
asconfig sidewinder false
asconfig freerideblocks true
asconfig freeridecaterpillars false
asconfig freerideautoadvance true
asconfig showsongname true
asconfig usebankingcamera false




WINDOW REGISTRATION:
You can also send a command to register your window with Audiosurf:
ascommand registerlistenerwindow MyWindowTitle

Once you've successfully registered your window it will return a WM_COPYDATA message to you:
asreport successfullyregistered
And it will send messages on events:
REPORTS:
--When a song completes it sends a report with their score:
asreport songcomplete 142798
--Each time Audiosurf goes to the character selection screen it will send:
asreport oncharacterscreen

--Each time a song start playing it sends three commands:
asreport nowplayingartistname nine inch nails
--Followed by:
asreport nowplayingsongtitle just like you imagined
--Followed by:
asreport nowplayingashfile C:\\Audiosurf\\AudiosurfHC\\104415601 - SomeSong.mp3.ash




QUICKSTART COMMANDS:
There's two commands it will accept only while loading. Sending either one puts Audiosurf in quickstart mode where it will progress to the character selection screen with no clicks required.
1) ascommand quickstartregisterwindow MyWindowName
--It'll send you a "asreport successfullyquickstartregistered" to confirm registration
--Then it will send "asreport oncharacterscreen" when ready for further commands
--You don't need to register again to get messages usually sent to a registered window
2) ascommand quickstartqueuecommand CommandToRunWhenDoneLoadingGoesHere
--Example: ascommand quickstartqueuecommand ascommand playsongfreeride c:\music\some song.mp3
--Once it gets to the character selection screen it will run CommandToRunWhenDoneLoadingGoesHere




Note: Audiosurf will queue WM_COPYDATA messages if it receives more than one in a frame.


For Python, there's some info about sending and receiving WM_COPYDATA messages here (I haven't tried using Python for this yet):
http://blog.buffis.com/?p=29

For c/c++, you can send a WM_COPYDATA with something like this:
//get Audiosurf's window handle
HWND hwndTargetWin = FindWindow(NULL,"Audiosurf");

//create the command message and data struct
char* str = "asconfig freerideautoadvance false";
COPYDATASTRUCT cds;
cds.cbData = strlen(str)+1;
cds.lpData = (void*)str;

SendMessage(hwndTargetWin, WM_COPYDATA, 0, (LPARAM)&cds);
« Last Edit: June 13, 2008, 09:29:49 AM by Dylan » Logged
Pwntastic
Roffles The Mighty
Global Moderator
Hero Member
*****
Posts: 1684


rofflesthemighty@hotmail.com LordDosk
View Profile WWW Email
« Reply #1 on: April 10, 2008, 01:20:19 AM »

Awwww yeah. Audiosurf media player coming up Wink
Tomorrow (today) will be a busy day for sure

edit: damn, now i'm debating even going to bed or if i should just start this and code it all up in one straight run... tempting... Shocked
« Last Edit: April 10, 2008, 01:41:33 AM by Pwntastic » Logged


Quote from: John Carmack
it’s not “oh just thread your application”.  Anyone that says that is basically an idiot, not appreciating the problems.
ANOON
Jr. Member
**
Posts: 56


View Profile
« Reply #2 on: April 10, 2008, 03:35:37 AM »

With the latest beta patch, you can control Audiosurf from an external app by sending WM_COPYDATA messages to the Audisourf window.

Where can I find the patch?
Logged
Pwntastic
Roffles The Mighty
Global Moderator
Hero Member
*****
Posts: 1684


rofflesthemighty@hotmail.com LordDosk
View Profile WWW Email
« Reply #3 on: April 10, 2008, 03:49:19 AM »

I'm pretty sure he meant the one listed here: http://www.audio-surf.com/forum/index.php/topic,2789.msg23863.html#msg23863
Specifically: http://media.bestgameever.com/Audiosurf_BetaPatch_4.10.08.zip
Logged


Quote from: John Carmack
it’s not “oh just thread your application”.  Anyone that says that is basically an idiot, not appreciating the problems.
ANOON
Jr. Member
**
Posts: 56


View Profile
« Reply #4 on: April 10, 2008, 06:19:06 AM »

loading a song with WM_COPYDATA is working, but the other commands are not  Undecided
Logged
Pwntastic
Roffles The Mighty
Global Moderator
Hero Member
*****
Posts: 1684


rofflesthemighty@hotmail.com LordDosk
View Profile WWW Email
« Reply #5 on: April 10, 2008, 06:25:37 AM »

turning the road on and off seems to work fine. ill peek at the others
Logged


Quote from: John Carmack
it’s not “oh just thread your application”.  Anyone that says that is basically an idiot, not appreciating the problems.
ANOON
Jr. Member
**
Posts: 56


View Profile
« Reply #6 on: April 10, 2008, 06:30:47 AM »

Yeah I found out that commands only work when the focus is on the as window

//edit ahhh I already found the problem... never mind the commands are working
« Last Edit: April 10, 2008, 06:38:40 AM by ANOON » Logged
Pwntastic
Roffles The Mighty
Global Moderator
Hero Member
*****
Posts: 1684


rofflesthemighty@hotmail.com LordDosk
View Profile WWW Email
« Reply #7 on: April 10, 2008, 06:47:26 AM »

Hehehehe. The roads are tricky though, as they like to disappear if the audiosurf window moves behind another window. Then you cant tell if theyre on or off Tongue
Logged


Quote from: John Carmack
it’s not “oh just thread your application”.  Anyone that says that is basically an idiot, not appreciating the problems.
Dark-Sonik
Jr. Member
**
Posts: 70


Just your little rodent in blue~

tachykusanagi@hotmail.de
View Profile WWW Email
« Reply #8 on: April 10, 2008, 07:08:10 AM »

Here something what I posted in the topic about the command line extension someone made (to play songs by rightclicking the file and choosing "Play with Audiosurf"):

Quote
€dit1: Found some bugs which are kinda odd:

-When trying to play a song on "Eraser Elite", the game loads the file with the infobox saying "Eraser Elite", but on the track it's only "Eraser" (blocks disappear faster, powerups from Eraser normal, other block-layout ect.)

I can't tell if that's either a problem with the context menu or with the new Beta feature (wrong labelling of the command)

€dit2: Seems to be a bug in the commands. Playing on "Eraser" (from the context menu) shows Eraser-Characterinfo, but the track is like on "Eraser Elite".
Means that the commands are probably a bit bugged...
« Last Edit: April 10, 2008, 07:17:18 AM by Dark-Sonik » Logged

LOL DYLAN BANNED ME
Hero Member
*****
Posts: 971


View Profile Email
« Reply #9 on: April 10, 2008, 10:33:35 AM »

Can't get reloadtextures to work.... I'm pretty sure I'm sending it right, but it just, doesn't do anything. The game's still using the textures it started with.

Also, when you minimise the game, the song carries on like normal, but when you open it back up, the track goes SUPER fast to catch up.
« Last Edit: April 10, 2008, 10:37:03 AM by Cody900 » Logged
Pwntastic
Roffles The Mighty
Global Moderator
Hero Member
*****
Posts: 1684


rofflesthemighty@hotmail.com LordDosk
View Profile WWW Email
« Reply #10 on: April 10, 2008, 10:45:29 AM »

Moop it works fine. I just tried it Wink

edit: it'd be kinda nifty if you could have audiosurf send out a message when its fully loaded and ready for input, unless you already did i've not gotten that far yet.
but the only way i cna think would be user input or a timer to wait until audiosurf is probably loaded to get something to open audiosurf and then load a song.
with a ready alert, the app could know exactly when to send a load command to audiosurf
« Last Edit: April 10, 2008, 11:09:03 AM by Pwntastic » Logged


Quote from: John Carmack
it’s not “oh just thread your application”.  Anyone that says that is basically an idiot, not appreciating the problems.
LOL DYLAN BANNED ME
Hero Member
*****
Posts: 971


View Profile Email
« Reply #11 on: April 10, 2008, 11:44:32 AM »

Ok it's working now, I had to do some super lame coding that I finally found out how to do. It's working now.
Logged
Faxmachinen
Newbie
*
Posts: 30



View Profile
« Reply #12 on: April 10, 2008, 01:52:03 PM »

Finding a window only by its title is a really bad idea. If Audiosurf's root folder was properly capitalized, these commands would appear to break at random. Guess why?
Apparantly you can search for the window class name as well, so perhaps you should give that a somewhat unique name.
Logged
ANOON
Jr. Member
**
Posts: 56


View Profile
« Reply #13 on: April 10, 2008, 02:01:56 PM »

Finding a window only by its title is a really bad idea. If Audiosurf's root folder was properly capitalized, these commands would appear to break at random. Guess why?
Apparantly you can search for the window class name as well, so perhaps you should give that a somewhat unique name.

the classname is START Tongue not very unique but it has one;)
Logged
LOL DYLAN BANNED ME
Hero Member
*****
Posts: 971


View Profile Email
« Reply #14 on: April 10, 2008, 02:02:09 PM »

Finding a window only by its title is a really bad idea. If Audiosurf's root folder was properly capitalized, these commands would appear to break at random. Guess why?
Apparantly you can search for the window class name as well, so perhaps you should give that a somewhat unique name.

The folder doesn't make a difference... It's found by the title text, and if you just set that to "Audiosurf", then it doesn't use any wildcards, and Audiosurf is the only thing to return that exact title.

Or you could just use FindWindow('START', 'Audiosurf'), Spy++ shows me that nothing else I'm running so far has used Start as a class name.... and I still fail to see why Audiosurf's folder name makes a difference.
Logged
Pages: [1] 2 3 4
Print
Jump to:  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Rhett design by Crip | XHTML | CSS