disable mouse click for a while, of filter mouse clicks - vb.net

Im using Visual Basic 2008 Express
Is there a way to disable mouse click for a while in Visual Basic 2008, I mean if mouse was clicked more than 1 time in very short time to click only once? -- I need it because my mouse became like crazy one.. when I click once it may clicks twice or more.., This is very very annoying... so until I buy another one, I'd like to filter click, to allow only one click and to block another clicks that were made in last second.
P.S : sorry about that question, but it is really annoying...
Thanks :)

There's an article on processing global mouse events on The Code Project: Processing Global Mouse and Keyboard Hooks in C#. It looks like the article lead to a project called Global Mouse and Keyboard Hooks .NET Libary in C#. You should be able to include the library in your VB.NET project and attach to events from there. The article also references some other information on MSDN that you should read before embarking on this project.
This is something that would be much easier to do from an unmanaged language like C or C++ though.
Although these samples are in C#, they should be easy enough to translate into VB.NET.

Related

Changing application layout via buttons in VB .NET

Currently I would like to program an application gathering forms that are callable with buttons on the side. For this, I am using the latest build of Visual Studio Community. One way I thought of would be to literally put all the form elements (textboxes, lists, etc.) in the application window and only enable them whenever the according button is clicked on. However, if this is the way to do it, I find it quite messy and unpractical, and I'm pretty sure there's another way around.
After some research, I have learned about the MDI layouts, but they don't suit my taste. I would like to keep everything in one single frame.
Could you give me a hand?

Tab Order in Visual Studio hates me

Tab Order in Visual Studio does not work for me for some reason.
I am making a VB.NET plugin for a cad program called Rhinocreos 5.
I have everything set perfect, and I don't know what the cause of it is.
I am using .Show() instead of .ShowDialog(), because I need that thread open and I don't feel like doing any thread management (not paid enough lol)
Does anyone have any pointers for this? Has anyone else ran into a tab problem with Rhino5 and .NET?
EDIT**
Seems I have to use a MODELESS Form for a rhino plugin.... So I wont have any tab keys or arrow keys unless I do a hook. But since I need to make the plugin future proof (in case I am no longer working here), I won't be doing that either. But thanks for the answers, comments, and awesome downvotes.
Very difficult to guess what's going on from the information you have provided, but I'd check the following things in the following order:
The disobedient form is open and has focus.
The form has controls in it.
At least some of the controls are enabled, focusable have their TabStop set to true.
There is no low-level keyboard handling in action (PreviewKeyDown, hooks etc).
Finally I'd call ShowDialog() instead of Show(), passing main form as parameter (to make disobedient form a child of main form) and see if that makes a difference.
It was a modeless form inside of Rhino3D as a plugin.
Rhino3D uses all plugins in the main thread. So tab is not an option.
The workaround was to tag all controls with a tag work (I used "tabMe")
Then I store all the controls in a List myTabbyControls.
Each time I press tab, I would cycle through the list.
But thanks for the down votes. It's the running joke of SO.

Custom Windows Form menu in vb.net

I want to make a Custom Windows Forms menu. Now, when I say "menu", I mean where the "Exit", "Maximize" and the "Minimize" icons are. I have seen in Microsoft Office software that Microsoft have done a custom WinForms Menu, and in many other software. I have done research for months, and searched so much and have not found anything! I have, found some companies which are currently selling Component Packages with Visual Basic, C# and Visual C++ components, however I do not have the money to buy one of these packages, therefore I need help making a custom Windows Form menu.
I would like to make a Custom Windows Form Menu as a "Ribbon" type. So, It will have a "Ribbon Form Menu". However, I do not wish to use any products or packages to do this for me, seen as I don't have money for them.
I have tried a number of ways for creating a Custom Form Menu:
Used a ToolStrip docked to the top of the form, and set the property of "Left to right" to True, and used buttons or labels for the "Exit", "Maximize" and "Minimize" buttons, although, this isn't really ideal, and I don't really want that anymore.
Used buttons at the top of the Form and docked a panel behind it to made it look like a custom form, but again, this isn't really ideal either.
Anyway, please can someone help me make a custom Windows Forms Menu? It would be nice if you could help me make it in the "Ribbon Style" too!
Please note this post is aimed at the Visual Basic Programming language.. I am using Visual Basic! :D
Thanks.
You have a few options, Firstly you can extend the ClientArea into the NonClientArea
and you would end up with something like: http://www.codeproject.com/Articles/44235/Painting-Vista-s-Aero-NonClientArea-in-VB-NET
After doing some digging i found a .net wrapper for the windows 7 ribbon control, I haven't tried using it yet but you might be able to make it work:
http://windowsribbon.codeplex.com/
Alternatively you can create it all from scratch, setting the FormBorderStyle to None and handling the moving/re-sizing etc by your own code.
As well as painting the Ribbon-like controls yourself.
The latter is a lot more work but is the most customizable, I hope this is helpful and gets you on the right track!

How to simulate mouse clicks?

I was wondering how to create a sort of auto clicker using VB.NET.
I would basicly have the click coordinates pre-defined and the clicks, which would have to be separated by delays I guess since I want more than one to happen periodically, would happen outside of the application window (I read this envolves extra system hooks?).
The only code I have been able to find is related to clicks on the application window, which is not what I am looking for.
In short: I want to click a button on the app window, which would initiate a number of clicks on certain pre-defined screen coordinates.
Thanks in advance :)
See this discussion on social.msdn: Simulate a mouse click in a program.
Uses winapi: SetCursorPos, GetCursorPos and mouse_event.
I believe you need to P/Invoke into Windows to accomplish this.
Have a look at the SendInput function.
If you are using automate the program,that program have some tabindex in order to relevant control.then you can use;
SendKeys.Send("{TAB}");
SendKeys.Send("{ENTER}");
it is more accurate on desktop application

Supress pop-up with VB 2008 Express Edition

The radio recently broke in our bedroom and as a result my missus now listen to various radio stations through her laptop. She moans that visiting various pages and clicking the 'listen' link is a bit of a pain. (Note to self: Must buy new radio!)
In the meantime, I have made a 'radio player' in VB 2008 Express, which is nothing more than 6 buttons down the left hand side of the 'player' I have created and a Web Browser Control on the right hand side.
Clicking each button links to the relevant player of the station she wants to listen to. (Being a newbie to VB and programming, I'm quite proud with what I've achieved so far!!)
Anyway, one station I do link to gives an "Are you sure you want to navigate away from this page" prompt: This one:
http://www.mygoldmusic.co.uk/
Well, thats the homepage of the site anyway, the actual player is here:
(Oops, seems I can only post one link! The actual player opens on-click of the 'listen' button then, sorry to be a pain!)
My question is: Is there a way to suppress this message in VB, or even auto-answer OK somehow?
The other sites I have linked to do not display this message, they just navigate away quite happily. Clicking OK on the prompt is no real hardship either, I hear you say, but in the interests of usability, I would just like it to navigate away from the site/player without prompting.
Remember, I'm using Microsoft Visual Basic 2008 Express Edition. (I say that, because I've come across loads of sites that tell you how to do it with JavaScript, just not VB!)
I've got to the point of thinking it can't be done, but here's hoping!
Any help/advice would be greatly appreciated. And, sorry for the lengthy question. Hope it gives you enough info on what I'm trying to achieve.
Thanks in advance again.
J.
The only way I can think of is to actually modify the DOM of the page in the WebBrowser control. That popup is loading when the "window.onunload" event fires. You should be able to override this behaviour by modifying the DOM.
The HTML document DOM (Document Object Model, essentially an object graph of the page structure) is stored in the WebBrowser.HTMLDocument property. Unfortunately, that specific property isn't available to the .NET version. It IS available to COM however, so through some very ugly and messy code you might be able to suppress the event.
The following code should be able to access the COM property containing the HTML DOM. The type returned is IHTMLDocument2, although you'll note that the class itself will return an object. You might need to add a reference to mshtml.dll to get the IHTMLDocument2 interface access the properties of this in a reasonable way.
Dim domDocument As IHTMLDocument2 = webBrowser.HtmlDocument.DomDocument
You can then access the OnUnload event (which sits on the "window" element, one above the document). Unfortunately, the plot thickens a bit here (I did say it was going to be ugly) because you need to pass a IDispatch object to the onunload event. I've never done this specifically but I found a write-up at the following link that provides some samples and should point you in the right direction: http://blogs.msdn.com/cgarcia/archive/2009/08/28/handling-dom-events-in-a-c-activex.aspx
You should be able to follow a similar approach but simply do nothing in the handler method, which should suppress the javascript alert you are getting.
Get the handle to the dialog and destroy it. Use FindWindow and send a WM_CLOSE message to it.