Author Topic: sendkey up arrow using variable for number of keystrokes with sendkey arrow up  (Read 74 times)

guile

  • Newbie
  • *
  • Posts: 6
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

  • Tech Support
  • *****
  • Posts: 3194
    • WinBatch
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.
 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

guile

  • Newbie
  • *
  • Posts: 6
thank you