autohotkey text replacement with variable - autohotkey

I am trying to figure out a way to do text replacement with a variable if possible.
Basically let's say I have a string: The Color is Red
I can say ::color::The Color is Red which will work, but now what if I want to be able to specify the color on demand. So if I typed color blue it would print out The Color is Blue instead.
Is there a way to do that? Or will I have to define all possible variations of my sentence in my script.

You can use a parsing Loop (or a For Loop in an array) and the Hotstring() function to create the hotstrings dynamically:
colors := "Blue,Red,White"
Loop, parse, colors, `,
Hotstring(":*:" "color " A_Loopfield, "The Color is " A_Loopfield, On)
The above code has to be placed in the auto-execute section (top of the script, before the first hotkey, hotstring or return) otherwise the script can't create the hotstrings.

Related

Change Backgroung Color of Matching Variables In VSCode

VSCode highlight matching occurrences under cursor by default
Highlighted matching occurrences - Default
What I want is to change the background color of variables matching occurrences under the cursor. Like this
Desired highlighting
The closest I got was with
workbench.colorCustomization{ "editor.selectionHighlightBackground": "#ff0000" }
however if the current variable is inside a loop/switch/etc, the outer occurrences isnt highlighte, also I need to have the text selected, not just with the cursor sitting there.
Thanks in advance.

How to change the color of parentheses and brackets (all occurrences) in ms word

I found a lot about changing the text within parentheses or brackets in ms word (ctrl+H and then setting options through the format), but how can we change the format (color) of parentheses or brackets itself, at all occurrences?
This is not a programming question. As such, it is off-topic here.
That said, a single wildcard Find/Replace is all you need, where:
Find = [\(\[\{\}\]\)]
Replace = ^&
and you set the replacement font attributes to whatever you want.
The above will replace all parentheses, braces and square brackets.
Here's a quick way,
I am showing in WPS Office you can follow the same in Ms Word
First hit Ctrl + H and Search for the Paranthesis or Brackets you want one at a time each.
Hover your cursor in the Replace with Section and Click on Format >> Font
You will see Font color section the in Replace Font Window
Select the color of your choice and click Ok
Click on Replace All
I hope this will help you out fixing your issues

gtk turn on italic, bold, etc in textview

[Revised]
I am trying GTK3 TextView, in C. I know how to apply tags, such as italics, etc., to a region of text.
But how do I "turn on" a style (italics, bold, etc) while typing in the buffer? For example, suppose I am typing text and there are no styles set. Then I want to type in italics. I want to apply the italic tag to the insert point, after which whatever I typed would be in italics.
I notice that when you place the insert cursor to the right of any existing styled text, the tags of the previous character are inherited, but only if the style is in effect before and after the insert point. Interestingly, the trailing newline can be stylized, so when the insert point is at the end of a line and the last visible character has a style, then that style is inherited.
I've looked at some methods that use a key-press signal and then apply a text tag to the region of the untagged character just typed, but that is slow and looks odd on screen -- the plain char is displayed and then replaced by the tagged char.
I've also tried:
gtk_text_buffer_insert_markup(buf, &iter, "<i>", -1);
but that gets a Warning: Invalid markup string: ... Element 'markup' was closed, but the currently open element is 'i' and has no effect on the displayed text. Using <i></i> gets no warning but also has no effect. I finally resorted to:
gtk_text_buffer_insert_markup(buf, &iter, "<i> </i>", -1); // 2 spaces
gtk_text_iter_backward_char (&iter);
gtk_text_buffer_place_cursor(buf, &iter);
which lets me start typing in italics between 2 new spaces -- that's not so bad.
But clicking an "I" button to start typing in italics -- that is a basic editing function that has been around for decades. It must be possible in GTK somehow?
Any ideas?
thanks

How Can I Make Some Window Region Transparent?

Instead of making a window transparent, I just want to make some regions of it transparent, how can I achieve that?
Searching for:
AutoHotkey transparent - Google Search
https://www.google.com/#q=AutoHotkey+transparent
The first result is:
WinSet
https://autohotkey.com/docs/commands/WinSet.htm
The subcommand 'Region' changes which parts
of the window are visible, making some parts completely transparent (invisible and click-through),
but it is not at all obvious from the help documentation that this is what it does.
Here is an example:
;make a Notepad window transparent apart from 3 opaque square regions:
vSquare1 := "100-100 200-100 200-200 100-200 100-100"
vSquare2 := "400-100 500-100 500-200 400-200 400-100"
vSquare3 := "700-100 800-100 800-200 700-200 700-100"
WinSet, Region, % vSquare1 " " vSquare2 " " vSquare3, Untitled - Notepad
There are further examples on the page.

Set background color other then standard one in Powershell

I can change console background color by script:
$host.UI.RawUI.BackgroundColor = "Black"
but in this case I'm limited to preset number of defined colors and unfortunately one I'm looking for is not here. There is option to pick color from console GUI (right click on top Windows PowerShell bar->properties->Colors). Unfortunately (again) only BackGroundColor and ForeGroundColor can be changed there, no way to change one of $host.privatedata colors there.
Is there possibility to put hex coded color via script somehow?
there is a registry hack here : http://stackingcode.com/blog/2011/11/14/zenburn-powershell
In my view, Powershell should allow you to set colors to a rgb hex value rather than the predefined set of colors. But design questions aside, the way I worked around this was to create a .reg file to redefine the "color buckets" (which they call ColorTables) that Powershell uses. The code below includes comments indicating what the specific ColorTable controls in Powershell.
Notes:
To save your current colors first, open regedit and export HKCU\Console.
Save the code below to a file (e.g. colors.reg), and run it.
Create a shortcut pointing to powershell. Run it. It should have new colors.
To modify colors, set the appropriate ColorTableXX dword to the hex value, but note, the RGB values are actually BGR, and they need to be padded with 00 in front of the number. So a blue color, #4286f4, would have a dword of 00f48642.
colors.reg:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
; BACKGROUND
"ColorTable07"=dword:00efefef
; ERROR BACKGROUND
"ColorTable00"=dword:00efefef
;ERROR
"ColorTable12"=dword:00255ffc
; STATIC TEXT (PROMPT and OUTPUT) AND COMMAND ARGUMENT
"ColorTable01"=dword:00472713
; COMMAND TEXT
"ColorTable14"=dword:00c56e36
; COMMAND TEXT SELECTED
"ColorTable09"=dword:00ef47d3
; COMMAND FLAG
"ColorTable08"=dword:00a53733
; COMMAND FLAG SELECTED
"ColorTable15"=dword:00ef47d3
; COMMMAND ARGUMENT SELECTED
"ColorTable06"=dword:00ef47d3
; COMMAND VARIABLE (e.g. $profile)
"ColorTable10"=dword:00a53733
; COMMAND VARIABLE SELECTED
"ColorTable13"=dword:00ef47d3
; deep purple -- not sure what this is
"ColorTable04"=dword:00660566
; brown -- not sure what this is
"ColorTable05"=dword:00336699
; purple -- not sure what this is
"ColorTable11"=dword:00845f84
; green -- not sure what this is
"ColorTable02"=dword:00339933
; pastel lavendar -- not sure what this is
"ColorTable03"=dword:00FF9999