?
Solved

Small VB program for middle mouse click.

Posted on 2003-02-19
10
Medium Priority
?
307 Views
Last Modified: 2010-05-01
Hello all,
          I'm hoping someone could help me with writing a program in VB.

All I want to do is have a program running all the time watching for a middle mouse click.

When the middle click occurs the program takes the current window with focus and maximizes that window on a secondary monitor.  If the program with focus is already on the second monitor it maximizes it in the first monitor.

Thanks for any help,
Aaron
0
Comment
Question by:Cide
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 1

Expert Comment

by:Munim
ID: 7983469
cant do it in VB.requires syswide hook
0
 

Expert Comment

by:Lemonss
ID: 7984847
hope this can help:
dim ButtonTest As Integer
private sub Form_MouseMove (Button as Integer, Shift As Integer, X as Single, Y as Single)
dim puExit as Boolean
'if click on the exit button, puExit becomes true.
Do while puExit = False
ButtonTest =Button And 7
'check whether the mid-button has been pressed. regardless whether other buttons has been pressed or not
    If ButtonTest = 4
        'Do whatever you want to do here
    Else: DoEvents
    End If
End Sub
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7985398
Munim is correct that you need a system-wide hook, but incorrect that you cannot do this with VB.  Here's some examples of system-wide hooks in VB:
http://vbaccelerator.nuwebhost.com/codelib/hook/vbalhook.htm
http://www.freevbcode.com/ShowCode.Asp?ID=1308

http://www.codeguru.com/vb_system/PK111802.html
http://www.developer.com/net/vb/article.php/1502401

Anyhow, some of these are for keyboard,  you just need to trap the mouse messages instead of the keyboard messages.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Cide
ID: 7989281
Thanks for your help so far, but how do I change the window to the other monitor though?
0
 
LVL 16

Accepted Solution

by:
twalgrave earned 2000 total points
ID: 8000203
0
 

Expert Comment

by:CleanupPing
ID: 8901424
Cide:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 8902984
Recommendation: Points to twalgrave
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 8903964
Thanks bobbit31.  I concur.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8959699
Thanks for the input.   Moderator, my recommended disposition is:

    Accept twalgrave's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0
 
LVL 2

Expert Comment

by:black_rawa
ID: 8966351
You have to use API. Then you check the MiddleButton all the time over all apps.

I must look at home, but it's very simple. I used it in a game I programmed.

; )
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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