WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: pguild on January 18, 2026, 01:07:33 PM

Title: sendkey("{DEL}) doesn't work.
Post by: pguild on January 18, 2026, 01:07:33 PM
;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
 
Title: Re: sendkey("{DEL}) doesn't work.
Post by: pguild on January 18, 2026, 02:26:01 PM
The problem was this line:
   display( 5, "DELETE","Will delete timestamp in 5")
when I removed that line DELETE worked.
Title: Re: sendkey("{DEL}) doesn't work.
Post by: JTaylor on January 19, 2026, 06:49:29 AM
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