[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB 6 Receive Data from USB Port

Posted on 2005-04-08
13
Medium Priority
?
1,800 Views
Last Modified: 2013-12-26
Hi everyone..

Can anyone help me..i'm going to make an improvise optical sensor by using the sensor of an optical mouse..
i want it to act like a counter
can anyone teach me on how to do this..if it is possible

btw im using visual basic 6

Thanks in advance..
0
Comment
Question by:pentacost
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 3

Expert Comment

by:JigglyD
ID: 13736294
Pentacost, are you looking at making some sort of motion detector?
0
 

Author Comment

by:pentacost
ID: 13736467
yes i do..actually im looking for a device that could act as a counter..
0
 
LVL 3

Expert Comment

by:JigglyD
ID: 13736767
Well, here's a strange possibility for you...

By leaving the optical mouse connected via USB, you could simply respond to a MouseMove event (which would automatically be fired whenever the optical sensor is tripped).  I would also put in some sort of minor delay timer so you didn't record the same person more than once.

Of course, this means that you would have to create an application that was complete keyboard (or touch screen) driven.

Jiggle On ! ! !
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:pentacost
ID: 13736933
hmm..may i ask for some sample codes on how to do this..

coz i this is my first time to USB port..can u give me some tips?

thank you very much i appreciate your help..
this'll help me alot in my thesis..coz im doing a prototype project of a filler machine downtime
0
 
LVL 3

Expert Comment

by:JigglyD
ID: 13737936
I have to take off now, but I will post some code later tonight.

Jiggle On ! ! !
0
 
LVL 13

Expert Comment

by:rettiseert
ID: 13739201
Will this mouse count people?, tickets? other objects?

I dont think a mouse can detect motion if is not close enough to the object.

btw, if you use a mouse following pentacost's advice, you don't need to interact with usb ports, vb can handle the device as a standard mouse
0
 

Author Comment

by:pentacost
ID: 13741237
the mouse will count canned goods..
i think retitiseert is right..it should be close enough, but i'll think of some better way later on..my only concern by now is how to take control it's events.. btw rettiseert im going to use an optical mouse and i'm going to remove it's optical sensor and make an improvised motion sensor that's why i want it to interact with the usb port..

is controlling a standard mouse in vb the same when controlling an optical mouse.. because i want it to trigger when a canned good pass through it and make a count in vb..

thanks for advices guys..
god bless
0
 

Author Comment

by:pentacost
ID: 13741929
oooops.. i think im going to have another problem..because by setting the mouse Event it will restrict the movement of the cursor..

is there any other way to do this? coz i still want to control the cursor of the mouse..
0
 
LVL 12

Expert Comment

by:fulscher
ID: 13765105
pentacost - Using an optical mouse for this purpose is an excellent idea. Cheap and reliable.

Setting the MouseMove event should not restrict the mouse movement at all. However, the event fires only in the active form or control - so basically, if you move the good over the mouse sensor, this is interpreted as a mouse movement. Therefore, the cursor moves in one direction until it's at the border of the form or screen. You could prevent this by setting your application to full screen.

Another option would be to write a filter for windows events ("hook"). Check out this article: http://www.vbaccelerator.com/home/VB/Code/Libraries/Hooks/Mouse_Gestures/article.asp - it explains how to create a filter which will trigger any movement of the mouse irrespective of the active window. You wan't need most of the code (it's for detecting gestures), but it shows the idea.

The third option would be to actually catching the mouse movements at the USB port. A mouse is generally a serial device, so mouse movements translate into a stream of data into the serial port. Unfortunately, Windows seems to know that a mouse is a mouse and not another serial device...

Jan
0
 

Author Comment

by:pentacost
ID: 13771521
fulscher:
is there any way i can catch the binary data sent by the movement of the mouse?
0
 
LVL 12

Expert Comment

by:fulscher
ID: 13771608
I'm not sure - look to me that you would have to write your own mouse driver to catch that data. In addition, you'd have to interprete the data coming from the mouse. I think it might be easier to go the hook way (at least for me, it would be easier).

Or you try to find an optical mouse which connects to the serial port. You could then catch the data coming from the serial port (after telling Windows that it's not supposed to treat that device as a mouse). This probably would be easier than trying to fetch data from the USB port (to be honest, I've no idea how to do this).

Jan
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14410083
PAQed with no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question