473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

ASP.NET call to mouse_event in browser

I am trying to create a flashlight effect without Flash. I created a 4000 X 2000 image with a transparent whole in the middle. This image follows the cursor around the browser. You can see a small circle of the content under the cursor, but cannot click on anything. My first attempt at mouse clicking was to catch the mouse click in JavaScript, set the display of my large image to none then perform a
Expand|Select|Wrap|Line Numbers
  1. document.elementFromPoint(x, y).click()
in JavaScript; this only works in IE as FF does not support click(). My next attempt is to catch the mouse click in JavaScript again which hides the image, then uses
Expand|Select|Wrap|Line Numbers
  1. PageMethods.MouseClick(x, y, mouseClick_Return);
to execute the following code:
Expand|Select|Wrap|Line Numbers
  1.         [System.Runtime.InteropServices.DllImport("user32.dll")]
  2.         public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
  3.  
  4.         [System.Runtime.InteropServices.DllImport("user32.dll")]
  5.         [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
  6.         public static extern bool GetCursorPos(out POINT lpPoint);
  7.  
  8.         public const int MOUSEEVENTF_LEFTDOWN = 0x02;
  9.         public const int MOUSEEVENTF_LEFTUP = 0x04;
  10.         public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
  11.         public const int MOUSEEVENTF_RIGHTUP = 0x10;
  12.         public const int MOUSEEVENTF_ABSOLUTE = 0x8000;
  13.  
  14.         [System.Web.Services.WebMethod]
  15.         public static void MouseClick(int x, int y)
  16.         {
  17.             POINT p;
  18.             if (GetCursorPos(out p))
  19.             {
  20.                 mouse_event(MOUSEEVENTF_LEFTDOWN & MOUSEEVENTF_ABSOLUTE, p.X, p.Y, 0, 0);
  21.                 mouse_event(MOUSEEVENTF_LEFTUP & MOUSEEVENTF_ABSOLUTE, p.X, p.Y, 0, 0);
  22.             }
  23.             else
  24.             {
  25.                 mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
  26.                 mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
  27.             }
  28.         }
  29.  
  30.  
.
Then I display the image again in the call back to the JavaScript.
This does not seem to work as I expected; the mouse click seems to not do anything. Any guidance would be appreciated.
Mar 11 '11 #1
0 1042

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: BLElliott | last post by:
I think this is a very basic question, so feel free to direct me to a FAQ or other resource to go and get myself educated, if that's the best answer. Can I perform web browser functions from a...
8
by: McBeth | last post by:
Hi! I'm trying to call external HTML web page requiring several POST-ed parameters from C# Web form. Parameters should be set by Web form. Is it possible ? How can I do it ? Thanks in advance ...
4
by: bowchow79 | last post by:
I have an application for which I'd like to simulate mouse clicks. What I want to do is simulate a click at a specific location in the application. I've tried PostMessage to no avail. I had a bit...
13
by: Abhishek | last post by:
Hi, how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that application only even if there is any other window in front of it. I dont...
2
by: wasishincar | last post by:
System.Diagnostics.Process.Start("IExplore.exe", URL) could popup a IE browser to the URL. But will overwrite the latest browser if it has. Is there any method/parameter/property that always...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
2
by: MartinPWalsh | last post by:
Is it possible, a how could I activate a call on a mobile phone by clicking the number in the phones/smartphone internet browser. I am not talking about using a VOIP gatway I need to activate a call...
2
by: Atila Olah | last post by:
Hello everyone. I would like to be able to emit a mouse click on my xgl/compiz desktop, like I used to do in Windows: win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0)...
2
by: anjummir | last post by:
I have one challenge here. lets say we have one web app opened with an authentication ticket(IPriciple implement) in one browser. lets call it browser A. Now from browser A client opens up another...
1
by: dtzWill | last post by:
Hey all--I'm trying to implement the server-side code for some software I'm writing for the iPhone. Basically it's a wireless touchpad... so I have a client that sends events (runs on the phone)...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.