Change text colour in a hotkey

Ask gaming related questions (AHK v1.1 and older)
TonyR
Posts: 2
Joined: 15 Apr 2021, 00:30

Change text colour in a hotkey

15 Apr 2021, 01:05

I'm writing documents relating to the game of contract bridge and need the ability to easily insert suit symbols. I've just discovered AutoHotKey and am very happy with the results.

I have created a script file with 4 scripts like :?*:! C::♣. (without the space between ! & C) This works well, but the icing on the cake would be to have the heart and diamond symbols appear red.

Is there any way to save the current text colour, change it to red before inserting the symbol and then restore the original colour?

Thanks

Tony
Last edited by BoBo on 15 Apr 2021, 05:07, edited 1 time in total.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Change text colour in a hotkey

15 Apr 2021, 17:47

The easiest way to do it is to have to separate Text controls, one for the rank and another for the suit. Then you can make the color for the suit Text control red. You can do that and position them right next to each other so they'll look like they do now, except if the rank character(s) gets wider, like Q or especially 10, it will change the natural position for suit that would be next to it as a separate control. One way around that is to use a monospace font like Courier New for the rank and use T instead of 10. Another way is to have the rank Text control be right-justified so it's allowed to grow and shrink on its left side so the right will stay butted up to the suit.

Having just said all that, I realized that you're talking about hotstrings and not GUI controls, so all that is out the window. :)
There are different ways to handle changing colors depending on what app you're using to type into with your hotstrings.
TonyR
Posts: 2
Joined: 15 Apr 2021, 00:30

Re: Change text colour in a hotkey

18 Apr 2021, 18:07

Thanks for the reply, boiler.

I am typing my documents in open office. The manual way to change colour is to highlight the text and then use a colour-picker from the menu. An alternative would probably to do a global replace at the end of the text and change all diamond and heart symbols to red. I've never tried that in OO, it did work in MSWord.

Ideally, I would like to do it on the fly using a hotkey.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Change text colour in a hotkey

18 Apr 2021, 19:00

The best way is probably to interface with OO via the Open Office API.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: prototype_zero and 36 guests