Mouse Remap for FreeCAD

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
GreggMendel
Posts: 4
Joined: 11 Aug 2022, 15:24

Mouse Remap for FreeCAD

Post by GreggMendel » 11 Aug 2022, 16:41

I'm trying to remap my mouse back key (XButton1?) to execute a simultaneous left mouse and center mouse button press for use in FreeCAD. It needs to continue the Left+Center signal while I drag in the display to rotate the image, then cease when the Back Button is released. I thought the code below might work, but if it does anything, I cannot discern what.

_______________________________________________________________________________________________________

Code: Select all

 #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
XButton1::
Send, {LButton Down}
Send, {MButton Down}

XButton1 Up::
Send, {LButton Up}
Send, {MButton Up}

return
[Mod edit: [code][/code] tags added.]
________________________________________________________________________________________________________

Is it possible to accomplish what I am trying to do, and if so, what do I need to code differently to get there? I've tried some variations from the above, but no magic so far...
Last edited by gregster on 11 Aug 2022, 16:44, edited 1 time in total.
Reason: Topic moved from 'Tutorials' to 'Ask For Help'.

User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Mouse Remap for FreeCAD

Post by mikeyww » 11 Aug 2022, 19:47

Welcome to this AutoHotkey forum!

Hotkey routines usually end in :arrow: Return. Here is an example. Using the program

Code: Select all

XButton1::
Send {LButton down}{MButton down}
SoundBeep, 1500
Return

XButton1 Up::
Send {MButton up}{LButton up}
SoundBeep, 1000
Return

GreggMendel
Posts: 4
Joined: 11 Aug 2022, 15:24

Re: Mouse Remap for FreeCAD

Post by GreggMendel » 12 Aug 2022, 11:44

I actually had a return at the end that I didn't paste in, but hadn't realized the need for one after each assignment.

Your code works (the beeps sound, and ShowOff indicates the intended button presses). Initially it seemed to register only the {LButton Down} in FreeCAD, but does function correctly after swapping the order of the Down commands:

Code: Select all

XButton1::
Send {MButton Down}{LButton Down}
SoundBeep, 1500
Return

XButton1 Up::
Send {LButton Up}{MButton Up}
SoundBeep, 1000
Return
[Mod edit: [code][/code] tags added.]

I had not noticed it before, but that is consistent with how FreeCAD treats the individual button presses (Center then left works, left then center registers only as a left ignoring the center press).

Thanks for getting me going!

User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Mouse Remap for FreeCAD

Post by mikeyww » 12 Aug 2022, 11:54

You are welcome.

If you omit Return, then the script continues to the next statement.

Post Reply

Return to “Ask for Help (v1)”