Split String and send with delay

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fischmir
Posts: 3
Joined: 24 Sep 2018, 01:27

Split String and send with delay

24 Sep 2018, 01:37

Hi,

I need to transfer some data from Excel to a web application. I Excel, I build a string, something like:

Code: Select all

{Shift Down}{TAB}{Shift up}{DOWN}{TAB}{TAB}{DOWN}{TAB}{DOWN}{TAB}{TAB}{TAB}{TAB}0,5{TAB}Some Comments
Then, I use the following script:

Code: Select all

!v::
mycb = %clipboard%
Send, %mycb%
Unfortuately, my web application is too slow, so I need to send the Keys using sleep.

So I need to split the string into single pieces, which can be send. But I don't know how to do this, as I can not use { as split_character, as I have two fields which can contain any text and do not start or end with { or }.

Code: Select all

;word_array := StrSplit(mycb, "{")
--> This doesn't work in case.

Any ideas how to send the single keys with delay?

Thanks,
Christian
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Split String and send with delay

24 Sep 2018, 01:51

Use SetKeyDelay with your current method.
You can set delay and duration of the key press.

HTH
fischmir
Posts: 3
Joined: 24 Sep 2018, 01:27

Re: Split String and send with delay

24 Sep 2018, 02:02

Yes, I found that....my main problem is to split the string into single pieces. How to split

{TAB}Test comment{ENTER}

into 3 pieces:?

{TAB}
Test comment
{ENTER}

Thanks.
garry
Posts: 3759
Joined: 22 Dec 2013, 12:50

Re: Split String and send with delay

24 Sep 2018, 11:19

made complicated , maybe with regex

Code: Select all

#warn
c:=""
x:="}"
a={Shift Down}{TAB}a1{Shift up}{TAB}Test comment{ENTER}a2{END}ended
b:=StrSplit(a,x)
Loop % b.MaxIndex()
  {
  m:=b[a_index]
  if m=
   continue
  stringmid,h,m,1,1
  if (h<>"{")
    {
	k1=
	k2=
	stringsplit,k,m,`{
	if k2=
	c .= k1 . "`n"
	else
    c .= k1 . "`n{" . k2 . "}`n"
	continue
	}
  c .= m . "}`n"
  }
msgbox, 262208, ,%c%
loop,parse,c,`n,`r
 {
 s:= a_loopfield
 if s=
   continue
 ;sleep,100 
 msgbox, 262208, ,%s%,.7
 }
exitapp
esc::exitapp
fischmir
Posts: 3
Joined: 24 Sep 2018, 01:27

Re: Split String and send with delay

25 Sep 2018, 00:54

Hi garry,

absolutely perfect. It worked out of the box.

I splitted variable c by 'n and processed all values in a loop. Thanks you very much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: hiahkforum, NullRefEx, ShatterCoder and 104 guests