Move cursor in form field text to space character

Share your macros, knowledge, solutions, services, ...
Post Reply
Petr
Posts: 88
Joined: Tue Oct 18, 2016 1:12 pm

Move cursor in form field text to space character

Post by Petr » Sun Jan 08, 2017 4:13 pm

A user came up with this question:
I want an automation or keyboard/mouse macro program that is able
to go to a field on a input box in my tax program
go the end of the field
have the cursor move left until it gets to a space
move right and then copy the 3 characters
paste those characters into the input area of the input box
add 3 numbers and 4 symbols

I know your program can do all what I ask but I am unsure of it having the logic to move left until it encounters a space and then move the cursor right?
The macro below does it. It navigates cursor to the position of the last space in the text in the field and then copies to clipboard next three characters. Just type in Notepad (or any other text editor or text field) text like this:
You will see in the clipboard numbers 123!
Make sure the cursor is anywhere on this line (any position, begin, middle, end) and run the macro. You should get "123" text in clipboard.

Code: Select all

<#>Copy whole line to clipboard
<home><#>
<shift><#>
<end><#>
<shift><#>
<clp_copyselected>(0,10)<#>Find the first space from the end of the line
<var_oper>(vLnt,"%_vClpText%",STR_LENGTH,"","","")<#>
<for>("i=EXPR(%vLnt%-1)","i>=0","-1")<#>
<var_oper>(vChar,"%_vClpText%",STR_GET_CHAR,"%i%","","")<#>
<if_str>("%vChar%==%_vKeySpace%")<#>
<for_break><#>
<endif><#>
<for_end><#>If space was found then go to this position
<if>("%i%>=0")<#>
<end><#>
<for>("s=0","s<EXPR(%vLnt%-%i%-1)","1")<#>
<left><#>
<for_end><#>Now copy the next three characters to clipboard
<shift><#>
<right><#>
<right><#>
<right><#>
<shift><#>
<clp_copyselected>(0,10)<#>
<else><#>
<clpempty><#>
<endif>
The macro was created and tested in version 8.2.5.

Post Reply