Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

USB autorun for non storage devices

Apr 5, 2005 1:25PM PDT

I'm looking for an application that will scan my USB ports for the insertion of a specific device then start an application.

I plan to use it so when I insert a USB joystick, my keyboard emulator will then run automatically.

Discussion is locked

- Collapse -
You'll have to write it.
Apr 5, 2005 9:30PM PDT

It's not a big piece of code and if you are a programmer I'd say it would take a week or less to accomplish.

Bob

- Collapse -
vbasic
Apr 5, 2005 10:41PM PDT

Was afraid of that. No I'm not a programmer (unless you count vbasic). I was really hoping that someone had a similar idea as me and already had something coded.

If I were to code it myself could it be done with vbasic? Or is it not advanced enough to control/monitor windows on that level.

- Collapse -
In VB6 it wouldn't be too hard.
Apr 5, 2005 11:08PM PDT

Here's the drill.

1. Go get REGMON (see google.com)

2. Now with REGMON look to see what registry changes there are when the device is ENUMERATED (fancy word about Windows adding the device).

3. Now in your VB6 routine, have it watch for this key to change/appear and launch your app.

Seems like a day's work or less.

Bob

- Collapse -
Finished
Apr 8, 2005 7:12AM PDT

Nah, your right didn't take me too long at all.

I was impressed just how well it did work. Check it out, SlyBadger

- Collapse -
A code passage I use a lot. Sleep...
Apr 8, 2005 8:00AM PDT

'This gives us access to a sleep function.
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


I find many programmers don't have a proper Sleep in VB and tend to see the CPU METER at 100% if they loop on DOEVENTS.

Useful?

Bob

- Collapse -
Very
Apr 8, 2005 10:32PM PDT

Personally I don't let my computer sleep, but it would be useful for others I'm distributing to.

All that needs to work is to be declared?

- Collapse -
Yes.
Apr 9, 2005 12:33AM PDT

I offered if because if you are looping in your code POLLING for the registry change, you'll peg the CPU meter and others will not like your software doing that.

This one liner lets you poll and give back time to the CPU to not peg the CPU.

Bob

- Collapse -
ok
Apr 9, 2005 2:12PM PDT

Thanks for the information!