Disable click on a 3rd party application - c#

I'm writing an application that needs to record a click location on the screen, over the top of another window using the mouse. Is there anyway to disable the mouse click so that it doesn't affect the window that is being clicked over?
e.g. I want to set a point over the top of my browser, but I don't want to click anything within my browswer whilst setting it.

You have a couple options:
Write a plugin/extension for the browser you're talking about. Maybe the browser's interface allows you to record such information
Use windows hooks. Using SetWindowsHookEx and WH_MOUSE_LL, you can get all mouse activity on the computer fairly simply. You will just need to check if the mouse activity is happening in the browser, using WindowFromPoint.

Related

Create a WPF Window that captures AND passes through Mouse Events

I'm working on a screen capture utility that captures active windows. I'm using transparent overlays to capture the full screen and then overlay the active windows based on mouse move events passed through to the underlying desktop/windows.
Both of the overlay windows currently use the WS_EX_TRANSPARENT style to allow mouse events to pass through to the underlying windows so I can detect where the mouse cursor is located. I grab the window handle and rect size to outline the window and then use Global Mouse and Keyboard Hooks to accept or reject a capture.
It's pretty ugly and spread out code (which is why I'm not posting here for now) but it all works very well and I can highlight the windows in mousemove and capture clicks with the global mouse and key handlers.
It all works except for this problem:
The Global Windows Hooks do not fire over an Admin Window so when I want to capture a Powershell, Command or Visual Studio (in Admin mode) Window no hook events are forwarded.
Apparently there's no way to work around this security issues using Windows hooks (or GetAsyncKeystate() for that matter).
I've tried a couple of different approaches to work around this issue:
Instead of using Hooks I tried using the highlight window to capture mouse/key events
This sort of works, but it's clumsy - fails if no window is selected at all (no way to get out) and doesn't allow for selecting contained windows once the parent is selected (ie. no drill down)
I also tried Win32 GetAsyncKeystate() which captures the last mouse or keyboard input and that would work, but it too fails to send mouse or key interactions from Admin windows.
So I have two choices imperfect solutions at the moment: using Hooks or GetAsyncKeyState to get the proper Window browsing selection behavior for all but admin windows, or I can capture all windows but lose the ability to drill into child windows after a parent window is selected.
I'm at the end of my rope and the real question is this:
Is there some way to create a semi-transparent or transparent window that can intercept mouseclicks and pass them on to the window area below?

C#/WPF image overlay on browsers

I am working on a wpf project and want to open browser (IE,Chrome,Firefox,Microsoft edge) on button click. After the browser opens I need to detect it's settings button on right corner and display an arrow image or a tooltip pointing to it.
I know how to open the browser using process.start but how to detect the settings area?
Get the browser's handle (HWND) after you open it (as shown in this answer), and read this answer on how to draw the arrow.
What you're trying to do is not easy, and has many points of possible failure, so I would avoid it, if some alternative was present.

Win32 API Call to specific X Y Coordinate of Window Handle

Well, the project has moved along rather nicely and we have a pretty darn good product, but a wrench has been thrown into the gear works.
We have a C# 2012 application that interacts with another application (written in VB 6 of all things) and we can do a good bit with it so far, but we have a problem.
We need to select a button on a toolbar at the top of this particular application's window, but the button is not available through an API search. We have the main window's handle and can see all of its children, but I think the Toolbar is a User type control that we can't access through the API Calls. This application is very poorly designed and we had to do a LOT of work just to discover TWO User ID text boxes on the logon screen.
Anyway, my question is this: How would I set up a call to the main window and click a certain X, Y coordinate of that window's viewable area? I am using SendMessage to send mouse clicks to press a button control already, but if I can't get access to that button control, the idea was to send mouse clicks to a specific coordinate of the window.
Any ideas folks? Thanks!
It looks like the solution will be to get the Window's rectangle and add the offset in order to use the mouse event API call.
Thank you to #Idle_Mind for the suggestion. It is at least working on our test environment. It will be next week before we can test the solution out in our client's environment.

Create a dock like application using C# and wpf

I need to create a application which is similar to those we will get when we buy a laptop. It will be visible only when the mouse pointer reaches the top of the window. So how can I able to do this using C# 4.0 ?
http://www.notebookcheck.net/uploads/pics/win2_12.jpg
this link u can see the application. I need to create such type
Any idea pls share. Thanks
I suppose there are several different ways to achieve this effect:
You can place part of the window of your application above the visible screen, so only a part of it is visible (let's say you can see only it's bottom). Then you need to handle events when mouse enters (MouseEnter) and leaves (MouseLeave) the form to move the form up and down.
You can use a background thread to call GetCursorPos method at a set interval (i.e. each 500ms) second to check where currently the mouse is. See this link for more information about it and a sample code: http://www.pinvoke.net/default.aspx/user32.getcursorpos.
(If you need only to check the mouse position, you can use a timer to simplify you application.)
When you hit what's possible with C#, you can always start invoking native code - such as the windows API. Since you don't ask a specific question, I'll leave you with:
Position your app where you want it to appear and hide it.
Capture mouse position with windows api (see this SO answer)
When mouse is at screen corner / top, etc; make your app visible.
Now make sure all this works with dual screen setup, and you are done.

send click to topmost window in compact framework using c#

I have an application which is in normal mode, now from that application i want to send click message to another window (say internet explorer). I want to click where mouse cursor is pointing right now with respect to screen and that click should be handled by internet explorer.
You can use the Win32 API call mouse_event -- I do not know if there is a .NET equivalent, but it can be used to do just what you want, i.e. fake a mouse click at the current location. To do this call it with the LEFTDOWN and LEFTUP flags.
Look it up on pinvoke.net for how to call from C# and VB.NET.

Categories

Resources