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

Started by guile, January 23, 2020, 12:07:10 PM

Previous topic - Next topic

guile

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.

:'(

td

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) Select
numberofupkeystrokes = 10
SendKey('{UP %numberofupkeystrokes%}')


Or construct a string literal using a variable and concatenation:

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


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

Code (winbatch) Select
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.
 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade