I am so confused why this is the only way to concatenate some text and clipboard

Get help with using AutoHotkey and its commands and hotkeys
kwfine
Posts: 16
Joined: 26 Nov 2015, 06:46

I am so confused why this is the only way to concatenate some text and clipboard

18 Jul 2018, 10:32

Hi all,

I am using Version 1.1.25.01 in Windows 7.

I have tried to concatenate some text and clipboard in AHK:

Code: Select all


Trial 1:
clipboard ;clipboard = "英國語"
finalString = "I am learning 日本語 and " %clipboard %


Trial 2:
clipboard ;clipboard = "英國語"
finalString = "I am learning 日本語 and " + %clipboard %


Trial 3:
variable = clipboard ;clipboard = "英國語"
finalString = "I am learning 日本語 and " . %clipboard %


Trial 4:
variable = clipboard ;clipboard = "英國語"
finalString = "I am learning 日本語 and " . clipboard 
How come only Trial 4 succeeded, and trials 1 and 2 and 3 were not successful?
Could you help me please?

Thank you

Kitty
User avatar
TLM
Posts: 1561
Joined: 01 Oct 2013, 07:52
GitHub: TLMcode
Contact:

Re: I am so confused why this is the only way to concatenate some text and clipboard

18 Jul 2018, 11:02

( for starters ) In 1, 2 and 3 you shouldn't have a trailing space between clipboard and the percent sign: %clipboard%.
Trail 4 will only concat the word ( literal string ) `clipboard` to the end of finalString NOT the clipboard's content.

If you're going to assign the variable `variable` with the clipboard contents,
you either have to use expression mode: variable := clipboard or also use percent signs: variable = %clipboard%

lastly if you want to concat the clipboard contents assigned to the variable `variable`, you should use it instead of `clipboard`.

Code: Select all

variable = %clipboard% ; or variable := clipboard
finalString = "I am learning 日本語 and " . %variable%
hth
Freire
Posts: 16
Joined: 10 Dec 2017, 11:30

Re: I am so confused why this is the only way to concatenate some text and clipboard

18 Jul 2018, 11:04

Posted a bit later. Well, just to add to the asnwer above:

Code: Select all

Trial 1:
finalString := "I am learning 日本語 and " clipboard ; The Column + Equal will interpret the right part as "Formula" and will ignore blank spaces between the Quote and The variable "clipboard"
Trial 2:
finalString := "I am learning 日本語 and " . clipboard ; The Same as Above Except that dot is the concatenate Operator, it can be ommited as above.
Trial 3:
finalString = I am learning 日本語 and %clipboard% ; The Equal sign will interpret anything as text and you must enter %% around your variables. Spaces won't be ignored here.

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, bourdin07, Gandharv and 227 guests