sendkey("{DEL}) doesn't work.

Started by pguild, January 18, 2026, 01:07:33 PM

Previous topic - Next topic

pguild

;This code moves cursor down one line, presses HOME key.
;Then highlights 9 characters of text correctly, but fails to delete the ;highlighted text. I am using Windows 11.
   sendkey("{DOWN}")
   sendkey("{HOME}")

   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")

   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")
   SendKey("+{RIGHT}")

   display( 5, "DELETE","Will delete timestamp in 5")
   sendkey("{DEL}")   
   pause("done","yes")
 exit
 
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

pguild

The problem was this line:
   display( 5, "DELETE","Will delete timestamp in 5")
when I removed that line DELETE worked.
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

JTaylor

When you run Display(), it is most likely changing the focus so the {DEL} is not going to the window you want.  You could try a TimeDelay() to give it time to return, assuming it would, or use WinActivate() on the Window you want the {DEL} sent to.  I would recommend the latter as it should be a sure thing.  You might need a TimeDelay() after it as well.

Jim

SMF spam blocked by CleanTalk