Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Small VB program for middle mouse click.

Posted on 2003-02-19
10
Medium Priority
?
329 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
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
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: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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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 Month11 days, 11 hours left to enroll

564 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