| Autor |
Beitrag |
Jowy
Hält's aus hier
Beiträge: 4
|
Verfasst: Mo 08.01.07 17:30
Hallo
Ich wusst ehrlich nicht richtig wohin mit meinem Problem und deshalb eröffne ich einfach mal hier den Thread ´~`
Wie der Titel schon sagt, möchte ich mit SendMessage(); einen Befehl an mIRC senden. Ja, ich habe schon die Suchen-Funktion benutzt und bin auf einen Thread mit 5 Zeilen Code gestoßen, was mir nicht richtig weiterhalf.
Erstmal Input:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
| procedure TForm1.Button1Click(Sender: TObject); const MYMESSAGE = WM_USER + 200; var wnd: hwnd; begin wnd := FindWindow('mIRC', nil); wnd := FindWindowEx(wnd, 0, 'Status', nil); SendMessage(wnd, MYMESSAGE, 1, 0); end;
end. |
Auszug aus der mIRC Help (leider in C++ Syntax):
| Zitat: | 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
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
cIndex - create a uniquely named mapped file, where lParam = N, the mapped filename is mIRCN.
If lParam is zero, the filename is mIRC, as in previous versions.
Returns - 1 if success, 0 if fail
|
Ich habe 2 Fragen.
1) Wo kann ich nun den Befehl an mIRC senden und vorallem wie?
2) create a uniquely named mapped <- Wie funktioniert das?
Danke für jede hilfreiche Antwort.
Jowy
|
|
Jowy 
Hält's aus hier
Beiträge: 4
|
Verfasst: Sa 13.01.07 16:26
...hat niemand eine Idee?
|
|
JayEff
      
Beiträge: 2971
Windows Vista Ultimate
D7 Enterprise
|
Verfasst: Sa 13.01.07 16:40
Die Syntax von SendMessage ist eigentlich die gleiche, wobei... Gib in Delphi SendMessage ein, markiere es, und drücke F1:
| Delphi OH: | The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7:
| LRESULT SendMessage(
HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); |
Parameters
hWnd
Identifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
Msg
Specifies the message to be sent.
wParam
Specifies additional message-specific information.
lParam
Specifies additional message-specific information.
Return Values
The return value specifies the result of the message processing and depends on the message sent.
Remarks
Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function to obtain a unique message for inter-application communication.
If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, Windows switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. |
Das heißt: Du suchst dir das Handle des Fensters raus, an das die Nachricht gehn soll, und sendest dann mit SendMessage die nachricht samt den Parametern an das Fenster.
Was genau du an mIRC senden musst, um den Effekt zu erreichen, den du willst, weiß ich nicht. Ob der Code zum finden des mIRC Fensterhandles richtig ist, kann ich auch nicht garantieren, aber X-SPY kann das.
_________________ >+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
|
|
Jowy 
Hält's aus hier
Beiträge: 4
|
Verfasst: Sa 13.01.07 21:42
Ich hab eine Unit namens mIRCc.pas gefunden und hab da mal bisschen durchgeschaut und mir meinen SendMessage(); Befehl zusammen gebastelt.
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| procedure TForm1.Button1Click(Sender: TObject); const MYMESSAGE = WM_USER + 200; var data: thandle; wnd: hwnd; data2: pchar;
begin data := CreateFileMapping(INVALID_HANDLE_VALUE,0,PAGE_READWRITE,0,4096,'mIRC'); data2 := MapViewOfFile(data,FILE_MAP_ALL_ACCESS,0,0,0); wnd := FindWindow('mIRC', nil); StrPCopy(data2,'/echo test'); SendMessage(wnd, MYMESSAGE, 1, 0); end;
end. |
Ich versteh zwar nicht warum es nun funktioniert, aber es funktioniert. :p
|
|
|