From WikiChip
Editing mirc/sendmessage
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{ | + | {{mIRC Guide}} |
The {{Win32|SendMessage()}} function can be used to communicate with mIRC from your external [[process]] (e.g. another program or a [[dll]]). mIRC provides a number of private [[Window Messages]] to evaluate or execute commands and identifiers. | The {{Win32|SendMessage()}} function can be used to communicate with mIRC from your external [[process]] (e.g. another program or a [[dll]]). mIRC provides a number of private [[Window Messages]] to evaluate or execute commands and identifiers. | ||
== Initializing communication == | == Initializing communication == | ||
+ | |||
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: | 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: | ||
Line 32: | Line 33: | ||
The following call to SendMessage() makes mIRC perform the commands that you specify: | The following call to SendMessage() makes mIRC perform the commands that you specify: | ||
− | |||
− | |||
SendMessage(mHwnd, WM_MCOMMAND, cMethod, cIndex) | SendMessage(mHwnd, WM_MCOMMAND, cMethod, cIndex) | ||
Line 40: | Line 39: | ||
* '''WM_MCOMMAND''' - Which should be defined as WM_USER + 200 | * '''WM_MCOMMAND''' - Which should be defined as WM_USER + 200 | ||
* '''cMethod''' - How mIRC should process the message, where: | * '''cMethod''' - How mIRC should process the message, where: | ||
− | ** 1 = As if typed in editbox (default) | + | ** 1 = As if typed in editbox (default) |
** 2 = As if typed in editbox, send as plain text | ** 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 | + | ** 4 = Use flood protection if turned on, can be or'd with 1 or 2 |
− | ** 8 = Use unicode text. For backward compatibility reason, mIRC takes the data in the mapped file as ANSI by default, if you are willing to use unicode, you must use this. This can be or'd with 1 or 2 | + | ** 8 = Use unicode text. For backward compatibility reason, mIRC takes the data in the mapped file as ANSI by default, if you are willing to use unicode, you must use this. This can be or'd with 1 or 2. |
* '''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". | * '''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". | ||
Line 89: | Line 88: | ||
** '''8''' - Bad eventid. | ** '''8''' - Bad eventid. | ||
** '''16''' - Bad server. | ** '''16''' - Bad server. | ||
− | ** '''32''' - Bad script | + | ** '''32''' - Bad code/script. |
** '''64''' - Disabled (if disabled in lock dialog). | ** '''64''' - Disabled (if disabled in lock dialog). | ||
+ | = Examples = | ||
− | + | This example create a function "test" for a dll which will execute a //echo command in mIRC, we do not use Unicode. | |
− | + | <syntaxhighlight lang="mIRC">#include <cstdio> | |
− | + | #include <windows.h> | |
+ | #define WM_MCOMMAND WM_USER + 200 | ||
+ | #define WM_MEVALUATE WM_USER + 201 | ||
− | + | int __stdcall test(HWND mWnd, HWND aWnd, CHAR *data, char *parms, BOOL show, BOOL nopause) | |
+ | { | ||
+ | DWORD test = NULL; | ||
+ | HANDLE file = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,4096, "mIRC"); | ||
+ | LPSTR str = (LPSTR) MapViewOfFile(file, FILE_MAP_ALL_ACCESS, 0, 0, 0); | ||
+ | wsprintf(str,"//echo -s Hello world"); | ||
+ | SendMessage(mWnd, WM_MCOMMAND, 1 , 0); | ||
+ | CloseHandle(file); | ||
+ | return 1; | ||
+ | }</syntaxhighlight> | ||
+ | [[Category:MIRC]] | ||
+ | [[Category:Interprocess communication]] |