From WikiChip
Difference between revisions of "mirc/sendmessage"
< mirc

(Remote Event Context)
 
(110 intermediate revisions by 62 users not shown)
Line 1: Line 1:
You can use SendMessage to communicate with mIRC from your external application, in your dll for example.
+
Hello
  
= Initializing communication =
+
Need Help Managing Your Social Media?
  
The external programs that send these messages must create a mapped file with the [http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537%28v=vs.85%29.aspx CreateFileMapping()] function:
+
Social Media Manager keeps your brand active across all platforms: Facebook, Instagram, TikTok, LinkedIn, YouTube, Pinterest, and X.
  
CreateFileMapping(
+
Increases visibility, and saves you time. More engagement, more growth without the daily hassle.
  _In_      HANDLE hFile,
 
  _In_opt_  LPSECURITY_ATTRIBUTES lpAttributes,
 
  _In_      DWORD flProtect,
 
  _In_      DWORD dwMaximumSizeHigh,
 
  _In_      DWORD dwMaximumSizeLow,
 
  _In_opt_  LPCTSTR lpName
 
);
 
  
* Use INVALID_HANDLE_VALUE for the hFile parameter, which basically allows the sytem to handle the file for us.
+
Do you need this service for your business? Try it now and see the difference.
* Use NULL for lpAttributes, for a default security.
 
* Use PAGE_READWRITE for flProtect, to be able to read and write from/to the file.
 
* Use 0 for dwMaximumSizeHigh and 4096 for dwMaximumSizeLow to indicate a file of that size
 
  
'''Note''': The mapped file must be at least 4096 bytes.
+
Reply to this email, and I'll be happy to share more details with you.
  
* lpName is the name of the file, in previous version of mIRC, this parameter had to be "mIRC", you certainly can see the limitation with this, so it was extended, you can now specify a name of the form "mIRCN" where N is a number. You can also still use mIRC of course.
+
Best regards,
 +
Glory
  
'''Note''': To prevent simultaneous access to the mapped file, your code must check whether the mapped file exists or not before using it. If it exists, you should assume that it is in use by another program, and should try again later.
 
  
= Communicating =
 
  
== Performing Commands ==
 
  
The following call to SendMessage() makes mIRC perform the commands that you specify:
 
  
SendMessage(mHwnd, WM_MCOMMAND, cMethod, cIndex)
 
  
* '''mHwnd''' - the handle of the main mIRC window, or the handle of a Channel, Query, etc. window.
 
* '''WM_MCOMMAND''' - which should be defined as WM_USER + 200
 
* '''cMethod''' - how mIRC should process the message, where:
 
** 1 = as if typed in editbox (default)
 
** 2 = as if typed in editbox, send as plain text
 
** 4 = use flood protection if turned on, can be or'd with 1 or 2
 
** 8 = use unicode text
 
  
* '''cIndex''' - If you created a mapped filename of the form "mIRCN", this is where you specify the N parameter to use, if cIndex is 0, the filename must be "mIRC".
 
  
This call returns 1 on success, 0 if it fails.
 
  
== Evaluating Identifiers and Variables ==
 
  
The following call to SendMessage() makes mIRC evaluate the contents of any line that you specify:
 
  
SendMessage(mHwnd, WM_MEVALUATE, cMethod, cIndex)
 
  
* '''mHwnd''' - the handle of the main mIRC window, or the handle of a Channel, Query, etc. window.
 
* '''WM_MEVALUATE''' - should be defined as WM_USER + 201
 
* '''cMethod''' - how mIRC should process the message, where:
 
** 8 = use unicode text
 
  
* '''cIndex''' - If you created a mapped filename of the form "mIRCN", this is where you specify the N parameter to use, if cIndex is 0, the filename must be "mIRC".
 
  
This call returns 1 on success, 0 if it fails.
 
  
= Remote Event Context =
 
  
If during a remote event, such as on TEXT, your script calls a DLL which then uses SendMessage() to execute a command or evaluate an identifier, you can tell SendMessage() to execute in the context of that remote event.
 
  
During a remote event, a {{mIRC|$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.
 
  
= Extended Version Information =
 
  
If '''cMethod''' is set to -1, you can set '''cIndex''' to:
 
* '''-1''' - to receive the mIRC version number.
 
* '''-2''' - to receive the cMethod options that are supported.
 
  
= Extended Error Information =
 
  
If cMethod is or'd with the value 16, this will make SendMessage() return more useful error values instead of just 0 for failure and 1 for success. The return values are:
+
 
* '''0''' - Success.
+
 
* '''1''' - Failure, You can OR that value to get more specific errors:
+
 
** '''2''' - Bad mapped filename.
+
 
** '''4''' - Bad mapped file size.
+
 
** '''8''' - Bad eventid.
+
 
** '''16''' - Bad server.
+
 
** '''32''' - Bad code/script.
+
 
** '''64''' - Disabled (if disabled in lock dialog).
+
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Netherlands, NB, Eindhoven, 5629 Gw, Agaat 182
 +
To stop any further communication through your website form, Please reply with subject:  Unsubscribe !wikichip.org

Latest revision as of 11:55, 6 July 2025

Hello

Need Help Managing Your Social Media?

Social Media Manager keeps your brand active across all platforms: Facebook, Instagram, TikTok, LinkedIn, YouTube, Pinterest, and X.

Increases visibility, and saves you time. More engagement, more growth without the daily hassle.

Do you need this service for your business? Try it now and see the difference.

Reply to this email, and I'll be happy to share more details with you.

Best regards, Glory






















Netherlands, NB, Eindhoven, 5629 Gw, Agaat 182 To stop any further communication through your website form, Please reply with subject: Unsubscribe !wikichip.org