Copy multi-line clipboard into variables

Get help with using AutoHotkey and its commands and hotkeys
Johana
Posts: 189
Joined: 02 May 2017, 02:34

Copy multi-line clipboard into variables

12 Jan 2019, 17:19

I want a hotkey to copy lines that looks exactly like this:

Code: Select all

Some text here1
Some text here2
12345 TEXT ;I need only number / not text

165465465465

[email protected]
I need each row to go into variable1, var2, var3 and so on (empty rows should not be counted. Row 3 should only return the numeric value into a variable.

Do I need to loop? Or what do I need todo?
User avatar
Scr1pter
Posts: 1214
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Copy multi-line clipboard into variables

12 Jan 2019, 17:33

Not tested, but I believe it will be a good starting help for you.

Code: Select all

Numpad0::
Loop, Parse, Clipboard, `n, `r  ; Split on each line break
{
  if A_Index = 3 ; If it's the 3rd round:
  {
    var3 = %A_LoopField% ; Get value
    var3 := RegExReplace(var3, "[^a-z]*\K[a-z]*") ; Remove all alpha-numericals
  }
  else ; For all other rounds:
  {
    var%A_Index% = %A_LoopField% ; Get values
  }
}
return
Please use [code][/code] when posting code!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602, Jelly Comb Touchpad - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.32.00
Johana
Posts: 189
Joined: 02 May 2017, 02:34

Re: Copy multi-line clipboard into variables

01 Mar 2019, 14:16

Scr1pter wrote:
12 Jan 2019, 17:33
Not tested, but I believe it will be a good starting help for you.

Code: Select all

Numpad0::
Loop, Parse, Clipboard, `n, `r  ; Split on each line break
{
  if A_Index = 3 ; If it's the 3rd round:
  {
    var3 = %A_LoopField% ; Get value
    var3 := RegExReplace(var3, "[^a-z]*\K[a-z]*") ; Remove all alpha-numericals
  }
  else ; For all other rounds:
  {
    var%A_Index% = %A_LoopField% ; Get values
  }
}
return
Worked great, It did count the empty rows as well.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bibliocrat, Bing [Bot], JoeWinograd, mikeyww, nutnutwin and 54 guests