Can the GUI support checkboxes?

109 views
Skip to first unread message

JC

unread,
Jul 23, 2021, 7:18:48 PM7/23/21
to autokey-users
When first starting out with AutoKey, one of the sample scripts is a "List Menu."

This thing is really cool but it only uses radio buttons. Can these little AutoKey GUIs support multiple checkbox choices and, say, user input in a text field?

If anyone would be willing & able to link to an example script that has these things going in it, that'd be awesome.

Little Girl

unread,
Jul 23, 2021, 8:46:29 PM7/23/21
to autokey-users
Hey there,

Here are some checkboxes:

```
# This script opens a checklist dialog from which you can make one or more choices.
# It also opens an info dialog displaying an error or the checklist item(s) you chose.
# It also opens with two choices made for you by default.
# There's an option to enable a line of code below that prints the result at the cursor.
# The exit code value is 0 for success or an integer for an error.

optionShapes = ["square", "triangle", "rectangle"]

retCode, choices = dialog.list_menu_multi(options=optionShapes,
    title="Choose all shapes that have four sides",
    message="Shapes",
    defaults="square,rectangle",
    height="250")

#If the exit code of the dialog is not zero (0 is for success or an integer is for an error):
if retCode != 0:

    #Display the exit code of the command:
    myMessage = "The exit code of the dialog was: " + str(retCode)
    dialog.info_dialog(title="Error", message=myMessage, width="200")

else:
    #This displays an info dialog displaying what you chose:
    for item in choices:
        #Display an info dialog listing your choice(s):
        myMessage = "You chose: " + item + "\n"
        dialog.info_dialog(title="Result", message=myMessage)
        #Uncomment the following line to paste the contents of the dialog at the cursor:
        #keyboard.send_keys(myMessage)
```

And here is text input:

```
#This script:
#    Displays an input dialog that returns a tuple that contains the following:
#        An integer value that shows the exit value from the script (0 for success, an integer for error).
#        A string value that contains the user's input text.
#    Displays an information dialog to show one of the following:
#        The error code, if any, from the input dialog.
#        The text that was entered into the input dialog.

retCode, userInput = dialog.input_dialog(title='Input required',
    message='Enter a string',
    default='example string')

#if retCode == 1:
if retCode:
    myMessage = 'Dialog exit code was: ' + str(retCode)
    dialog.info_dialog(title='You cancelled the dialog',
    message=myMessage, width='200')
else:
    dialog.info_dialog(title='The string you entered was: ', message=userInput)
```

jos...@main.nc.us

unread,
Jul 24, 2021, 6:29:40 AM7/24/21
to autoke...@googlegroups.com
I'm not sure how kdialog and Zenity work (depending on which AutoKey front
end you're using), but yad returns distinct error codes for nothing
selected, user pressed Cancel, user pressed ESC, and dialog timed out.
Some scripts may be able to use these codes to their advantage. The
possible values should be in the documentation of their respective
standalone packages.

BTW, AutoKey does not fully expose the capabilities of these dialog
managers. If you need something further or just want to use another dialog
manager such as yad, you can call out to it by running it using
subprocess(). The return status can be retrieved and the results placed on
stdout can also be captured and used by your script.

It would also be possible to roll your own dialog by directly using GTK or
Qt.

Joe
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/8aed76fc-0e1f-404c-ba3b-e8d10ccccd90n%40googlegroups.com.
>


jos...@main.nc.us

unread,
Jul 24, 2021, 6:33:10 AM7/24/21
to autoke...@googlegroups.com
I'm not sure how kdialog and Zenity work (depending on which AutoKey front
end you're using), but yad returns distinct error codes for nothing
selected, user pressed Cancel, user pressed ESC, and dialog timed out.
Some scripts may be able to use these codes to their advantage. The
possible values should be in the documentation of their respective
standalone packages.

BTW, AutoKey does not fully expose the capabilities of these dialog
managers. If you need something further or just want to use another dialog
manager such as yad, you can call out to it by running it using
subprocess(). The return status can be retrieved and the results placed on
stdout can also be captured and used by your script.

It would also be possible to roll your own dialog by directly using GTK or
Qt.

Joe

Little Girl

unread,
Jul 24, 2021, 4:03:44 PM7/24/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:

>I'm not sure how kdialog and Zenity work (depending on which AutoKey
>front end you're using), but yad returns distinct error codes for
>nothing selected, user pressed Cancel, user pressed ESC, and dialog
>timed out. Some scripts may be able to use these codes to their
>advantage. The possible values should be in the documentation of
>their respective standalone packages.

Yep. Both KDialog and Zenity offer those and the codes vary from one
type of dialog to another, so documentation is crucial or you'd be in
for a lot of experimentation each time.

>BTW, AutoKey does not fully expose the capabilities of these dialog
>managers. If you need something further or just want to use another
>dialog manager such as yad, you can call out to it by running it
>using subprocess(). The return status can be retrieved and the
>results placed on stdout can also be captured and used by your
>script.

Yes, that's very cool. It's nice of AutoKey to have some of them
built in, though, even if they are hobbled in some ways.

>It would also be possible to roll your own dialog by directly using
>GTK or Qt.

I haven't gone that far with AutoKey yet, but it's on the plate for
the future.

--
Little Girl

There is no spoon.

JC

unread,
Jul 25, 2021, 1:12:36 AM7/25/21
to autokey-users
Thanks for the examples, Little Girl. I'm starting to, uh, see how much AutoHotkey handholds users through its built-in GUI.

Question 1

I'm wanting to create an AutoKey GUI that spits out my address in a modular way (to send to people/when websites lack autofill or whatever; I use it surprisingly more often than one might expect):

123 XYZ Road
City, ST 12345-6789

The GUI would send, based on your radio-button and checkbox choices:
  1. only the first line
  2. the text above, exactly as is
  3. same as above but all on one line (", " in place of the line break)
  4. the text above, as is but without "-6789"
  5. same as above but all on one line (", " in place of the line break)
This is relatively lightning-quick to build in AutoHotkey, so I'm starting to get a bit simultaneously intimidated & disappointed by AutoKey...

Question 2

Another question I have is: is it possible to have AutoKey's GUI display with the first radio button (in, say, a GUI with only radio buttons) already selected?

Question 3

In your three-shapes example popup, the title of the GUI is: "Choose all shapes that have four sides." However, the GUI that actually appeared was too horizontally small and didn't display the title in its full length. Is it possible to customize the GUI so that it always wraps its starting horizontal dimension to whatever the length of the title is?

JC

unread,
Jul 25, 2021, 1:26:15 AM7/25/21
to autokey-users
Asked too soon (re: Question 1); I am now aware of GtkDialog lol.

I suppose the easiest address-sender here would solely consist of radio buttons, since there may be some logic conflicts (can't select any checkboxes like "ZIP+4" if you opt only to send the first line of the address, for example), whose error codes I probably can't be bothered to put in, seeing how this is true programming instead of AHK's pseudo-code.

Aaaaand I"m reminded of why I could never get into programming, despite repeatedly trying, lol.

jos...@main.nc.us

unread,
Jul 25, 2021, 1:30:05 AM7/25/21
to autoke...@googlegroups.com
Hey, I was just outlining where the lunatic fringe was, not suggesting
anyone actually try it! :)

Unless you want to turn pro UI developer, there's probably no reason for
such extreme measures.

It is sufficiently niche and complex, so it probably pays well.

Joe

>
> --
> Little Girl
>
> There is no spoon.
>
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/60fc721e.1c69fb81.db54d.2715%40mx.google.com.
>


jos...@main.nc.us

unread,
Jul 25, 2021, 5:51:07 AM7/25/21
to autoke...@googlegroups.com
This looks like a nice example application for our wiki once it works.

> Thanks for the examples, Little Girl. I'm starting to, uh, see how much
> AutoHotkey handholds users through its built-in GUI
> <https://www.autohotkey.com/docs/commands/Gui.htm>.
>
> Question 1
>
> I'm wanting to create an AutoKey GUI that spits out my address in a
> modular
> way (to send to people/when websites lack autofill or whatever; I use it
> surprisingly more often than one might expect):
>
> 123 XYZ Road
> City, ST 12345-6789
>
> The GUI would send, based on your radio-button and checkbox choices:
>
> 1. only the first line
> 2. the text above, exactly as is
> 3. same as above but all on one line (", " in place of the line break)
> 4. the text above, as is but without "-6789"
> 5. same as above but all on one line (", " in place of the line break)
>
> This is relatively lightning-quick to build in AutoHotkey, so I'm starting
> to get a bit simultaneously intimidated & disappointed by AutoKey...

This is a design trade-off. From what I have heard, AHK is a very nice
package, but it only allows you to do what it knows how to do.

AutoKey scripts are written in full native Python which can do almost
anything, limited only by your imagination and coding skills. There are
only a few low level things you can't do because they interfere with
AutoKey's operations. We run into those very rarely.

Since not everyone is a flash Python programmer (I'm a beginner), we
provide as much support as possible here and on Gitter.
>
> Question 2
>
> Another question I have is: is it possible to have AutoKey's GUI display
> with the first radio button (in, say, a GUI with only radio buttons)
> already selected?
>
> Question 3
>
> In your three-shapes example popup, the title of the GUI is: "Choose all
> shapes that have four sides." However, the GUI that actually appeared was
> too horizontally small and didn't display the title in its full length. Is
> it possible to customize the GUI so that it always wraps its starting
> horizontal dimension to whatever the length of the title is?

I'm not sure what the limitations of our dialog box interfaces are because
I only use them for very simple cases.

However, it is relatively easy to directly call the dialog manager of your
choice (or almost any other external program or script) using the
subprocess() module. With the proper calling sequence, you can retrieve
the exit status of the program and the output that it writes to stdout
(usually the terminal).

When you run dialogs this way, you have full access to all of the dialog
manager's options and settings, several of which will directly address the
issues you raise above.

I'm a big yad fan. It's a fork of Zenity which is what autokey-gtk uses
for dialogs, so the settings mentioned are for yad, but will probably also
work in Zenity. Kdialog, which is used by autokey-qt has similar settings
to yad/Zenity, but the calling sequences may vary a bit. Littlegirl is a
heavy Kdialog user, so she can address any specific differences as
necessary.

In yad, selection lists are tuples with a label, a value/expression, and a
preselected flag. If the preselected flag is "true" then the first such
option will be preselected as the default choice. (If multiple selections
are enabled, more than one choice can be preselected.)

The problem you describe would most easily be solved using one simple
single choice radio button selection list. If I were coding it, I would
have it just emit a choice number and pass that through one or more case
statements to select and assemble the desired address components in a
string variable. At the end, I would put the results into the clipboard
and paste them into the application window.

The default dialog box dimensions are frequently suboptimal. In
yad/Zenity, this can be adjusted using --height=# and --width=#, where #
is the desired number of pixels for that dimension. Start with something
like 300 each and then adjust as necessary if you don't want to calculate
the correct value in advance. After you've used it enough, you can usually
pick relatively good values to start with. Starting a bit too large, you
can halve or double the initial value until you get close and the go up or
down half that amount and repeat as necessary in sort of a binary search
for the optimal value.

If you want to, you can use the Python len() function to measure the
length of your title in characters. Then you have to convert that into
pixels (I'm not sure how to do that because it's font and font size
dependent.) and then add in a healthy margin for the borders of the dialog
box and for the fact that the title field is smaller than the whole width
of the box.

yad also has a word wrap option if you need it along with lots of other
options.
--wrap-width=NUMBER
Set the width of column before wrapping to NUMBER.

Another advantage of using an external dialog manager is that you can run
it standalone from the CLI (terminal). This allows you to run it many
times very quickly until you get it just right.

If you end up with a long command line with lots of text or options, you
can split it into multiple lines by making the last character on every
line except the last one a backslash. Extra white space between arguments
has no effect, so you can use it to make the command much more readable.

I create a bash script with the yad command in it and just run that
script. This way, I can repeatedly edit, save, and run. You can pass
arguments to the script such as the title as long as you are careful about
quoting/escaping things that bash might attempt to expand.

Once it works, you can call the script from within your AutoKey Python
script and provide the arguments from Python.

Joe

Good questions. You got me to write a "book" today to answer them. Maybe
some of it will end up in the wiki, so feedback is appreciated.
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/b75d6fd9-8e4c-4c9f-9574-bb045f864974n%40googlegroups.com.
>


jos...@main.nc.us

unread,
Jul 25, 2021, 6:18:59 AM7/25/21
to autoke...@googlegroups.com
Yes. See my other responses. The trick is to do one thing at a time. Just
select the option number and then put it through a bunch of separate tests
to assemble the address. If then else statements will work, but one or
more case statements might be cleaner.

See how far you can get with a rough draft that at least spells out all
the cases and I'll help you to get it to work.

If you're not comfortable enough to write it in Python, you can write it
in pseudocode (an informal cross between plain English and a structured
programming language).

There's no rocket science involved in this one.

This what a tiny piece of a typical business application looks like - a
bunch of simple decisions that interact with each other until it's not
simple any more. :)

GtkDialog is yet another standalone dialog manager. They're all basically
the same for simple things and just vary a bit on the actual syntax they
use. The only caveat is that I haven't used it, so I'll be less help in
debugging it.

Joe

> Asked too soon (re: Question 1); I am now aware of GtkDialog
> <https://autokey.github.io/lib.scripting.GtkDialog-class.html> lol.
>
> I suppose the easiest address-sender here would solely consist of radio
> buttons, since there may be some logic conflicts (can't select any
> checkboxes like "ZIP+4" if you opt only to send the first line of the
> address, for example), whose error codes I probably can't be bothered to
> put in, seeing how this is true programming instead of AHK's pseudo-code.
>
> Aaaaand I"m reminded of why I could never get into programming, despite
> repeatedly trying, lol.
> On Sunday, July 25, 2021 at 12:12:36 AM UTC-5 JC wrote:
>
>> Thanks for the examples, Little Girl. I'm starting to, uh, see how much
>> AutoHotkey handholds users through its built-in GUI
>> <https://www.autohotkey.com/docs/commands/Gui.htm>.
>>
>> Question 1
>>
>> I'm wanting to create an AutoKey GUI that spits out my address in a
>> modular way (to send to people/when websites lack autofill or whatever;
>> I
>> use it surprisingly more often than one might expect):
>>
>> 123 XYZ Road
>> City, ST 12345-6789
>>
>> The GUI would send, based on your radio-button and checkbox choices:
>>
>> 1. only the first line
>> 2. the text above, exactly as is
>> 3. same as above but all on one line (", " in place of the line
>> break)
>> 4. the text above, as is but without "-6789"
>> 5. same as above but all on one line (", " in place of the line
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/15fde9de-5b6b-4701-8dec-3ecf5db211ben%40googlegroups.com.
>


Little Girl

unread,
Jul 25, 2021, 11:49:02 AM7/25/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:

>>>It would also be possible to roll your own dialog by directly using
>>>GTK or Qt.

>> I haven't gone that far with AutoKey yet, but it's on the plate for
>> the future.

>Hey, I was just outlining where the lunatic fringe was, not
>suggesting anyone actually try it! :)

>Unless you want to turn pro UI developer, there's probably no reason
>for such extreme measures.

>It is sufficiently niche and complex, so it probably pays well.

Heh. No worries. I'm just messing around with code and adding it to
the many things I do rather than trying to specialize in it or turn
it into a career. The certs will look good on my résumé, but not be
the main star of the show.

JC

unread,
Jul 25, 2021, 2:00:07 PM7/25/21
to autokey-users
Cool! And yeah, it would be infinitely helpful if there was a portion of the wiki dedicated specifically to acclimating AutoHotkey users to AutoKey.

If yad is objectively superior, could we petition the dev of AK to change from Zenity to yad, then? Wait, are you the author of AutoKey?

Little Girl

unread,
Jul 25, 2021, 6:02:41 PM7/25/21
to autokey-users
Hey there,

If yad is objectively superior, could we petition the dev of AK to change from Zenity to yad, then?

No, please don't. I, for one, would pipe up against it. My reason is that KDialog is provided by default with Kubuntu and Zenity is provided by default with Ubuntu, but Yad must be installed separately in either one. I realize that's easy to do, but I will always be in favor of software that doesn't require installation over software that does.
 

Little Girl

unread,
Jul 25, 2021, 6:25:55 PM7/25/21
to autokey-users
Hey there,

JC wrote:
Thanks for the examples, Little Girl. I'm starting to, uh, see how much AutoHotkey handholds users through its built-in GUI.

Yep, some programs do.
 
Question 1

I'm wanting to create an AutoKey GUI that spits out my address in a modular way (to send to people/when websites lack autofill or whatever; I use it surprisingly more often than one might expect):

123 XYZ Road
City, ST 12345-6789

The GUI would send, based on your radio-button and checkbox choices:
  1. only the first line
  2. the text above, exactly as is
  3. same as above but all on one line (", " in place of the line break)
  4. the text above, as is but without "-6789"
  5. same as above but all on one line (", " in place of the line break)
This is relatively lightning-quick to build in AutoHotkey, so I'm starting to get a bit simultaneously intimidated & disappointed by AutoKey...

This isn't nearly as bad as it may seem. In fact, if you look up each of those steps one by one on Stack Exchange, you could have a working script cobbled together within a few minutes. See Joe's message for some pointers on how to approach it and, as he said, you can always come in here or into the Gitter chat and ask for help if you run into trouble.
 
Question 2

Another question I have is: is it possible to have AutoKey's GUI display with the first radio button (in, say, a GUI with only radio buttons) already selected?

I haven't figured it out yet. If you run the AutoKey command in your terminal window with the -c option (so use the autokey-gtk -c command instead of the autokey-gtk command or use the autokey-qt -c command instead of the autokey-qt command), it will launch with the main window open. If you open another terminal window and run the same command (with the -c option) again when the main window isn't open, it will open the main window. I'm not certain it would work from within AutoKey, but so far it's fallen over for me when I tried it in my buggy version of the program. Your mileage may vary.

If you're game to try, this is what I did to test it here and it failed miserably. I created this little script and saved it with a typed abbreviation. I then closed the AutoKey main window and triggered the script with the abbreviation and was told that there's no such file or directory, but there is, so this needs more exploration:

import subprocess
subprocess.Popen(["autokey-gtk -c"])

 Question 3

In your three-shapes example popup, the title of the GUI is: "Choose all shapes that have four sides." However, the GUI that actually appeared was too horizontally small and didn't display the title in its full length. Is it possible to customize the GUI so that it always wraps its starting horizontal dimension to whatever the length of the title is?

 I'm not sure. Joe had some ideas on how that might be done and you could tinker with them. Meanwhile, I modified the script by adding width arguments to the dialog. While I was in there, I also made it so it will fail gracefully if you don't choose any of the options. Here's the new version of that script, and you can mess around with the height and width of any of those windows that open:

# This script opens a checklist dialog from which you can make one or more choices.
# It also opens an info dialog displaying an error or the checklist item(s) you chose.
# It also opens with two choices made for you by default.
# There are options to enable a line of code in each dialog below that print the result at the cursor.
# The defaults, height, and width options are optional and can be left off of any dialog.
# The exit code values are 0 for success or an integer for an error.


optionShapes = ["square", "triangle", "rectangle"]

retCode, choices = dialog.list_menu_multi(options=optionShapes,
    title="Choose all shapes that have four sides:",
    message="Shapes",
    defaults="square, rectangle",
    height="250",
    width="400")

# If the exit code of the dialog is not zero:
if retCode != 0:

    # Display the exit code of the command:

    myMessage = "The exit code of the dialog was: " + str(retCode)
    dialog.info_dialog(title="Error", message=myMessage, width="200")
    # Uncomment the following line to print the contents of the dialog at the cursor:
    # keyboard.send_keys(myMessage)

else:

    # For each item in the checklist:
    for item in choices:

        # If no item was chosen:
        if not item:
            # Display an info dialog letting the user know that:
            myMessage = "You did not choose any shapes."
            dialog.info_dialog(title="Result", message=myMessage)
            continue

        # Display an info dialog with your choice:

        myMessage = "You chose: " + item + "\n"
        dialog.info_dialog(title="Result", message=myMessage)
        # Uncomment the following line to print the contents of the dialog at the cursor:
        # keyboard.send_keys(myMessage)

Little Girl

unread,
Jul 25, 2021, 6:29:11 PM7/25/21
to autokey-users
By the way, my apologies for the messy code up there. Google removed the ability for us to insert raw code into these messages for some strange reason and it seems to like adding blank lines where there aren't any in what we paste in. When you come to any that don't belong, feel free to remove them.

jos...@main.nc.us

unread,
Jul 26, 2021, 8:37:32 AM7/26/21
to autoke...@googlegroups.com
Replacing Zenity with yad would be really cool, but very difficult to
justify the work involved.

IMHO yad is better, but everyone else might not agree.

I am perhaps the third longest term user who is still around and have
become the default project manager for AutoKey (Pointy Haired Boss).
I keep things going doing a lot of end user support and issue triage on
GitHub.

I was a professional programmer, but I'm a Python beginner and I do not
know the AutoKey source code or modify it.

Anyone can file an enhancement request issue on GitHub, but it's
preferable to discuss it here or on Gitter first to clarify the request
and see if it makes sense to others (whether they agree with it or not,
they have to understand it.)

Also some requests are impossible in practice or ill advised or,
sometimes, are asking for a feature that's already there, but the OP
doesn't realize it.

Weeding these out in advance really helps the project retain its focus.

Chris Deckter wrote the original (Python 2.x) version of AutoKey and
supported it for a number of years. Eventually, he burned out on it and
left the project.

The current version is based on Python 3.x . It was cloned and upgraded by
another developer, Guoci, who has also since gone inactive. We have had
several developers since then and currently have three who are actively
contributing to the project.

Joe
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/c23c063f-00ef-4fc3-8a34-0b7bdb54fa4en%40googlegroups.com.
>


jos...@main.nc.us

unread,
Jul 26, 2021, 9:12:15 AM7/26/21
to autoke...@googlegroups.com


> Hey there,
>
> JC wrote:
>
>> Thanks for the examples, Little Girl. I'm starting to, uh, see how much
>> AutoHotkey handholds users through its built-in GUI
>> <https://www.autohotkey.com/docs/commands/Gui.htm>.
>
>
> Yep, some programs do.
>
>
>> Question 1
>>
>> I'm wanting to create an AutoKey GUI that spits out my address in a
>> modular way (to send to people/when websites lack autofill or whatever;
>> I
>> use it surprisingly more often than one might expect):
>>
>> 123 XYZ Road
>> City, ST 12345-6789
>>
>> The GUI would send, based on your radio-button and checkbox choices:
>>
>> 1. only the first line
>> 2. the text above, exactly as is
>> 3. same as above but all on one line (", " in place of the line
>> break)
>> 4. the text above, as is but without "-6789"
>> 5. same as above but all on one line (", " in place of the line
>> break)
>>
>> This is relatively lightning-quick to build in AutoHotkey, so I'm
>> starting
>> to get a bit simultaneously intimidated & disappointed by AutoKey...
>>
>
> This isn't nearly as bad as it may seem. In fact, if you look up each of
> those steps one by one on Stack Exchange, you could have a working script
> cobbled together within a few minutes. See Joe's message for some pointers
> on how to approach it and, as he said, you can always come in here or into
> the Gitter chat and ask for help if you run into trouble.
>
>
>> Question 2
>>
>> Another question I have is: is it possible to have AutoKey's GUI display
>> with the first radio button (in, say, a GUI with only radio buttons)
>> already selected?
>>
>
> I haven't figured it out yet. If you run the AutoKey command in your
> terminal window with the -c option (so use the *autokey-gtk -c* command
> instead of the *autokey-gtk* command or use the *autokey-qt -c* command
> instead of the *autokey-qt* command), it will launch with the main window
> open. If you open another terminal window and run the same command (with
> the -c option) again when the main window isn't open, it will open the
> main
> window. I'm not certain it would work from within AutoKey, but so far it's
> fallen over for me when I tried it in my buggy version of the program.
> Your
> mileage may vary.
>
> If you're game to try, this is what I did to test it here and it failed
> miserably. I created this little script and saved it with a typed
> abbreviation. I then closed the AutoKey main window and triggered the
> script with the abbreviation and was told that there's no such file or
> directory, but there is, so this needs more exploration:
>
> import subprocess
> subprocess.Popen(["autokey-gtk -c"])
>

When a program is running in the GUI, its environment is whatever the GUI
has established. This is usually different from the environment that exits
when you open a terminal window.

In particular, the PATH that Linux uses to find executable programs is
different and usually less inclusive.

You can often get around this by specifying the fully qualified path to
your application, e.g. /usr/bin/autokey-gtk if you did a system wide or
package installation or where AutoKey was installed if you did a local
install using pip -user ...

Once it finds your program, what it will do with it is another story, but
if it doesn't work, you'll have a new error message to pursue.

Joe

> Question
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/a5f9fc52-6ef9-4696-893e-2e0275f05000n%40googlegroups.com.
>


jos...@main.nc.us

unread,
Jul 26, 2021, 9:16:56 AM7/26/21
to autoke...@googlegroups.com
When you end up with unintentionally reformatted code, rather than solving
the problem, you can almost always replace the code with a link to web
storage such as Dropbox or Pastebin. They don't mind structured text.

Joe

> By the way, my apologies for the messy code up there. Google removed the
> ability for us to insert raw code into these messages for some strange
> reason and it seems to like adding blank lines where there aren't any in
> what we paste in. When you come to any that don't belong, feel free to
> remove them.
>
> On Sunday, July 25, 2021 at 6:25:55 PM UTC-4 Little Girl wrote:
>
>> Hey there,
>>
>> JC wrote:
>>
>>> Thanks for the examples, Little Girl. I'm starting to, uh, see how much
>>> AutoHotkey handholds users through its built-in GUI
>>> <https://www.autohotkey.com/docs/commands/Gui.htm>.
>>
>>
>> Yep, some programs do.
>>
>>
>>> Question 1
>>>
>>> I'm wanting to create an AutoKey GUI that spits out my address in a
>>> modular way (to send to people/when websites lack autofill or whatever;
>>> I
>>> use it surprisingly more often than one might expect):
>>>
>>> 123 XYZ Road
>>> City, ST 12345-6789
>>>
>>> The GUI would send, based on your radio-button and checkbox choices:
>>>
>>> 1. only the first line
>>> 2. the text above, exactly as is
>>> 3. same as above but all on one line (", " in place of the line
>>> break)
>>> 4. the text above, as is but without "-6789"
>>> 5. same as above but all on one line (", " in place of the line
>>> break)
>>>
>>> This is relatively lightning-quick to build in AutoHotkey, so I'm
>>> starting to get a bit simultaneously intimidated & disappointed by
>>> AutoKey...
>>>
>>
>> This isn't nearly as bad as it may seem. In fact, if you look up each of
>> those steps one by one on Stack Exchange, you could have a working
>> script
>> cobbled together within a few minutes. See Joe's message for some
>> pointers
>> on how to approach it and, as he said, you can always come in here or
>> into
>> the Gitter chat and ask for help if you run into trouble.
>>
>>
>>> Question 2
>>>
>>> Another question I have is: is it possible to have AutoKey's GUI
>>> display
>>> with the first radio button (in, say, a GUI with only radio buttons)
>>> already selected?
>>>
>>
>> I haven't figured it out yet. If you run the AutoKey command in your
>> terminal window with the -c option (so use the *autokey-gtk -c* command
>> instead of the *autokey-gtk* command or use the *autokey-qt -c* command
>> instead of the *autokey-qt* command), it will launch with the main
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/546d7b98-ea97-49ad-b159-bd6fa0b8e20en%40googlegroups.com.
>


Little Girl

unread,
Jul 26, 2021, 2:18:26 PM7/26/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:
>Little Girl wrote:

>> If you're game to try, this is what I did to test it here and it
>> failed miserably. I created this little script and saved it with a
>> typed abbreviation. I then closed the AutoKey main window and
>> triggered the script with the abbreviation and was told that
>> there's no such file or directory, but there is, so this needs
>> more exploration:
>>
>> import subprocess
>> subprocess.Popen(["autokey-gtk -c"])

>When a program is running in the GUI, its environment is whatever
>the GUI has established. This is usually different from the
>environment that exits when you open a terminal window.

Yeah. I figured I'd test launching it twice from two different
terminal windows first just to see if that would try to open another
instance of AutoKey or bring up the main window. I was pleasantly
surprised to find that it brings up the main window. I then put it
into an AutoKey script to see if I could get it to do it.

>In particular, the PATH that Linux uses to find executable programs
>is different and usually less inclusive.

Yep.

>You can often get around this by specifying the fully qualified
>path to your application, e.g. /usr/bin/autokey-gtk if you did a
>system wide or package installation or where AutoKey was installed
>if you did a local install using pip -user ...

I tried that. I even tried just autokey and /usr/bin/autokey because I
also have those in that directory. None of the four worked from my
copy of AutoKey, but you'all might have better luck with your more
modern versions.

>Once it finds your program, what it will do with it is another
>story, but if it doesn't work, you'll have a new error message to
>pursue.

True. The endless adventures of Python or AutoKey (or both) error
messages are always entertaining when you tend to mess around.

Little Girl

unread,
Jul 26, 2021, 2:21:30 PM7/26/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:

>When you end up with unintentionally reformatted code, rather than
>solving the problem, you can almost always replace the code with a
>link to web storage such as Dropbox or Pastebin. They don't mind
>structured text.

Good point. I'll also try reaching out to Google to suggest that they
bring back the code formatting. Perhaps a pretty please with a cherry
on top will do it.

jos...@main.nc.us

unread,
Jul 27, 2021, 10:21:09 AM7/27/21
to autoke...@googlegroups.com
If you can come up with a million cherries, it might help. :)

If you file something I can upvote, let me know.

Joe
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/60fefd28.1c69fb81.1ed65.382b%40mx.google.com.
>


Little Girl

unread,
Jul 27, 2021, 5:07:29 PM7/27/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:

>If you can come up with a million cherries, it might help. :)
>
>If you file something I can upvote, let me know.

Heh. I asked with a pretty please with a million cherries on top. I
didn't see a way to do it anywhere where you could upvote it, so I
just sent feedback. Hopefully they'll do it. You could do the same, I
suppose. The more, the merrier, right?

jos...@main.nc.us

unread,
Jul 28, 2021, 2:32:34 AM7/28/21
to autoke...@googlegroups.com
I lost track of what I agreed to upvote in this long thread.

Joe
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to autokey-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/6100758f.1c69fb81.5a0fb.0611%40mx.google.com.
>


Little Girl

unread,
Jul 28, 2021, 1:27:11 PM7/28/21
to autoke...@googlegroups.com
Hey there,

jos...@main.nc.us wrote:

>I lost track of what I agreed to upvote in this long thread.

Google Groups giving us the code blocks back so our snippet formatting
will be honored.
Reply all
Reply to author
Forward
0 new messages