Cut linebreak when copying from Exel? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Krd
Posts: 405
Joined: 10 Mar 2020, 02:46

Cut linebreak when copying from Exel?

01 Mar 2021, 08:24

Hello,

Code: Select all

Send, {Ctrl Down}c{Ctrl Up}   ;copying 11 digits number from exel.
Sleep, 500
11digit := Clipboard
The problem is that if I use "If and else" it doesn't match the same 11 digit numbers found in another place in order to make a match.
Because if I paste the result to a word-doc it adds and extra line which autohotkey reads and my next copying value will never match the clipboard as it has a line break.

Is there a code that removes the line break? I found some old posts but couldn't make it work.

This is my whole code:

Code: Select all

0 & s::    
Loop, 2
{
Click, 399, 6
Sleep, 1000
Send, {Down}
Sleep, 1000
Send, {Ctrl Down}{Shift Down}{Left}{Shift Up}{Ctrl Up}
Sleep, 1000
Send, {Ctrl Down}c{Ctrl Up}   ;copy 11 digits from exel.
Sleep, 500
11digit := ""
Sleep, 500
11digit := Clipboard
Sleep, 500
Click, 1941, 838 
Sleep, 500
Send, {Ctrl Down}f{Ctrl Up}
Sleep, 500
Send,{Alt Down}d{Alt Up}
Sleep, 500
Send, {Ctrl Down}v{Ctrl Up}
Sleep, 500
Send, {Enter}
Sleep, 500
Send, {Enter}
Sleep, 7000
Clipboard := "" 
Click, 2443, 208, 2  ;Copy second 11 digits from another system
Sleep, 500
11digitSECOND := ""
Sleep, 500
11digitSECOND := Clipboard
Sleep, 500
Clipboard := ""
Sleep, 500
if (11digit ~= 11digitSECOND)
{
Click, 399, 6
Sleep, 500
Send, {Ctrl Down}f{Ctrl Up}
}
else 
Click, 3302, 185
Sleep,1000
}
Krd
Posts: 405
Joined: 10 Mar 2020, 02:46

Re: Cut linebreak when copying from Exel?

01 Mar 2021, 09:26


Don't know where to put it, thats what I have seen before...
Krd
Posts: 405
Joined: 10 Mar 2020, 02:46

Re: Cut linebreak when copying from Exel?

01 Mar 2021, 10:17

Is there another way to remove other than first 11 digits from clipboard? I want first 11 digits copied.
User avatar
mikeyww
Posts: 27044
Joined: 09 Sep 2014, 18:38

Re: Cut linebreak when copying from Exel?

01 Mar 2021, 10:24

Code: Select all

Clipboard = rrrr123xyz4567890123456abc123456defg
Sleep, 80
; -----------------------------------------------
str := Clipboard, Clipboard := "", Clipboard := RegExReplace(RegExReplace(str, "\D"), ".{11}\K.*")
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Else MsgBox, 64, First eleven digits, %Clipboard%
Krd
Posts: 405
Joined: 10 Mar 2020, 02:46

Re: Cut linebreak when copying from Exel?  Topic is solved

01 Mar 2021, 10:38

This fixed for me after the first value copy from exel:

11digit := substr(clipboard, 1, 11)

Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, yanjujino1 and 206 guests