mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2014
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Mar 2014
Posts: 8
So, within an ON TEXT or similar remote event, when I use /dll or $dll the HWND that's supposed to be the active window is always the status window, not the window that recieved the event. How can I fix, or work around this?

Joined: Aug 2013
Posts: 80
I
Babel fish
Offline
Babel fish
I
Joined: Aug 2013
Posts: 80
Correct - that is the reason you can't use /say and /me in such events.

How, exactly, you handle this will depend on the event. For the on TEXT and ACTION (and to some extent, NOTICE) events, you can use:
Code:
$gettok($chan(#).hwnd $query($nick).hwnd $window(Message Window).hwnd,1,32)
within the event to return the handle of either the channel, query window, or dedicated message window, depending.

Joined: Jan 2004
Posts: 1,352
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,352
Quote:
Extended SendMessage() to enable executing a command in the context of a remote event. During a remote event, a $eventid identifier is set to a unique value to identify the event. This can be passed to a DLL which can then pass it back to mIRC using: SendMessage(mHwnd, WM_MCOMMAND, MAKEWPARAM(cMethod, cEventId), cIndex)

This will cause the command/evaluation to execute in the context of the remote event identified by cEventId. If cEventId is 0, this indicates a non-remote event.


This change added in 7.33 may also be useful

Joined: Jul 2006
Posts: 3,969
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,969
Read this thread, which tell us it's normal to get the hwnd of the status window for almost all events (has nothing to do with the fact you can't use /me inside an event, mIRC is aware if you do /me from an on text event which listen on a channel and could totally make /me working here by sending an action to that channel).
There is no local identifier returning the HWND of the window associated with the event, you can't possibly pass/use such a value, you can't possibly be annoyed by this side effect of running events with the status window, UNLESS you are using $window(@ $+ $wid).hwnd inside the definition of the event which is unlikely (in the thread, a workaround for that seems to grab the $wid value inside an alias call from that event..


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Mar 2014
Posts: 8
Can this returned handle be use as an HWND in a C/C++ DLL (is it an integer that can be converted to a HWND or HWND*)?

Edit: It is a shame that the active window isn't the calling window, but the server's status window.

Joined: Jul 2006
Posts: 3,969
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,969
Yes, those handles are not fake handles lol.
But I found what you need, when you make a call to a dll, the prototype of the function include an "aWnd" parameter, which is the handle of the window in which the command is being issued, this should be your correct target window.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Mar 2014
Posts: 8
I currently use that parameter, it isn't correct. It is set to the status window of the connection when used in remote events. When used in an alias or the remote event on INPUT it is correctly set.

Joined: Jul 2006
Posts: 3,969
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,969
Then you have to pass the parameter yourself, using $chan().hwnd for example


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 8
A
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Mar 2014
Posts: 8
Okay. I will do this, and then cast it to a HWND in the DLL.


Link Copied to Clipboard