All Things WinBatch > Customer Service

sendkey up arrow using variable for number of keystrokes with sendkey arrow up


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.


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:'}'
You can find more information about string concatenation, variable substitution, string literals, and variables in the Consolidated WIL Help file.

thank you


[0] Message Index

Go to full version