用sendmessage 送字串到另一應用程式中 或 發送msn訊息 |
尚未結案
|
payment333
一般會員 發表:2 回覆:1 積分:0 註冊:2004-08-06 發送簡訊給我 |
小弟查過相關文件..但一直都查不到相關資料...小弟蠻菜的..問題如下
對於sendmessage 使用不是很清楚
比如要發送字串到到記事本中,程式碼如下
NotePad:=FindWindow('NotePad', nil);
h:=ChildWindowFromPoint(jimmy,Point(10,10));//如不帶此行則,字串會寫到標題上
s:='測試Test';
SendMessage(h, WM_SETTEXT,0,longint(PCHAR(S))); 請問如果我想把訊息傳送到msn的對話框中(文字輸入框中),請問point要帶多少,小弟亂用Caret當point座標,但依然無法把字串送到msn文字輸入框中,請問要怎麼做才可呢?小弟不想使用keybd_event方式送字元,因為小弟要傳送中文字,或有什麼方式可以傳送訊息給msn通訊錄上的名單,麻煩高手解答....謝謝
|
sos_admin
版主 發表:121 回覆:697 積分:768 註冊:2003-07-23 發送簡訊給我 |
|
cohost
一般會員 發表:2 回覆:6 積分:1 註冊:2005-08-24 發送簡訊給我 |
你可以參考這篇 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=36089 其中也有 sos_admin 版主的意見,發問者也由外國的網站找到了有用的function 我自己正在找一個 由讀卡機所接收的16位元的資料轉到其他者的程式(游標位置)顯示(小作家也可) 下面是這個function 及我用Timer1Timer 去反覆送出字串的例子
測試出來了,應可開始寫了 ^^ function GetSysFocus : integer;
Var
hOtherWin,OtherThreadID,hFocusWin : integer; Begin
hOtherWin := GetForegroundWindow;
OtherThreadID := GetWindowThreadProcessID( hOtherWin, nil);
If AttachThreadInput( GetCurrentThreadID, OtherThreadID, true ) Then
Begin
hFocusWin := GetFocus;
result := GetFocus;
AttachThreadInput( GetCurrentThreadID, OtherThreadID, False );
End
else
result := getFocus;
End; procedure TForm1.Timer1Timer(Sender: TObject);
var s:string;
h, npad:HWND;
begin
StatusBar.Panels[0].Text:=DateTimeToStr(Now); if GetSysFocus <> 0 then begin
h:=ChildWindowFromPoint(GetSysFocus,Point(10,10));
if h <> 0 then begin
BringWindowToTop(GetSysFocus); //使其成為focus之window
s:='測試Test';
SendMessage(h, WM_SETTEXT,0,longint(PCHAR(S)));
end;
end; end;
|
chtai
高階會員 發表:68 回覆:238 積分:116 註冊:2004-05-21 發送簡訊給我 |
payment333 您好, 您可以參考看看我以前發表過的文章,相信可完全達到您的需求。
雖然是用 BCB 寫的,不過我相信您一定看得懂 :) http://delphi.ktop.com.tw/topic.php?TOPIC_ID=64701 --
http://www.csie.nctu.edu.tw/~chtai/software.php
好用免費軟體的收集網頁
------
My Web: http://nelson.csie.us My Blog: http://blog.nelson.csie.us |
cohost
一般會員 發表:2 回覆:6 積分:1 註冊:2005-08-24 發送簡訊給我 |
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=38172
這篇才是我要推薦的,內有 wawa作者 及 sos_admin 大大的意見 另外 chtai 大大
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=64701
所推薦的bcb 也可以執行成功
不過小第在bcb上,仍沒研究出轉成delphi的方法
只有自己寫了一個還有點問題的程式
找得到視窗了,但游標都黏在開頭,且會把原先的視窗中的文字砍掉
想說看可否,不刪原先的文字(利用insert),且游標移動到後面 or 下一行(類似enter) unit Unit1; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls; type
TForm1 = class(TForm)
Timer1: TTimer;
StatusBar1: TStatusBar;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.DFM} function GetSysFocus : integer;
Var
hOtherWin,OtherThreadID,hFocusWin : integer; Begin
hOtherWin := GetForegroundWindow;
OtherThreadID := GetWindowThreadProcessID( hOtherWin, nil);
If AttachThreadInput( GetCurrentThreadID, OtherThreadID, true ) Then
Begin
hFocusWin := GetFocus;
result := GetFocus;
AttachThreadInput( GetCurrentThreadID, OtherThreadID, False );
End
else
result := getFocus;
End; function PutStrFocus(sStr : string) : boolean;
var s:string;
h:HWND;
begin
if GetSysFocus <> 0 then begin
h:=ChildWindowFromPoint(GetSysFocus,Point(13,0));
if h <> 0 then begin
BringWindowToTop(GetSysFocus); //使其成為focus之window
s:=sStr;
SendMessage(h, WM_SETTEXT,0,longint(PCHAR(S)));
end;
end;
end; procedure TForm1.Timer1Timer(Sender: TObject);
var s:string;
h, npad:HWND;
begin
StatusBar1.Panels[0].Text:=DateTimeToStr(Now);
PutStrFocus(DateTimeToStr(Now));
end; end. 搶了payment333 大大的版面, 粉抱歉囉
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
之前寫法: http://delphi.ktop.com.tw/topic.php?topic_id=61102 另一寫法 //使用Delphi的CD資料夾中,有Info\Extras\SendKeys\SndKey32.pas 方式: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,sndkey32, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); protected procedure CreateParams(var Params: TCreateParams); override; procedure WndProc(var Message: TMessage); override; private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); Params.ExStyle := Params.ExStyle or WS_EX_NOACTIVATE; end; procedure TForm1.WndProc(var Message: TMessage); var r:TRect; begin if (Message.Msg =WM_MOVING) then begin r.Left :=0; r.Top :=0; r.Right:=0; r.Bottom:=0; r := TRect(Pointer(Message.LParam)^); Self.Left := r.Left; Self.Top := r.Top; end; inherited WndProc(Message); end; procedure TForm1.FormCreate(Sender: TObject); begin self.BorderStyle:=bsSingle; self.FormStyle:=fsStayOnTop; end; procedure TForm1.Button1Click(Sender: TObject); begin SendKeys('abc123', True); end; end.網海無涯,唯學是岸! 發表人 - qoo1234 於 2005/08/31 23:30:38 |
cohost
一般會員 發表:2 回覆:6 積分:1 註冊:2005-08-24 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |