{space} in clipboard Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
JoshS611
Posts: 10
Joined: 07 Dec 2017, 12:26

{space} in clipboard

12 Jan 2018, 10:04

I'm currently working on saving time with my script where I have been sending a long variable. I have simply been using the send command to send the whole variable which makes the program manually type it out. However I realised that I could save seconds by using clipboard=%variable% and Send, {ctrl down}v{ctrl up} see below for what I am meaning:
Original:

Code: Select all

Variable1=Hello,{space}
Variable2=How are you,{space}
Variable3=Well thank you
Greeting=%Variable1%%Variable2%%Variable3%
Send, %Greeting%
Resulting correctly but "slowly" in Hello, How are you, Well thank you

New:

Code: Select all

Variable1=Hello,{space}
Variable2=How are you,{space}
Variable3=Well thank you
Greeting=%Variable1%%Variable2%%Variable3%
Clipboard=%Greeting%
Send, {ctrl down}v{ctrl up}
This sends text instantly but sends {space} literally so Hello,{space}How are you,{space}Well thank you

Could anyone help with my problem of adding a space to the end of a variable and then refering to this variable later including its space

In case anyone wonders why not just omit the {space} and use Greeting=%Variable1% %Variable2% %Variable3%, I am actually taking the variables from a spreadsheet and if the cell is blank I don't want the variable to be a space, i want it to be blank. I understand I could use a tree of if commands when setting the Greeting variable to decide where the spaces should be but this seems too lengthy when it actually consists of more like 8 variables, all with or without spaces based on their own rules.

Thank you!
User avatar
noname
Posts: 509
Joined: 19 Nov 2013, 09:15

Re: {space} in clipboard  Topic is solved

12 Jan 2018, 10:19

Code: Select all

autotrim off
Variable1=Hello,%a_space%
clipboard:=Variable1
%a_space% gives you a space

See autotrim to not trim spaces : https://autohotkey.com/docs/commands/AutoTrim.htm
soundcloud.com/user-32706894
JoshS611
Posts: 10
Joined: 07 Dec 2017, 12:26

Re: {space} in clipboard

12 Jan 2018, 10:25

Brilliant, I tried the %a_space% and tried just typing a space after setting autotrim off, never occurred to try both together, working fine now thank you!
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: {space} in clipboard

12 Jan 2018, 13:42

I would do it like this, using expression-style assignments. Cheers.

Code: Select all

q::
Variable1 := "Hello, "
Variable2 := "How are you, "
Variable3 := "Well thank you"
Greeting := Variable1 Variable2 Variable3
Clipboard := Greeting
Send, ^v
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, duncan21, Google [Bot], thephoenix and 235 guests