if soundwave.wav plays then send character/test>

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

if soundwave.wav plays then send character/test>

Post by Snickers » Mon Dec 12, 2005 3:24 am

Is there a function that monitors a particular sound file and if it is played, macro scheduler can perform the next step?

for example:

If soundwav.wav plays
Send Character/text>yadayada
endif

Also, is there a command to check the pixel color at a certain pixel and say that the mouse cursor is over that location. I want to know the color of the cursor.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 12, 2005 12:56 pm

No, but are you really wanting to monitor an actual sound file or a system event which is mapped to a sound file? There is more likely to be a way to monitor system events, some of which cause sounds to be played.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Dec 12, 2005 1:57 pm

in the particular game that I am playing, the only indications that I receive that tells me its time to click the button is a sound wav that is played. Is there a way to edit the sound file to make the sound wav itself start a macro? Like some code in the sound wav?

It is a game that causes the system event so I don't know how to monitor that event within the game. I suppose I could locate the memory address but that would take me forever.

IanSmith
Junior Coder
Posts: 24
Joined: Tue Jul 12, 2005 2:31 pm

Post by IanSmith » Mon Dec 12, 2005 3:13 pm

The crudest way to do this would be to monitor the last access time of the wav file - but be aware that this has an accuracy of one minute...if you are trying to get a script to play a game for you it might be better to learn to play the game!

Anyway, you could try this is a loop:

Run>cmd.exe /c dir sound.wav > %temp%\time.txt
readln>%temp%\time.txt,1,timeline
midstr>%timeline%,13,5,time

then compare the time with the last value to see if the file has been accessed. The /ta switch for dir uses the access time as the search criterion. Using one > means that the line is overwritten each time it's checked.

As for getting the colour of a cursor (I'm assuming for reference, and not during a game) is to do a mouse move, and then use GetPixelColor for a couple of pixels down and across. If you want to do it during a game you could use GetCursorPos and do the same thing...

Hope that helps,

Ian

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Dec 12, 2005 4:30 pm

IanSmith wrote:...if you are trying to get a script to play a game for you it might be better to learn to play the game!
This is a pretty funny and thoughtless comment to be honest. Someone who writes macros or codes programs that "play games for you" not only know how to play the game already but understand it better than your average player. So I don't need to learn to play the game. I have a pretty good grasp on it already.

The macro I am trying to write will repeat a motion for me that I am tired of doing in game. The in game motion makes me a lot of in game coinage; however, the motion is getting a bit boring and I'd like my macro to do it for me.

I thought about doing the last access such as you have mentioned but it didn't respond quickly enough.

Right now I'm going to try and find a way to make the wav file not only play the sound but send a hotkey of sorts that would start the macro for me.

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Tue Dec 13, 2005 2:03 am

Another method to get the last access time would be to use the VBS File System Object, it is accurate to the second. I've turned off the last accessed feature on my NTFS drives to save a bit of overhead so I am not really able to test this with WAV files recently accessed - it's on by default so unless you've turned it off, this may get you pointed in the right direction...
Dim fso, myfile, msg
Set fso = CreateObject("Scripting.FileSystemObject")
Set myfile = fso.GetFile("D:\Temp\rt3guide2.pdf")
msg = "The file " & myfile.name & " was last accessed: " & myfile.DateLastAccessed
MsgBox msg, vbOKOnly, "File Last Accessed Info"
Set fso = Nothing
Set myfile = Nothing
Best Wishes,
Monkster

IanSmith
Junior Coder
Posts: 24
Joined: Tue Jul 12, 2005 2:31 pm

Post by IanSmith » Tue Dec 13, 2005 9:28 am

Woo - sorry if an offhand comment caused offence; I was reminded of the bloke earlier this year who asked someone to write a macro for free to change gear in a driving game he was playing...

Take care, Ian

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Tue Dec 13, 2005 1:47 pm

No worries; no offense taken.

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Tue Dec 13, 2005 6:53 pm

Alright I have found another way to make it work without having to monitor the .wav file.

It is up and running but now i want to make it usable by a few close friends of mine. I have added a window resolution formula that finds the window resolution and multiplies it by a certain decimal number; however, the number sometimes returns an unwanted value such as, 300.6.

How can i turn this into a whole number or omit the decmal position. for example:

//maximized your window
wait>5
WindowAction>1,name_of_window
//determine your screen or window resolution
SetFocus>name_of_window
GetActiveWindow>name_of_window,X,Y,W,H
//calculate location to start
let>W2=%W%*.23
let>H2=%H%*.30
//calculate maximum ending position
let>W3=%W%*.74
let>H3=%H%*.70
//send me a message to test calculations TEMPORARY
//REMOVE************REMOVE************REMOVE************REMOVE
MessageModal>%W%,%H% , the y axis is %H2% - %H3%, the x axis is %W2% - %W3%

The values returned are usually ending with a decimal. I cant send the mouse to move to 300.6,701.4

How might I be able to calculate without decimals or round off the decimal place?

The exact pixel i am moving to does not need to be exact.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Dec 13, 2005 7:13 pm

Use the Round or Trunc functions. Round rounds up or down to an integer value. Trunc just cuts off the decimals to return an integer value:

//This will round 301.6 up to 302
Let>a=301.6
Let>a={Round(%a%)}

//This will round 301.2 down to 301
Let>a=301.2
Let>a={Round(%a%)}

//This will just truncate to 301
Let>a=301.6
Let>a={Trunc(%a%)}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Wed Dec 14, 2005 1:27 am

It is beautiful!

You guys have been a great help!

Only one last step to go, and we'll see what happens.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts