Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

sending mousedown and mouseup to foreign application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Trollpower - 19 May 2004 13:06 GMT
Dear NG,

ive got a small C# Application which needs to send a mousedown event,
followed by a mouseup event to a foreign window (eg. browser window).

I managed to get the appropriate windowhandle and also putting it into
the foreground. But sending a message with "buttondown" allways shows
no effect. I dont get any error-messages, since i put the whole code
into a try-catch-clause.

I use the following code to send a mousedown-message to the window:

uint WM_LBUTTONDOWN   = 0x0201;
SetForegroundWindow((int)windowHandle);
SendMessage(windowHandle, WM_LBUTTONDOWN, 0, 0);

The "windowHandle"-variable is valid and "SetForegroundWindow" show
effect. i also tried PostMessage instead of Sendmessage, but the
effect stays the same: nothing happens.

Background:

The target window shows a small game, which needs a mouseclick to be
started. The window shows up but the sendmessage wont let the game
start.

Any ideas on how to bring the sendmessage to work?

Thanks in advance

Jens
Gabriele G. Ponti - 19 May 2004 13:38 GMT
Try setting the wParam of SendMessage() to MK_LBUTTON.
Trollpower - 21 May 2004 07:59 GMT
> Try setting the wParam of SendMessage() to MK_LBUTTON.

Thanks Gabriele,

i tried your suggestion without any success. Anyone got further hints
on how to solve this problem?
Jeff Gaines - 21 May 2004 12:46 GMT
>> Try setting the wParam of SendMessage() to MK_LBUTTON.
>
>Thanks Gabriele,
>
>i tried your suggestion without any success. Anyone got further hints
>on how to solve this problem?

I've never had a lot of success sending dummy mouse clicks to
other windows, I think that Windows knows where the mouse is and
just doesn't accept that it was clicked.

The help says that lParam should contain the mouse co-ordinates,
does 0 make sense in your app?

Do you need to send a mouse click, could you use a different
message, perhaps a user registered message?

Signature

Jeff Gaines - Damerham Hampshire UK

Jens Meyer - 21 May 2004 14:42 GMT
Thanks Jeff for your answer,

i allready tried to submit the mouse-click.coordinates. But i had no
luck. The Game runs in a small explorer window which only needs a
mouseclick to start. The coordinates are not important.

But meanwhile i solved the problem with a small workaround.

First i put the window to foreground (SetForegroundWindow), then i move
the mousecursor over the window (eg. Cursor.Current = new
Point(100,100);) and as a last thing i call SendMessage with a
mouseclick as messagetype and also the coordinates.

This is quite an afford to let a foreign application accept a mousclick.
But now it works acceptable.

Thanks for anybodys help on this issue.

Greetz

Jens

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.