Control click through transparency c# - c#

I am making a form that is transparent. However, I would like to sometimes be able to click "through" the form. What I mean is that I need to be able to control whether clicks go through the form or not. I am using Windows 8, which I heard makes a difference in this case as well. How can I do this?
Thanks!
EDIT: Refining my question: I am making a form which is transparent and maximized. When a user clicks, the form catches the click then moves it from the previous location which was clicked, and clicks "through" the form at the new location. I've got most of it working in C# and WPF, but I cannot simulate clicks "through" the form. How would I do this?

Related

Trying to detect and gather data on click outside application

I would like to know if it is possible to, while running a WPF window application in Visual Studio, wait for the user to click anywhere on the screen (not necessarily inside the window of my application - for the purpose of my application, the click would most likely occur inside a browser page) and then gather the information about the click (like inside the window of which application the user clicked, or the selector of the html element the user clicked)? I know this question might be very confunsing but this is basically my last resort since researching on the Internet hasn't helped me much. Just to provide a better idea of what I seek, it's like what the 'Extract Structured Data' Activity does in UiPath. Oh and I'm using C# by the way.
You can try and use this external library called GlobalMouseHook.
This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
Here is what you can do with this library:
Mouse coordinates
Mouse buttons clicked
Mouse drag actions
Mouse wheel scrolls
Key presses and releases
Special key states
Hope this helps.

C# - Using a NotifyIcon from an User Control

This is something that surprisingly wasn't able to find a solution online.
I have in my main form a couple of user control, that after doing a certain action, I want to show a notification icon.
The examples shown about doing from a different form don´t apply to User Controls, as you can't directly reference the form that is using it.
In the case the question is a bit confusing:
Application
- Main Form
--NotifyIcon
--UserControl
---Button that when pressed, show the NotifyIcon
--UserControl
---Button that when pressed, show the NotifyIcon
I´m using VS2010 by the way.

Mouse down in Silverlight

I'm working on a project in Silverlight. This is the problem:
When mouse enters in my control, I want to check whether the mouse button is down already or not. There is no way to see when it's been pressed because it might have pressed outside of the browser.
This is a default behavior, thats why mousebuttonup event is used for final actions of your process such as clicking on button does not process its assignment if you release your button outside of the button.
However, you can find a workaround using drag drop features of Silverlight according to your scenario.

Sending command to showDialogue Form from inactive form

I want to send keys to a show dialogue form from another inactive form.See the picture
Form a is showing dialogue.Behind is another form which has a customized keyboard and numpad.
I simply send keys against these button clicks.
How is it possible that I can send keys from keyboard to show dialogue form.
What you're asking is essentially impossible. Once you understand how modal dialogs work (forms that are shown using the ShowDialog method are modal), you will understand why. A modal dialog is used when you want to force the user to interact only with that dialog. It prevents them from interacting with any other windows in your application by disabling those windows. They become impervious to mouse clicks, don't receive keyboard input, and can't receive the focus. Windows beeps at you and flashes the title bar of the modal dialog when you try, it's non-subtle way of shaking its head and saying "no, no, no".
So what's going on here is that when you show your "Deposits" form as a modal dialog using the ShowDialog method, all of the other windows in your application are disabled. In your particular case, that means the window that contains your on-screen keyboard is disabled, too, and can't receive mouse click events. That's why nothing is happening when you try to click on its "keys" (buttons).
The easiest workaround (as I suggested in a comment) is to show your "Deposits" form as a non-modal dialog using the Show method instead. Unlike a modal dialog, this will not disable other windows in your application, allowing the user to interact with all of them at once. Clicking on another window will set focus to that window and allow it to process input events. But you say this isn't workable for you, because you want the "Deposits" form to disable every control on your main window, but not your on-screen keyboard.
Of course, I lied at the beginning when I said it was "impossible". What I meant is that is that it's very tricky, and will require you to work around the standard Windows interactivity model. A couple of ideas
on how you might go about doing that spring to mind:
You could use the On-Screen Keyboard utility that is included with all recent versions of Windows. Microsoft already provides a program for this purpose. You don't have to build and maintain your own, it already includes all the necessary logic to prevent it from stealing the focus when the user clicks on one of its "keys", and since it isn't part of your program, it won't be disabled when you show forms as modal using the ShowDialog method. To check it out, go to Start -> Run and type osk.
For example, in Windows 7 it looks something like this:
If you insist on using your own, custom-designed on-screen keyboard, you will have to show it as a child window of your modal dialog. That is, your application starts with its main form, per usual. Then, when you show the "Deposits" form as a modal dialog using the ShowDialog method, the main form gets disabled. From the "Deposits" form, you can then show the on-screen keyboard form using the non-modal Show method. The main form is still disabled, because it's showing a modal dialog (the "Deposits" form). But the "Deposits" form is not disabled, because it's showing a non-modal dialog (your on-screen keyboard).

C# Autohide form

I've a winforms app that "docks" to the taskbar
I'd like to autohide the form and make it appear only when the mouse goes near/over the form
any suggestions ?
Install a global hook onto the mouse-move event and check to see if it is within the form boundaries. Should work even with the form hidden. If not just store the location as a rectangle and check against that.
Code for a simple and handy global hook implementation can be found at:
http://www.codeproject.com/KB/cs/globalhook.aspx
I've used this method to create "hotspot" functionality to a user desktop.
I'm not sure it is exactly answering your question, but there is a sample of this on Codeplex...
http://remoteaccessmonitor.codeplex.com/
Browse the source code and check out the MinimizeToTray.cs file - it has examples of pop up messages when hiding and I think its default behaviour is to re-appear on click (although I imagine this could be changed).
You could.
Poll mouse coords until it's within a certain radius of your app.
Position an invisible, always-on-top form above the docked app and have it fire a MouseEnter event.
That's all I can think of really. Either.

Categories