mIRC Homepage
Posted By: cgfiend Posting in a channel from a @window? - 21/07/04 03:59 PM
I'm attempting to perform message functions from a @window to a channel when I click on something in the @window, but the focus of the formerly active channel is "lost" and the Status window becomes the focus. How do I bring back focus to the last channel I was in so I can perform /say or /me?
Posted By: Kelder Re: Posting in a channel from a @window? - 21/07/04 05:17 PM
In scripts it's better to use /msg #channel instead of /say and /describe #channel instead of /me. (change #channel with the name of your channel ofcourse).

Now for the second problem: I'm not aware of a $id that gives you the last active channel, you can get the current active window with $active, but on your custom window, it will show @windowname...
Posted By: cgfiend Re: Posting in a channel from a @window? - 21/07/04 05:22 PM
Hmmm... might have to rethink this. I could always keep track of the rooms. /msg #channel mytext worked fine. But not knowing the last active channel is the problem. Hmm.. maybe I could do an ON trigger to store the channel name. I just hoped there was a better way. Thanks. Food for thought. smile

(edit)

I found a way. Use $chan(x) to find the name of each channel I'm in. Of course, it won't store the last channel I *was* in, but it should work. Also, if I am logged onto two servers I can use $server to get the server names, then use that to access both servers' channels.
Posted By: Iori Re: Posting in a channel from a @window? - 22/07/04 08:04 AM
  • on *:connect:unset %lactivechan. $+ $cid
    on *:active:#:set %lactivechan. $+ $cid #

//msg $($+(%,lactivechan.,$cid),2) message

You might want to unset it when you part (or are kicked from) channels too.
Posted By: cgfiend Re: Posting in a channel from a @window? - 22/07/04 02:54 PM
Thanks. Another way I figured out without using ON triggers...

;find file using filename from listbox (no path specified)
var %t = $findfile(g:\ogg,* $+ $sline(@FrethScript,1),0,var %f = $1-)

;play the file using an external player associated with file
/run %f

;switch to the last active channel and make it active again
/window -a $chan(1)

;place a command in the active window's edit box and press enter - in this case a play emote
/editbox -an /me plays $nopath(%f)

(edit) This is flawed tho since $chan(1) only gives the first channel window always. $lactive would be what to use, but I am still trying to figure out what it is when it's a status window.
Posted By: cgfiend Re: Posting in a channel from a @window? - 22/07/04 05:51 PM
Found the answer on this forum. smile Problem solved...

Instead of using this...
/window -a $chan(1)

...this works like a charm and works w/ Status WIndow...
window -a $iif(* * iswm $lactive,$+(",$lactive,"),$lactive)
Posted By: cgfiend Re: Posting in a channel from a @window? - 03/08/04 01:32 AM
***UPDATE***
I was wrong. Disregard the above!! Even with the above example, if you try to /me from a @Window when the last active window was the Status Window you will get an error message that /me cannot be used in the current window (status window).

The secret isn't to check for the last active window at all. Instead, you check the active window and see if it's the type of "status".

;If the active window type is not equal to "status" then
;take the edit box of the last active window and add
;"/me says something", then press Enter.

if $window($active).type != status { /editbox -an /me says something. }


This will effectively post in the last active window unless it's a status window. smile
© mIRC Discussion Forums