Using autohotkey to search for a word in the title of a window then replacing the entire title with something new - title

I am new to autohotkey and am trying to search for a certain word in the current window, say the title is: "Raining cats and dogs" I want to select the title if it has the word "cats" and then change it to "CATS". If it did not have the word "cats" then do not change.
I used the hotkey
F12::
WinGetTitle, title, A
MsgBox, "%title%"
return
but I am unaware on how to do a word search in that title then change it.

Related

Google search input text box can be found using name but not id

I am trying to go to the url "https://www.google.co.in" enter the word "Googling" in the input text box and then click on the search button.
The input text box has id "gs_htif0".
So the statement
driver.findElement(By.id("gs_htif0")).sendKeys("Googling");
should work. But it's not. The statement
driver.findElement(By.name("q")).sendKey("Googling");
is working fine. It fills the search box with the word "Googling".
It seems you tried incorrect id. Please check with :
driver.findElement(By.id("lst-ib")).sendKeys("Googling");

Insert/replace string in existing text form field in Word (VBA)

So I'm trying to create a conditional dropdown in Word. I've used a Legacy Drop-Down Form Field with multiple options.
What I want to happen is when one of the options is selected from the dropdown (and then I guess you have to Tab to enter it...), the Legacy Text Form Field below, that has a simple default text, should populate with a new string from the case statement.
Things that I've already done/got working:
the drop down is working, and on exit it runs a macro
case statement is written out
the result of the case statement is in a variable (string type), let's call it StringVar
can pull the text form field's text (default text) with ActiveDocument.FormFields("TextBox").Result
What I figure out, however, is how to replace the default text in the already existing Text Form Field with the case statement's string variable text.
I've tried
ActiveDocument.FormFields("TextBox").Result = StringVar
but it doesn't change anything inside the text form field. The default text is still there.
So I can answer my own question after pondering and being hit with an "oh, duh" moment.
I had unprotected the document (ActiveDocument.Unprotect Password:="") in order to do this:
ActiveDocument.Content.InsertAfter Text:=("This is my text")
because I was wondering if I was grabbing the right string.
Turns out,
ActiveDocument.FormFields("TextBox").Result = StringVar
DOES work. BUT the file has to be protected (filling in forms) for it to replace the string in the text form field. Otherwise, nothing shows up even though the result had indeed been updated. Fancy that.

Make the text Bold or Underline

Goal:
Make the country's name to have underline or bold in the textbox. Please rememeber that there are lots of country's name in the list.
Problem:
How should I enable to make the country's name to have underline or bold only?
Information:
The data source is SSAS.
You can do this using Placeholders. To use placeholders in your cell, click on where it shows <<Expr>> so it is highlighted then right-click it and choose Placeholder Properties.... On the General tab select the radio button to activate HTML - Interpret HTML tags as styles.
So now we can use HTML tags to highlight sections of the text in the cell. Next we need a function to convert country names so they appear bold.
Create a custom code function to bold the text: from the Report menu, choose Report Properties... and click the Code tab. Enter the following code:
Function BoldCountries(Text As String) As String
return Text.Replace("Australia", "<b>Australia</b>")
End Function
Okay, so that only bolds Australia. I'll leave it as an exercise for you to load a list of country names and iterate through them putting HTML bold tags around the country names.
Finally, go to your field cell and change the expression for the `Value from just the field value to calling this function with the field value:
=Code.BoldCountries(Fields!FieldWithCountryNames.Value)

Word: remove page from multipage userform

I want, depending of the previous choice from the user just let some tab's being seen.
Once i am new in VBA, i start showing all the tab's and after the choice from the user, i remove the tab's that i don't want. For that i am using this line of code
MultiPage1.Pages.Remove "name of the tab"
The problem is, if i don't have the same CAPTION and the NAME field of the tab the tab is not remove.
If anyone have a diferent solution for this or another away to remove without have to change the caption for the same name of NAME field i would be thankful.
Thanks
You can give a page of a multi-page control a different name from the caption in the Properties Window. You can access it from the View menu.
I've highlighed the name of the control in yellow and the caption in aqua.
If the captions are unique, you could use a Select Case statement to get the name, based on the caption. Are users actually typing in the caption of the tabs they want, or selecting from check boxes? In either case, the captions would have to be unique, so you could do something like:
Select Case True
Case Check1.Value
MultiPage1.Pages.Remove Pages("kp").Index
Case Check2.Value
MultiPage1.Pages.Remove Pages("jp").Index
End Select
That's a bit rough, but is that the general idea?

Add a button to a word textbox

I want to add a button to a textbox in a word document.
The button should stick to the textbox like this:
----------------------------------------
word document content
text, text, a textbox follows
------------------[button1]-
|text box content |
----------------------------
text, followed by another textbox
------------------[button1]-
|textbox2 content |
----------------------------
more text
---------------------------------------
I have been able to add a button using vba, but I don't know how to make it stick to the textbox since I can have more instances to textboxes with buttons.
I would like to do this using macros, but a C# addin solution is also welcomed.
I'm afraid it isn't possible to overlay a button to a textbox like you show, and make them stick together. To overlay them, you need to set their layout wrapping style to something else than "in line with text" (e.g. "Square") but then Word won't let you group them (at least not my Word 2003) so in principle they can be moved relative to each other.
However if you create a button and a text box next to each other and leave the wrapping style be "in line with text" which is the default, then they will stay side by side and not move relative to each other (unless you type text in between them).
Selection.InlineShapes.AddOLEControl ClassType:="Forms.CommandButton.1"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.InlineShapes.AddOLEControl ClassType:="Forms.TextBox.1"
Then you can your other textbox-button pairs on the following lines.