Skip to content

Instantly share code, notes, and snippets.

@sl5net
Created November 12, 2022 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sl5net/c853e93160a5c1958d355ead6f3fdc73 to your computer and use it in GitHub Desktop.
Save sl5net/c853e93160a5c1958d355ead6f3fdc73 to your computer and use it in GitHub Desktop.
# its for 0ad helpers only 22-1112_2304-06
# i use it as autoKey-script script
ac = window.get_active_class()
if "Pidgin.Pidgin" == ac:
c = clipboard.get_clipboard()
# c = "aa bb cc" # test string
keyboard.send_keys("!mute 1 day -r profanity<home><ctrl>+<right> ") # paste and move to playerName Position
keyboard.send_keys(c.split(" ", 1)[0]) # paste only the first word
@sl5net
Copy link
Author

sl5net commented Nov 12, 2022

update

# hotkey in arena26 for mute a player
# tested in ubuntu. its a autoKey-Script (python)
# https://gitlab.com/sl5net/0ad_mute4profanity/-/blob/main/0ad_mute4profanity.py
ac = window.get_active_class()
if "Pidgin.Pidgin" != ac:
    exit(1)

c = clipboard.get_selection()

if False: # testing if get_selection works
    from plyer import notification
    notification.notify(
        title = c,
        message = c,
        timeout= 2,
        toast=False)

window.activate("helpers")

ac = window.get_active_class()
if "Pidgin.Pidgin" != ac:
    exit(1)

# c = clipboard.get_clipboard()
# c = "aa bb cc" # test string
keyboard.send_keys("!mute 1 day -r profanity<home><ctrl>+<right> ") # paste and move to playerName Position

import re
cFistRE = re.search("[\w_]+", c)
cFist = cFistRE.group(0) if cFistRE else exit(1) # looks a bit ugly. that could be better.
# if cFist == "":
#     exit(1)
keyboard.send_keys(cFist) # paste only the first 
# keyboard.send_keys(c.split(" ", 1)[0]) # paste only the first word # works but not good pattern

keyboard.send_keys("<end>" + "<ctrl>+<left>" * 3) # replace day
keyboard.send_keys("<delete>" * 3) # number

choices = [
"minutes",
"day",
"mins",
""
]
retCode, choice = dialog.list_menu(choices, title="min / day", message="", default=None,  geometry="900x700" )
if retCode == 0:
    keyboard.send_keys("" + choice)
    #window.activate("helpers")
    #time.sleep(.4)
    #clipboard.fill_clipboard(choice)


keyboard.send_keys("<ctrl>+<left>" * 2) # replace number
keyboard.send_keys("<delete>") # delete

if False: # works but is not needet probably
    retCode = keyboard.wait_for_keypress('d',modifiers=['<enter>'],timeOut=5)
    window.activate("arena26")

exit(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment