WinBatch Technical Support Forum

All Things WinBatch => Customer Service => Topic started by: guile on January 23, 2020, 12:07:10 pm

Title: sendkey up arrow using variable for number of keystrokes with sendkey arrow up
Post by: guile on January 23, 2020, 12:07:10 pm
Issue with using variable for number of keystrokes with sendkey arrow up function,
Tried every way and searched for hours, need help please.

numberofupkeystrokes = 10

SendKey(`{UP numberofupkeystrokes}`)

SendKey(`{UP 10}`) but need to come from variable.

 :'(
Title: Re: sendkey up arrow using variable for number of keystrokes with sendkey arrow up
Post by: td on January 23, 2020, 01:48:30 pm
Not sure were you searched but this is very basic but important stuff.  You need to understand the difference between variables and string literals and how the difference impacts their usage.  You can use some combination of a string literal and a variable to get what you want but you need to adhere to the language syntax rules for the respective elements.

Use a string literal as a parameter in combination with variable substitution:

Code: Winbatch
numberofupkeystrokes = 10
SendKey('{UP %numberofupkeystrokes%}')
 

Or construct a string literal using a variable and concatenation:

Code: Winbatch
numberofupkeystrokes = 10
SendKey('{UP ':numberofupkeystrokes:'}')
 

Another alternative would be to fill the contents of a variable with your keystroke string:

Code: Winbatch
numberofupkeystrokes = 10
strKeys = '{UP ':numberofupkeystrokes:'}'
SendKey(strKeys)
 

You can find more information about string concatenation, variable substitution, string literals, and variables in the Consolidated WIL Help file.
 
Title: Re: sendkey up arrow using variable for number of keystrokes with sendkey arrow up
Post by: guile on January 23, 2020, 05:53:15 pm
thank you