Save and Trim Variables as Raw Text

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jgchao
Posts: 46
Joined: 28 Jun 2016, 10:15

Save and Trim Variables as Raw Text

24 May 2017, 11:57

Hello,

I am trying to save a series of variables as raw text, and then trim them.

They are numbers like "+108", "+222", "+821". AHK reads them as "!08", "@22", "*21", and this also causes an error when I try to consolidate and trim them. How can I correct this?

My code below:

Code: Select all

^Numpad1::
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
	Sleep, 100
	template1 := rTrim(Clipboard," `t`r`n")
	Clipboard := ""
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
	sleep, 100	
	template2 := rTrim(Clipboard," `t`r`n")
	Clipboard := ""
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
	sleep, 100	
	template3 := rTrim(Clipboard," `t`r`n")
	Clipboard := ""
Return

^Numpad2::
templates := rTrim(%template1% %template2% %template3%," `t`r`n")
MsgBox, %templates%
Return
Thanks in advance!
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Save and Trim Variables as Raw Text

24 May 2017, 12:09

No reproduce, no comment.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Save and Trim Variables as Raw Text

24 May 2017, 12:12

They are numbers like "+108", "+222", "+821". AHK reads them as "!08", "@22", "*21"
Compare:

Code: Select all

Send, +108
SendRaw, +108
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Save and Trim Variables as Raw Text

24 May 2017, 12:39

jgchao wrote:

Code: Select all

^Numpad1::
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
	Sleep, 100
	template1 := rTrim(Clipboard," `t`r`n")
	Clipboard := ""
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
	sleep, 100	
	template2 := rTrim(Clipboard," `t`r`n")
	Clipboard := ""
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
	sleep, 100	
	template3 := rTrim(Clipboard," `t`r`n")
	Clipboard := ""
Return

^Numpad2::
templates := rTrim(%template1% %template2% %template3%," `t`r`n")
MsgBox, %templates%
Return

Code: Select all

^Numpad1::
    Loop, 3
    {
        Clipboard := ""
        Send, ^c{Down}
        ClipWait, 1
        template%A_Index% := RTrim(Clipboard, " `t`r`n")
    }
Return

^Numpad2::
    templates := template1 template2 template3
    MsgBox, % templates
Return
Edit:
Send, {CTRLDOWN}c{CTRLUP}{DOWN}
You need a space between Ctrl and Down. {Ctrl Down}
templates := rTrim(%template1% %template2% %template3%," `t`r`n")
Remove the %%. Note that this combines the strings, then trims the combined string.
jgchao
Posts: 46
Joined: 28 Jun 2016, 10:15

Re: Save and Trim Variables as Raw Text

24 May 2017, 13:06

kon wrote:
templates := rTrim(%template1% %template2% %template3%," `t`r`n")
Remove the %%. Note that this combines the strings, then trims the combined string.
Thank you! But how can I preserve the spaces in between the templates?
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Save and Trim Variables as Raw Text

24 May 2017, 13:32

But how can I preserve the spaces in between the templates?
Don't use RTrim the first time?

Code: Select all

^Numpad1::
    Loop, 3
    {
        Clipboard := ""
        Send, ^c{Down}
        ClipWait, 1
        template%A_Index% := Clipboard
    }
Return

^Numpad2::
    templates := RTrim(template1 template2 template3, A_Space "`t`r`n")
    MsgBox, % templates
Return
Quick Edit:
Or add the spaces manually: templates := RTrim(template1 " " template2 " " template3, A_Space "`t`r`n")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, NinjoOnline and 299 guests