Macro Program [Solved]

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
dedraconis
Level 1
Level 1
Posts: 18
Joined: Sun Dec 31, 2023 10:11 am

Macro Program [Solved]

Post by dedraconis »

Coming off of using AutoHotkey on Windows, does anyone have a recommendation for a macro program that'll run well on LMDE? I don't need super complicated loops - just "[X] Key = String," "Toggle/Loop," and "Wait [X] Seconds." It's fine if it can't do more than say.. 4 instructions in a phrase.
Last edited by dedraconis on Fri Feb 16, 2024 9:40 pm, edited 1 time in total.
delphi
Level 1
Level 1
Posts: 11
Joined: Sat Sep 23, 2017 5:35 pm
Location: Lymm, Cheshire, UK
Contact:

Re: Macro Program

Post by delphi »

I used to use autokey, it uses Python to do pretty fancy stuff, below a bit a script I have used:

Code: Select all

import subprocess
import time
# move window function
def movewin(Yp):
    thisWin = window.get_active_title()
    windetails = window.get_active_geometry() # returns tuple of: x, y, width, height
    window.resize_move(thisWin, xOrigin=1600-windetails[2], yOrigin=Yp, width=-1, height=-1, matchClass=False)
    ret = windetails[3]
    return ret
    
command = 'wmctrl -l'
output = system.exec_command(command, getOutput=True)
#Yprog = 0
#
if 'Utils' in output:
    window.activate("Utils",switchDesktop=True)
else:
    subprocess.Popen(["/home/chris/Documents/LazarusProgs/StartProgs/Console/StartTheUtils"])    
    time.sleep(0.6)
Hope you find Autokey suits yor needs, Chris
motoryzen
Level 10
Level 10
Posts: 3497
Joined: Sun Dec 08, 2019 12:25 am

Re: Macro Program

Post by motoryzen »

Perhaps I'm shooting too low on the variety scale of options here..but xdotool can some wonders also with the right imagination. I absolutely love it for bashscripting.
Mint 21.2 Cinnamon 5.8.4
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor
dedraconis
Level 1
Level 1
Posts: 18
Joined: Sun Dec 31, 2023 10:11 am

Re: Macro Program

Post by dedraconis »

delphi wrote: Sat Jan 27, 2024 6:48 pm I used to use autokey, it uses Python to do pretty fancy stuff, below a bit a script I have used:

Code: Select all

import subprocess
import time
# move window function
def movewin(Yp):
    thisWin = window.get_active_title()
    windetails = window.get_active_geometry() # returns tuple of: x, y, width, height
    window.resize_move(thisWin, xOrigin=1600-windetails[2], yOrigin=Yp, width=-1, height=-1, matchClass=False)
    ret = windetails[3]
    return ret
    
command = 'wmctrl -l'
output = system.exec_command(command, getOutput=True)
#Yprog = 0
#
if 'Utils' in output:
    window.activate("Utils",switchDesktop=True)
else:
    subprocess.Popen(["/home/chris/Documents/LazarusProgs/StartProgs/Console/StartTheUtils"])    
    time.sleep(0.6)
Hope you find Autokey suits yor needs, Chris
Hey, thank you for the suggestion. That looks like what I'll want to use. I don't feel it's appropriate to ask someone to walk me through every macro I need, but would you happen to know a good tutorial about how to use this? Like the very basics of how to target the window/program you want, assign toggle key for loops, etc. I just tried doing some Google searches for it but I'm having little luck.
delphi
Level 1
Level 1
Posts: 11
Joined: Sat Sep 23, 2017 5:35 pm
Location: Lymm, Cheshire, UK
Contact:

Re: Macro Program

Post by delphi »

I can't give any more examples for autokey as like motoryzen I use xdotool most of the time and fire a script from an icon.

I notice autokey has moved from python 2 to python 3 so the syntax may have changed.

Here is a script I use to send the "media pause" to Lazamp (my own media player) or winamp, mpv, freetube etc, if none are running it sends pause or equivalent globally.

xdotool is available in "Software Manager".
Excuse the tabs got messed up when I pasted the code.

Code: Select all

#!/bin/bash

#send Pause to Lazamp if not there send specific command or generic pause

result="$(echo  |  xdotool search -name  'laz-amp')" 
if [ -n "$result" ]
    then
        echo "LazAmp Running"
		echo "pause" | netcat localhost 2199
		# if lazamp is running, don't send to winamp
        exit 0
    else
        echo "No Lazamp"
		result="$(echo  |  xdotool search -name --onlyvisible 'winamp')" 
		if [ -n "$result" ]
    	then
        	echo "Winamp is running"
        	xdotool search  -name  --onlyvisible 'winamp' key ctrl+XF86AudioPause
    	else
			result="$(echo  |  xdotool search -name  'mpv')" 
			if [ -n "$result" ]
    		then
        		echo "mpv is running"
        		xdotool search  -name --onlyvisible  'mpv' key p
    		else
				result="$(echo  |  xdotool search -name --onlyvisible 'waterfox')" 
				if [ -n "$result" ]
    			then
        			echo "Waterfox is running"
        			xdotool search  -name  --onlyvisible 'waterfox' key k
				else
					result="$(echo  |  xdotool search -name --onlyvisible 'freetube')" 
					if [ -n "$result" ]
    				then
        				echo "freetube is running"
        				# freetube pause only works with global key, k is the pause command
					xdotool  key k
    				else
        				#none of the above
						# send generic pause
						xdotool  key XF86AudioPause
					fi
				fi
			fi
		fi
	fi

echo $result
dedraconis
Level 1
Level 1
Posts: 18
Joined: Sun Dec 31, 2023 10:11 am

Re: Macro Program

Post by dedraconis »

Are there any xdotool tutorials? It seems to be the #1 recommended thing for this but I have no idea how to use it. Like.. pretend (you don't need to pretend, you can assume as fact) that I am an idiot. A chimpanzee in which you, an advanced alien species, are graciously trying to teach to use a rock as a hammer for the first time.

Edit 2/16/24: The answer I was in search of is "bash scripts." Thanks for the assist.
Post Reply

Return to “Software & Applications”