Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Selrach
Newbie


Joined: 14 Jan 2012
Posts: 8

PostPosted: Sat Jan 24, 2015 3:28 pm   

Trigger which plays sound only when window is inactive?
 
To give a basic example, I have a chat redirector which triggers whenever someone sends me a direct message. I would like to make it soo this same trigger will play a sound.. but only if I am not actively in the cmud window at the time. This way I'll be notified when tabbed out, and won't be bombarded and annoyed with the sounds when in a discussion with someone.

This is a feature I made a lot of use of in mushclient before changing over. No clue if it's just not possible in cmud, or if I've overlooked something simple.
Thanks in advance for any assistance with this.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sat Jan 24, 2015 9:58 pm   
 
#PLAY will play media files no problem.
Not sure how to test if CMUD itself currently has keyboard focus.
I could tell you which of the windows has focus, but that doesn't seem to go null when another program has focus.
_________________
Discord: Shalimarwildcat
Reply with quote
Selrach
Newbie


Joined: 14 Jan 2012
Posts: 8

PostPosted: Sun Jan 25, 2015 12:15 am   
 
Hrmm, while not precisely what I'm after, I could make use of that to similar effect by clicking on the chat window before tabbing out.. it would be a lot better than the only other option I've thought of so far which is turning on/off a folder of triggers manually each time I tab in/out.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sun Jan 25, 2015 2:36 am   
 
There might be a way to determine the program that has focus with lua, or one of the other languages CMUD can understand natively without installing more libraries.
_________________
Discord: Shalimarwildcat
Reply with quote
Selrach
Newbie


Joined: 14 Jan 2012
Posts: 8

PostPosted: Sun Jan 25, 2015 9:53 am   
 
I tried a few of the other languages, settled on the checking window focus you mentioned.
I used:
#if (%curwin!=mudnamehere) {#beep} {}
I need to click the chat window before tabbing out, but it'll serve the purpose.
Thanks for the help. =3
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Jan 25, 2015 1:15 pm   
 
It's possible with Lua. I did it with the winapi lua library available here: http://stevedonovan.github.com/files/winapi13-51gcc32.zip. Don't have the code handy, but I believe I did something like this:
Code:
if winapi.get_foreground_window():get_process():get_process_name() ~= "CMUD.exe" then zs.cmd.beep() end

Full API reference for that library is available here, for any tweaking that may be required: http://stevedonovan.github.io/winapi/api.html
Reply with quote
Selrach
Newbie


Joined: 14 Jan 2012
Posts: 8

PostPosted: Mon Jan 26, 2015 11:56 am   
 
I haven't done much with Lua before, soo having a hard time figuring this out.. first thing though, where is the winapi file supposed to go? My best guess is the cmud install directory, but when I tested it there with both..
Code:
if winapi.get_foreground_window():get_process():get_process_name() ~= "cMUDPro.exe" then zs.cmd.beep() end

and
Code:
if winapi.get_foreground_window():get_process():get_process_name() == "cMUDPro.exe" then zs.cmd.beep() end

I don't get a beep. If it's processing correctly, one of those two should produce a beep I'd think.

I tested zs.cmd.beep() on its own to be sure that was working, and it was, but when I tried doing a sound with zs.cmd.play("C:\path\to\sound.wav"), as I'd eventually want an actual sound, not just a beep, I couldn't get that working either, I figure I'm just not passing the location to it properly, not sure the right way.. I also tried it as just zs.play, and without quotes/with single quotation marks, none of those worked.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Jan 27, 2015 8:19 am   
 
I believe the winapi.dll should go in the lua folder in the main CMUD directory. You also need to load it in your trigger with require("winapi"). The play command isn't working because backslash is a special character in lua strings, used for escape sequences (\n is new line, \t is a tab character, etc). For a literal backslash, you need to double it, \\.
Reply with quote
Selrach
Newbie


Joined: 14 Jan 2012
Posts: 8

PostPosted: Tue Jan 27, 2015 8:56 am   
 
Ook, got the play command working easily, thanks! There seems to be no lua folder in the main cmud directory. I tried creating a folder named lua and putting it in there just to test, but regardless of where it is anything after the require statement in the script appears not to be executing, so I presume that means it's not seeing it? The odd thing is I'm not getting any sort of errors though..
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Tue Jan 27, 2015 9:18 am   
 
lua5.1.dll
is in the program files/cmud folder directly, stick the api beside it
_________________
Discord: Shalimarwildcat
Reply with quote
Selrach
Newbie


Joined: 14 Jan 2012
Posts: 8

PostPosted: Tue Jan 27, 2015 9:36 am   
 
That's where I've had it soo far, other than when I made a specific directory for it that is, it's back there now..

I was going to say I still had the same issues, but while typing this out I tried restarting the client again on a hunch and finally got an error message saying that it couldn't process because lua51.dll was missing. I copied lua5.1.dll and renamed the copy to lua51.dll, now the entire thing seems to be working.
Surprising and confusing, but pleasing.
Thanks for all of the help!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net