I'm writing a screen shot app where I need to prevent the mouse over effect in all windows. For example, when hovering over a button or hyperlink they will often change color as a form of feedback. My goal is to take a screen shot where the user clicks without the additional feedback.
I can see two approaches:
Disable / ignore the system cursor and create my own. Allow it to fly around the screen without triggering any hover effects. Send a mouse_event when the user clicks using winuser.h
Use a semi-transparent topmost WPF window that allows clicks pass through to other windows. THis answer feels close, but does trigger hover over effects in other windows.
Option 1 is feasible, but I would need to also account for right clicking and scroll wheel.
Option 2 would be best if I could pass through the click event and not the mouse movement. Is this possible in WPF or should I roll my own cursor controls?
Thanks!
Related
I need to write a text recognition (from image) application. The main idea is that while my application is running, I may have the need to transform some text of an image into manageble text. So, in this case with the mouse I need to draw a square around the area that i need to capture and the software must convert the content of the extracted picture into text.
I solved the problem of image recognition. I also find a very easy way to capture from screen.
What I need to do now is be able to select with the mouse the interesting area that is over an other running opplication (for example over a webpage or over an image opened in Paint). That must be like the screencapture on windows7, you create a selection of the screen and this is saved like a picture.
By looking around, I didn't find anything and I don't knwo where to start.
Many thanks
You can achieve that using either a 'tricky' easy way or a real but difficult approach.
The tricky way
Screen Recorder applications usually use this approach:
Whenever user wants to select an area, you display a full screen border less Window with 0% opacity, then user attempts to select the screen area, and he is actually selecting your Window area, so you can receive mouse events and display/draw a rectangular shape to show the selection area to the user.
In this approach, the program needs to know when to display the Window and when to hide it. This can be done by for example defining Hotkeys for capturing:
Program registers a hot key using RegisterHotKey to Windows.
User presses and holds that hot key
Program displays the tricky Window
User selects the interested area, program receives that area using mouse events of the tricky Window
User released the hot key and program hides the Tricky window.
The real way
Using this way, you need to set a message hook in order to receive mouse and keyboard events while user is interacting with desktop not your program. This is not an easy to accomplish approach and I recommend you the first one.
When I drag a window to the Top/Left/Right of screen, the window will be magnified or max automatically.
How to avoid system max or magnify this window when user drag it to specified area?
If you want to disable Snap, please follow this guide
To turn Snap on or off
Open the Make the keyboard easier to use page by clicking the Start
button Picture of the Start button, clicking Control Panel, clicking
Ease of Access, clicking Ease of Access Center, and then clicking Make
the keyboard easier to use.
Under Explore all settings, click Make the mouse easier to use.
Under Make it easier to manage windows, do one of the following:
To turn Snap off, select the Prevent windows from being automatically
arranged when moved to the edge of the screen check box.
To turn Snap on, clear the Prevent windows from being automatically
arranged when moved to the edge of the screen check box.
Click OK.
As I mentioned in the comment, please don't try to manipulate this through (application specific) code.
Thanks for everybody...
I make a trick in SizeChanged event.
When size is changed, application will re-size to original size...
I implemented a custom window in WPF. It is possible to drag this window. So when i drag it to the top it maximizes. But than, when I drag this from the top, it should minimize - but it's not.
It is able to drag, but size is the same as maximize.
I'm looking for event which is called, when user drag window from maximize state, so i could call minimize function from code.
I can't find this event. Thanks for help.
Shouldn't you leave this kind of functionality up to Windows? Windows 7 will handle most such gestures automatically (such as maximizing when dragging it to the top, cascading when dragging it to the side, etc).
What you want to achieve, however, is not standard behavior and I have never seen a program behave like that ever.
I would ask myself this: Is this really a functionality I want? Personally I would not do this unless there are very good reasons to do so
I have a form with a Transparency-key color, where I'm doing a global mouse hook for the right click.
Until there everything is okay, but since the form is transparent, the mouse cursor is changing according to what is behind the form.
Is there any way to change the global mouse cursor?
Yup, that's how transparency works. Not just to the eye of the user, also to what the mouse sees from its left eye. Has to work that way, major user confusion if it didn't, no option to change it.
The workaround is to show a fake version of the desktop. A screen shot. Just what the ever popular Windows Snipping Tool does. Sample code is in this thread.
How to track the mouse position on the screen regardless of application.i.e. Whenever the user clicks or select something with mouse in any application, i want to display my own menu at that point itself.
Is there any way to get mouse position on the screen using c#?
To do this, you'd need to P/Invoke to user32.dll and use SetWindowsHookEx().
Have a look here:
SetWindowsHookEx (user32)
How to set a Windows hook in Visual C# .NET
That sounds like a bad idea. I'm sure you could force it with a bit of effort, but what about the other applications that may want to show their own menus when the mouse is clicked?
I have solved this issue, I used Low Level Mouse hooks and Low Level Keyboard hooks to implement the solution.
I am yet to add the Menu part of it.