Jump to content

Swap mouse buttons


Cue
 Share

Recommended Posts

If you had done a search you would have found this

Func SwapMouseButton($mode = 1)
    DllCall("user32.dll", "int", "SwapMouseButton", "int", $mode)
EndFunc

Edit -

mode = 1 for swapping

mode = 0 for returning to normal mode

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Hi,

yes u can like BigDod shows, but why?

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

BigDod thanks for that. I actually did do a search but didnt come across that what did you use for you search terms.

Hi, th.meger I need this for a Tablet pc so that I can add a small area on the screen to point to then the next point will be a left click instead.

Link to comment
Share on other sites

Hi Cue,

still not totally clear, but ... nevertheless - go on. :lmao:

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Sorry, I didnt explain very well.

I've got a tablet pc and pointing anywhere on the screen performs a right click. To "left" click you have to hold the pen on the screen for a while which is quite annoying. so I'm writing a script with a tray icon that when right clicked on will make the next click a left click.

Hope thats understandable.

Link to comment
Share on other sites

BigDod thanks for that. I actually did do a search but didnt come across that what did you use for you search terms.

"swap mouse buttons"


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Thats what I searched for and got alot of threads I skimmed through most that sounded relavent and didt find anything. Nevermind

Did you enclose it in quotes as per my post. When I did it I only got two hits one of which was this topic. Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

I cant seem to figure out why this simple script doesnt work. It shows some very odd behavior.

clicking the system tray swaps the mouse buttons until a left click is performed. if you swap then left click on the tray the system tray menu shows. now the problem is if you click the tray after left clicking on the menu you cant swap the buttons again until you right click even if you exit the script and start it again :lmao:

any idea whats going on.

#Include <Constants.au3>
#Include <Misc.au3>
#NoTrayIcon

Opt("TrayMenuMode",3)   ; Default tray menu items (Script Paused/Exit) will not be shown.
TraySetClick(0)
$Menuclicked=0

$aboutitem      = TrayCreateItem("About")u 
TrayCreateItem("")
$exititem       = TrayCreateItem("Exit")

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
            
        Case $msg = $TRAY_EVENT_PRIMARYUP
        SwapMouseButton(1) ;swap buttons
        TraySetState (4) ;make tray blink
        
        while Not _IsPressed(01, "user32.dll") AND $Menuclicked=0 ;wait for left click
        WEnd
        
        SwapMouseButton(0) ;swap back
        TraySetState (8) ;stop tray blink
        $Menuclicked=0
        
        Case $msg= $TRAY_EVENT_SECONDARYDOWN
        $Menuclicked=1
        
        TraySetState (8) ;stop tray blink
        SwapMouseButton(0) ;swap back
        
        ;show tray menu
        TraySetClick(1)     
        MouseClick("left")
        TraySetClick(0)
        
        Case $msg = $exititem
            Exit
    EndSelect
WEnd

Func SwapMouseButton($mode = 1)
    DllCall("user32.dll", "int", "SwapMouseButton", "int", $mode)
EndFunc
Link to comment
Share on other sites

Works fine for me, once the swap is done, use the left click which is now the right click, then it swaps again

Edit: had my left and right reversed in the sentence.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Figured it out I should have used TRAY_EVENT_SECONDARYUP instead because it performed a PRIMARYUP after i let go. but its still very odd that if you exit the script and start it again it remembers if you didnt press right click

Link to comment
Share on other sites

Figured it out I should have used TRAY_EVENT_SECONDARYUP instead because it performed a PRIMARYUP after i let go. but its still very odd that if you exit the script and start it again it remembers if you didnt press right click

Using the dllcall to swap mouse buttons, doesn't just swap the mouse buttons in the script.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Works fine for me, once the swap is done, use the left click which is now the right click, then it swaps again

Hi gafrost. Iam writing this for a tablet pc so pretend you dont have a right click. i wanted to click on this tray, swaps buttons then next left click becomes a right click and swaps back to normal.

Edit: added quote to avoid confusion, gafrost types alot faster than his Avatar :lmao:

Edited by Cue
Link to comment
Share on other sites

Using the dllcall to swap mouse buttons, doesn't just swap the mouse buttons in the script.

gafrost its hard to keep up with your posts, lol

try it with only the left click. it actually swaps them back but it still requires a right click before performing it again.

Edited by Cue
Link to comment
Share on other sites

Do this to recreate the problem. use left click only. click on tray, click tray again, now click about. now try clicking the tray to swap again, It doesnt work .

Now exit the script and open again now click on tray, It still doesnt work.

Kinda odd

edit:[ Remember exit using left click only by using ctrl+Break in SciTE for example]

Edited by Cue
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...