A Single Script for 2 Trackballs?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
stretch65
Posts: 21
Joined: 16 Jun 2015, 23:49

A Single Script for 2 Trackballs?

10 Jun 2021, 05:49

I have 2 computers that I use at different times of the day.

On computer 1, I use a 4 button trackball in which buttons 3 & 4 are defined natively as "xbutton1" and "xbutton2".

On computer 2, I use a different 4 button trackball in which buttons 3 & 4 are defined natively as "mbutton" and "xbutton1".

There's a script which I run on each computer. But because of the differences between the 2 trackballs, I'm having to maintain 2 different versions of the same script - which I find tedious and error prone.

As a simplified example, the 2 scripts look kind of like the following:

Code: Select all

; --- Trackball 1 Script ---

#HotIf WinActive("Notepad")
	$xbutton1:: { ... }
	$xbutton2::	{ ... }
	$xbutton1 & xbutton2:: { ... }
	$xbutton2 & xbutton1:: { ... }

#HotIf WinActive("Calc")
	$xbutton1:: { ... }
	$xbutton2::	{ ... }
	$xbutton1 & xbutton2:: { ... }
	$xbutton2 & xbutton1:: { ... }


; --- Trackball 2 Script ---

#HotIf WinActive("Notepad")
	$mbutton:: { ... }
	$xbutton1::	{ ... }
	$mbutton & xbutton1:: { ... }
	$xbutton1 & mbutton:: { ... }

#HotIf WinActive("Calc")
	$mbutton:: { ... }
	$xbutton1::	{ ... }
	$mbutton & xbutton1:: { ... }
	$xbutton1 & mbutton:: { ... }
The code that the hot keys call is mostly the same for both scripts.

So, I've been wondering if there's a way of writing a single script that will run on both machines.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: ntepa, teadrinker and 15 guests