远程控制桌面时为和鼠标按下能传过去,而鼠标抬起却传不过去??? ( 积分: 100 )

  • 主题发起人 主题发起人 lcl_003
  • 开始时间 开始时间
L

lcl_003

Unregistered / Unconfirmed
GUEST, unregistred user!
我下载了remotecxp代码研究,发现控制其他电脑时鼠标左键的抬起发不过去,而按下可以。但是鼠标右键按下抬起都能发过去。代码看不出有啥区别啊:(哪位帮忙分析下是啥问题啊。

这是控制端的鼠标按下,抬起,移动的代码
procedure TRemoteCPCFm.FormMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if SpeedButton4.Down = False then exit; //如果鼠标标志置上则
if Form1.IdFTCPClient.Connected = False then exit; //如果网络开通则
try
Form1.IdFTCPClient.Write('鼠标命令' + EOL); //发送鼠标命令---1
StringsLen := 0;
SendStrings.Clear;
SendStrings.Append('鼠标移动'); //发送鼠标参数---2
SendStrings.Append('随便'); //数据对齐---3
//发送鼠标参数---4
SendStrings.Append(IntToStr((X * RemoteScreenWidth) div Screen.Width));
//发送鼠标参数---5
SendStrings.Append(IntToStr((Y * RemoteScreenHeight) div Screen.Height));
StringsLen := Length(SendStrings.Text);
Form1.IdFTCPClient.WriteInteger(StringsLen);
Form1.IdFTCPClient.WriteStrings(SendStrings);
sleep(10);
except
Panel2.Caption := '注意:鼠标命令失败!';
end;
end;

procedure TRemoteCPCFm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if SpeedButton3.Down = False then exit; //如果键盘标志置上则
if Form1.IdFTCPClient.Connected = False then exit; //如果网络开通则
try
Form1.IdFTCPClient.Write('键盘命令' + EOL); //发送键盘命令---1
StringsLen := 0;
SendStrings.Clear;
SendStrings.Append('键盘按下'); //发送键盘命令---2
SendStrings.Append(IntToStr(Key)); //发送键盘虚拟码参数---3

StringsLen := Length(SendStrings.Text);
Form1.IdFTCPClient.WriteInteger(StringsLen);
Form1.IdFTCPClient.WriteStrings(SendStrings);
except
Panel2.Caption := '注意:键盘命令失败!';
end;
end;

procedure TRemoteCPCFm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if SpeedButton3.Down = False then exit; //如果键盘标志置上则
if Form1.IdFTCPClient.Connected = False then exit; //如果网络开通则
try
Form1.IdFTCPClient.Write('键盘命令' + EOL); //发送键盘命令---1
StringsLen := 0;
SendStrings.Clear;
SendStrings.Append('键盘抬起'); //发送键盘命令---2
SendStrings.Append(IntToStr(Key)); //发送键盘虚拟码参数---3

StringsLen := Length(SendStrings.Text);
Form1.IdFTCPClient.WriteInteger(StringsLen);
Form1.IdFTCPClient.WriteStrings(SendStrings);
except
Panel2.Caption := '注意:键盘命令失败!';
end;
end;



下面是被控端的代码
procedure RemoteMouseControl(AThread: TIdPeerThread);
var
MouseState: string; //按键状态
MouseButton: string; //鼠标之左-- 中-- 右键
MousePos: TPoint; //鼠标点
ReadStringLen: integer;
ReadStrings: TStringList;
begin
try
ReadStrings := TStringList.Create;
except
exit;
end;
try
ReadStringlen := AThread.Connection.ReadInteger;
if ReadStringLen > 200 then
begin
ReadStrings.Free;
exit;
end;
ReadStrings.Text := AThread.Connection.ReadString(ReadStringLen);
except
ReadStrings.Free;
exit;
end;

if ReadStrings.Count < 4 then exit;

MouseState := ReadStrings[0];
MouseButton := ReadStrings[1];
try
MousePos.X := StrToInt(ReadStrings[2]);
MousePos.Y := StrToInt(ReadStrings[3]);
except
ReadStrings.Free;
exit;
end;
ReadStrings.Free;
if MouseState = '鼠标按下' then //处理鼠标按下模拟
begin
if MouseButton = '左键' then
Mouse_Event(MOUSEEVENTF_LEFTDOWN, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '中键' then
Mouse_Event(MOUSEEVENTF_MIDDLEDOWN, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '右键' then
Mouse_Event(MOUSEEVENTF_RIGHTDOWN, MousePos.X, MousePos.Y, 0, 0);

end else
if MouseState = '鼠标抬起' then //处理鼠标抬起模拟
begin
if MouseButton = '左键' then
Mouse_Event(MOUSEEVENTF_LEFTUP, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '中键' then
Mouse_Event(MOUSEEVENTF_MIDDLEUP, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '右键' then
Mouse_Event(MOUSEEVENTF_RIGHTUP, MousePos.X, MousePos.Y, 0, 0);

end else
if MouseState = '鼠标移动' then //处理鼠标移动模拟
begin
SetCursorPos(MousePos.X, MousePos.Y);
end;
end;
 
我下载了remotecxp代码研究,发现控制其他电脑时鼠标左键的抬起发不过去,而按下可以。但是鼠标右键按下抬起都能发过去。代码看不出有啥区别啊:(哪位帮忙分析下是啥问题啊。

这是控制端的鼠标按下,抬起,移动的代码
procedure TRemoteCPCFm.FormMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if SpeedButton4.Down = False then exit; //如果鼠标标志置上则
if Form1.IdFTCPClient.Connected = False then exit; //如果网络开通则
try
Form1.IdFTCPClient.Write('鼠标命令' + EOL); //发送鼠标命令---1
StringsLen := 0;
SendStrings.Clear;
SendStrings.Append('鼠标移动'); //发送鼠标参数---2
SendStrings.Append('随便'); //数据对齐---3
//发送鼠标参数---4
SendStrings.Append(IntToStr((X * RemoteScreenWidth) div Screen.Width));
//发送鼠标参数---5
SendStrings.Append(IntToStr((Y * RemoteScreenHeight) div Screen.Height));
StringsLen := Length(SendStrings.Text);
Form1.IdFTCPClient.WriteInteger(StringsLen);
Form1.IdFTCPClient.WriteStrings(SendStrings);
sleep(10);
except
Panel2.Caption := '注意:鼠标命令失败!';
end;
end;

procedure TRemoteCPCFm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if SpeedButton3.Down = False then exit; //如果键盘标志置上则
if Form1.IdFTCPClient.Connected = False then exit; //如果网络开通则
try
Form1.IdFTCPClient.Write('键盘命令' + EOL); //发送键盘命令---1
StringsLen := 0;
SendStrings.Clear;
SendStrings.Append('键盘按下'); //发送键盘命令---2
SendStrings.Append(IntToStr(Key)); //发送键盘虚拟码参数---3

StringsLen := Length(SendStrings.Text);
Form1.IdFTCPClient.WriteInteger(StringsLen);
Form1.IdFTCPClient.WriteStrings(SendStrings);
except
Panel2.Caption := '注意:键盘命令失败!';
end;
end;

procedure TRemoteCPCFm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if SpeedButton3.Down = False then exit; //如果键盘标志置上则
if Form1.IdFTCPClient.Connected = False then exit; //如果网络开通则
try
Form1.IdFTCPClient.Write('键盘命令' + EOL); //发送键盘命令---1
StringsLen := 0;
SendStrings.Clear;
SendStrings.Append('键盘抬起'); //发送键盘命令---2
SendStrings.Append(IntToStr(Key)); //发送键盘虚拟码参数---3

StringsLen := Length(SendStrings.Text);
Form1.IdFTCPClient.WriteInteger(StringsLen);
Form1.IdFTCPClient.WriteStrings(SendStrings);
except
Panel2.Caption := '注意:键盘命令失败!';
end;
end;



下面是被控端的代码
procedure RemoteMouseControl(AThread: TIdPeerThread);
var
MouseState: string; //按键状态
MouseButton: string; //鼠标之左-- 中-- 右键
MousePos: TPoint; //鼠标点
ReadStringLen: integer;
ReadStrings: TStringList;
begin
try
ReadStrings := TStringList.Create;
except
exit;
end;
try
ReadStringlen := AThread.Connection.ReadInteger;
if ReadStringLen > 200 then
begin
ReadStrings.Free;
exit;
end;
ReadStrings.Text := AThread.Connection.ReadString(ReadStringLen);
except
ReadStrings.Free;
exit;
end;

if ReadStrings.Count < 4 then exit;

MouseState := ReadStrings[0];
MouseButton := ReadStrings[1];
try
MousePos.X := StrToInt(ReadStrings[2]);
MousePos.Y := StrToInt(ReadStrings[3]);
except
ReadStrings.Free;
exit;
end;
ReadStrings.Free;
if MouseState = '鼠标按下' then //处理鼠标按下模拟
begin
if MouseButton = '左键' then
Mouse_Event(MOUSEEVENTF_LEFTDOWN, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '中键' then
Mouse_Event(MOUSEEVENTF_MIDDLEDOWN, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '右键' then
Mouse_Event(MOUSEEVENTF_RIGHTDOWN, MousePos.X, MousePos.Y, 0, 0);

end else
if MouseState = '鼠标抬起' then //处理鼠标抬起模拟
begin
if MouseButton = '左键' then
Mouse_Event(MOUSEEVENTF_LEFTUP, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '中键' then
Mouse_Event(MOUSEEVENTF_MIDDLEUP, MousePos.X, MousePos.Y, 0, 0);
if MouseButton = '右键' then
Mouse_Event(MOUSEEVENTF_RIGHTUP, MousePos.X, MousePos.Y, 0, 0);

end else
if MouseState = '鼠标移动' then //处理鼠标移动模拟
begin
SetCursorPos(MousePos.X, MousePos.Y);
end;
end;
 
呵呵,我以前也遇到过这个问题,不过已经解决了,代码在家里,如果你需要的话,请留下EMAIL,我明天可以发给你
 
xmcccc,多谢多谢 2000se@163.com
 
老兄,你搞这些干嘛呀? 效果有XP里的远程桌面好吗?

有一年多没有来这里了,今天上来发帖招聘,NND,原来的一万多分都不见了。不知道何故。

你们的小公司搞的如何了?
 
哈哈哈~~~~~~当然没有xp远程桌面效果好了。写这些无非骗点钱吗[:D],还行,凑合混口饭吃:)
 
可以发个给我吗?goodliuyi2000@163.com
 
我们用过一种VNC server 和VIEWER的网络软件,发现客户端控制时,当打开服务器的大型程序时,客户端的VNC VIWER死掉了,当然,服务器的使用了多屏卡。。不知如何详细解释?谢谢!
 
可以发个给我吗?xiayu-open@163.com 不胜感激
 
可以发个给我吗?cqjxnc@sina.com.cn不胜感激
 
可以傳給我研究...我是一位delphi編程愛好者...veition@yahoo.com
 
接受答案了.
 
可以发个给我吗?zyw83238@163.com
 
后退
顶部