Basically i am creating a vbnet system software. I want to create a shortcut key to lock the system with out affecting the windows explorer (just my system only). Is it possible to create one for that? Or let's say create a procedure that triggers anywhere whether the focus is on a control, on a form (whether shown as normal or modal), or on any other that has the focus on it.
I just need an idea. Thank you.
I think you could use hotkey registration to do it.
Here is one of a few existing walk throughs on accessing user32.dll to register a global hotkey
I think the key for you will be where to register the hotkey and make sure to unregister it when your application closes.
Related
I'm using VB.NET 4.7.2
I have a multi-form application and I'm coding the "Window" menu on top to show open forms so the user can easily switch (now that Win11 has forced combining applications on the taskbar).
I need each open form to be able to handle the FormOpening and Load events generated by other forms. My current solution is to handle those events locally in each form, which then triggers a custom global event that any other form can handle.
But that's a little tedious - is it possible for one form to handle another form's closing or opening without this workaround?
You could subclass a standard form to do all the scut work of registering with the shared global and hooking other forms events. You then just need to change the forms header to point at the subclasses type and off you go.
I've got a single instance (set up via .net) program that operates mostly from the system tray but also has a window.
Users often lose the program among their other system tray icons and believe the program isn't running, trying to open it again from the executable.
How can I detect, within my running program, that the executable is opened again? (So that I can maximize the window)
Thanks in advance.
Opening another copy of a single instance program will bring your form to the front by default, but when the form isn't visible, this won't have any effect.
This is what I was looking for
The MyApplication_StartupNextInstance event occurs when another instance is started. This can be used to call any additional functions you need.
In Project Properties, You can navigate to Application -> View Application Events and handle Me.StartupNextInstance from within Partial Friend Class MyApplication.
Direct all thanks to the comments.
I have an ActiveX DLL which currently reads from a serial port. Now I want it to accept input from a USB device.
The USB device functions as a standard Human Interface Device. That is to say, if I open Notepad then the device's output will appear in Notepad as if it were typed on a keyboard.
Normally, I would capture Key Up/Down events, but I think that I need a form for that and my DLL does not have a form.
How can I capture that input?
[Update] I found this http://us.generation-nt.com/answer/anyone-know-how-read-keyboard-input-within-an-activex-dll-help-7934442.html# which claims to do it, but the code there won't work as is uses the AddressOf operator, which can only be used in a .BAS file, so not in an DLL .CLS
I am not even sure if I am looking for a system wide hook or application specific.
Hmmm, http://www.xtremevbtalk.com/showthread.php?t=77216 says "You can't implement a global WH_KEYBOARD hook in VB - it requires a standard (non ActiveX dll) as it has to be loaded into the address space of all the running applications."
[Upper date] So, maybe I can a form, make it 1x1 pixel and invisible and have a function GetTheData which shows the form modally and collects and returns the data - either getting keyboard input at form level or into a (n invisible) control then closes the form returning the input.
Would that work? If anyone posts a working example I will award a bounty (I would prefer that the form not be visible on the task bar and have no close button; the user should not be aware of it, or able to close it, it should close itself when it receives enough input from the USB attached HDI).
You can use RegisterRawInputDevices to monitor HID devices' input but this requires a window to listen for WM_INPUT message which means subclassing the window.
Here is a working sample project: UsbBarcodeSanner.zip
I think you have better option,
using uesr32.dll you can do this task easily,
refer this link
you will be able to use this function
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
This dll handles anything you want for user in windows.. refer Old Post
I hope this will help..
This is an auto talker that i created, but it isn't very convenient to click on start and stop when the text is being typed at 10 milliseconds. So i wanted to create a key that when pressed starts the auto typer, and also stops it. I have a box where the user can press a key to assign to start and stop the auto typing. What code would i put for clicking on assign? I want assign to: get key from textbox5.text and use it as the shortcut key to start spamming. The key would be pressed when the Interface for the spam bot is minimized, so i can't use "&Spambot" for S to be the shortcut key.
Any help would be appreciated.
Please click on the link below to see image
http://s16.postimg.org/6xdxtjvg5/Interface.png
I successfully used some methods to read the numkey state, started my stuff when it is turned on, and stop it when it is turned off again, maybe you will like that solution.
If Control.IsKeyLocked(Keys.NumLock) Then ...
your alternative would be to 1. use an keyDown event (i think it gave more information about pressed keys than key pressed event), then store it in a local variable
And finally using an external dll to figure out if any key is pressed anywhere in windows. And if, then compare if it is the correct key, and then trigger whatever you want to trigger.
I need to take text already obtained and stored in a variable and place it in another window: IE or any other windows application.
Context:
An asynchronous application is running in IE, most likely in the background, and when an event fires in the application, certain text needs to be inserted wherever the cursor/carrot is.
I am not restricted to any particular technology so if it even needs to be an ActiveX component I am open to anything.
This is something due for a project by the end of the week so ANY suggestions/ideas are VERY welcome.
Thank you in advance.
You'll need to write an ActiveX control that calls the SendInput function.
However, this sounds like a dumb idea. What are you trying to do?