TonyJix
asked on
Moving the Mouse
Hello,
I need to move the window of another application, but SetWindowPos and MoveWindow don't work.
I had the idea of moving the mouse to the title bar of the application, then hold the left mouse button while moving the mouse (all programatically). This way I am able to move the application anyway.
Anyone any idea how to do a mouse click (let it hold) and move the mouse at the same time?
Thank you.
I need to move the window of another application, but SetWindowPos and MoveWindow don't work.
I had the idea of moving the mouse to the title bar of the application, then hold the left mouse button while moving the mouse (all programatically). This way I am able to move the application anyway.
Anyone any idea how to do a mouse click (let it hold) and move the mouse at the same time?
Thank you.
ASKER
Hi,
Not what I am looking for. I need it to click button and move mouse at the same time. Otherwise you won't drag the window.
Not what I am looking for. I need it to click button and move mouse at the same time. Otherwise you won't drag the window.
I think from that sample code you can simulate mouse button down, then mouse move, then mouse button up?
ASKER
Good one.. brb
ASKER
Not doing anything with this App...
So weird.. I can get the Handle of the window, I move the moust to the titlbar, then I drag it. But nothing happens. If I use the same code on Notepad it works fine.
It must have some anti-interfere code hehe.
So weird.. I can get the Handle of the window, I move the moust to the titlbar, then I drag it. But nothing happens. If I use the same code on Notepad it works fine.
It must have some anti-interfere code hehe.
Oh... sorry I have no idea about that... what application is it?
May be someone else can help?
May be someone else can help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Tony, dinilud only used the functions I gave you.
And why didn't your code only work on Notepad before?
And why didn't your code only work on Notepad before?
Sorry dinilud, no offence.
ASKER
Yes, maybe. I shouldve split... The code was easier to use though.
If you post your same solution here: https://www.experts-exchange.com/questions/22714749/SetWindowPos-alternative.html?cid=239
Then I will give you points there hardi.
If you post your same solution here: https://www.experts-exchange.com/questions/22714749/SetWindowPos-alternative.html?cid=239
Then I will give you points there hardi.
Oh so you open up 2 questions for this
Ok thank you :-D
Ok thank you :-D
i got one error.
Without checking correctly don't accept any answer.
procedure MyDragWindowToPos(pHandle: HWND;pPos: TPoint);
const XDiff=100; YDiff=10;
var R:TRect;
Rx,Ry:Word;
begin
GetWindowRect(pHandle,R);
SetCursorPos(R.Left+XDiff, R.Top+YDif f);
Rx:= Round((pPos.X+XDiff)*65535 /Screen.Wi dth);
Ry:= Round((pPos.Y+YDiff)*65535 /Screen.He ight);
Mouse_Event(MOUSEEVENTF_LE FTDOWN,0,0 , 0, 0) ;
Mouse_Event(MOUSEEVENTF_AB SOLUTE or MOUSEEVENTF_MOVE, 0, 0, 0, 0) ;
Mouse_Event(MOUSEEVENTF_AB SOLUTE or MOUSEEVENTF_MOVE, Rx , Ry, 0, 0) ;
Mouse_Event(MOUSEEVENTF_LE FTUP,0, 0, 0, 0) ;
end;
Without checking correctly don't accept any answer.
procedure MyDragWindowToPos(pHandle:
const XDiff=100; YDiff=10;
var R:TRect;
Rx,Ry:Word;
begin
GetWindowRect(pHandle,R);
SetCursorPos(R.Left+XDiff,
Rx:= Round((pPos.X+XDiff)*65535
Ry:= Round((pPos.Y+YDiff)*65535
Mouse_Event(MOUSEEVENTF_LE
Mouse_Event(MOUSEEVENTF_AB
Mouse_Event(MOUSEEVENTF_AB
Mouse_Event(MOUSEEVENTF_LE
end;
ASKER
It's the ABSOLUTE or MOUSEEVENTF_MOVE that's needed. Thanx though.
See this (see Simulations)
http://delphi.about.com/od/vclusing/a/mouseadvanced.htm