BUG: WaitKeyDown

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

BUG: WaitKeyDown

Post by fightcancer » Mon Jun 27, 2022 9:32 pm

WaitKeyDown>VK109
Mdl>Done

MS doesn't wait for anything and immediately executes line 2. (VK109 is the NumPad subtract key.)

EDIT: it works for the first few times as it should, then it won't work any more, i.e. it won't wait but goes straight to line 2. I tested VK109, VK101, VK107 and the backslash key (i.e. "\").

EDIT 2: same issue with all keys.
Last edited by fightcancer on Tue Jun 28, 2022 4:21 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: BUG: WaitKeyDown

Post by JRL » Tue Jun 28, 2022 12:13 pm

Sounds like your key is sticking down.
You don't mention the results with the other keys.

fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

Re: BUG: WaitKeyDown

Post by fightcancer » Tue Jun 28, 2022 4:20 pm

Same issue with all keys.

The keys are not stuck as they produce no keystrokes in Notepad, Discord or other software.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: BUG: WaitKeyDown

Post by Dorian (MJT support) » Tue Jun 28, 2022 5:15 pm

I'm unable to reproduce an issue in v15.0.20 even when looping 25 times. (And there haven't been any changes to WaitKeyDown since Version 7.3.10.5 17 years ago).

Code: Select all

let>x=0
repeat>x
  let>x=x+1
  WaitKeyDown>VK109
  Mdl>Done %x%
Until>x,25

Yes, we have a Custom Scripting Service. Message me or go here

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: BUG: WaitKeyDown

Post by JRL » Tue Jun 28, 2022 5:29 pm

Out of curiosity, Does this script wait until you press the KeyPad's minus key? Or does it run straight to "Done"?

Code: Select all

OnEvent>Key_Down,VK109,0,srtVK109

Let>VK109_wait_Flag=1

Label>VK109IdleLoop
  If>VK109_wait_Flag=1
    Goto>VK109IdleLoop
  EndIf

MDL>Done

SRT>srtVK109
  Let>VK109_wait_Flag=0
END>srtVK109

fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

Re: BUG: WaitKeyDown

Post by fightcancer » Tue Jun 28, 2022 8:00 pm

Dorian (MJT support) wrote:
Tue Jun 28, 2022 5:15 pm
I'm unable to reproduce an issue in v15.0.20 even when looping 25 times. (And there haven't been any changes to WaitKeyDown since Version 7.3.10.5 17 years ago).

Code: Select all

let>x=0
repeat>x
  let>x=x+1
  WaitKeyDown>VK109
  Mdl>Done %x%
Until>x,25

When I run this script below, it breaks the WaitKeyDown functionality so that in both the OP script and the script you shared above, MS ignores WaitKeyDown.

The script below is taken from a much larger macro (about 1240 lines long). I trimmed the lines of code that I imagine are irrelevant leaving only the code below.

Just to be clear, first I run the script below. Then WKD is broken. Then I can run either script above and WKD does absolutely nothing for any key that I've so far tested. Not sure what's going on, or when MS resets so that WKD works again.

Code: Select all

//Bug 2
Let>GW=0.1
GetActiveWindow>wTitle,x,y,w,h
GetWindowHandle>wTitle,wHandle

If>{(%wTitle%="*Untitled - Notepad") OR (%wTitle%="Untitled - Notepad")}
  Let>text=11
  Goto>GotText
EndIf

Label>GotText
If>text=11
  Input>Wtext,World of Tanks: Send which text?%CRLF%1 HILL%CRLF%2 Tryin 2 Improve%CRLF%3 Platoon%CRLF%4 Carry all%CRLF%5 Dead Heroes%CRLF%6 Sorry 4 Kills%CRLF%7 emails%CRLF%8 Spotting%CRLF%9 Sorry 4 sucking!%CRLF%0 "gg" & TheText,8
  If>Wtext=8
    Input>Res,Where?,1
        Length>Res,LenRes
        If>LenRes=0
          Msg>LenRes = %LenRes%.  Ending macro.
          Goto>EndMacro
        EndIf

    Let>TW=0
    Let>myStr=%Res%
    GoSub>ClipBoard,myStr
    GoSub>PasteText

    WaitKeyDown>VK109
    BlockInput>1
    GoSub>ClipBoard,2
    GoSub>PasteText
    BlockInput>0
      Wait>TW

    WaitKeyDown>VK109
    BlockInput>1
    GoSub>ClipBoard,3
    GoSub>PasteText
    BlockInput>0
      Wait>TW

    WaitKeyDown>VK109
    BlockInput>1
    GoSub>ClipBoard,4
    GoSub>PasteText
    BlockInput>0
      Wait>TW

    WaitKeyDown>VK109
    BlockInput>1
    GoSub>ClipBoard,5
    GoSub>PasteText
    BlockInput>0
  EndIf
EndIf

Label>EndMacro

SRT>ClipBoard
/* Put text on the Clipboard (Cb) and verify that it's there.

REQUIREMENTS:
Specify the text to be on the Cb when calling this SRT.  Example: GoSub>ClipBoard,myStr
*/
    //Test the string to make sure it's not 0 length.
    Length>ClipBoard_Var_1,LenStr
    If>LenStr=0
      //The string is 0 length.  End macro.
      Msg>The LenStr string length is %LenStr%.  Ending macro.
      SkipLabel>EndMacro
      Goto>EndClipBoard
    EndIf

  WaitClipBoard
PutClipBoard>ClipBoard_Var_1
  WaitClipBoard
  Wait>0.01
  WaitClipBoard
GetClipBoard>WotCb
  WaitClipBoard

    //Test what's on the Cb.  If it's not what I want, then end the macro.
    If>WotCb<>ClipBoard_Var_1
      //It's not what I want.  End the macro.
      Msg>What's on the Clipboard (WotCb) is not what I want.  Ending macro.%CRLF%%CRLF%WotCb = %WotCb%%CRLF%ClipBoard_Var_1 = %ClipBoard_Var_1%
      SkipLabel>EndMacro
      Goto>EndClipBoard
    EndIf

Label>EndClipBoard

END>ClipBoard

SRT>PasteText
/* Paste text from the Clipboard (Cb) into the chat box in WoT. */
//Open the chat box and paste.
Press ENTER
  Wait>GW
Press CTRL
  Wait>GW
Send>v
  Wait>GW
Release CTRL
  Wait>GW
Press ENTER

END>PasteText
Last edited by fightcancer on Tue Jun 28, 2022 8:04 pm, edited 1 time in total.

fightcancer
Macro Veteran
Posts: 239
Joined: Fri Apr 15, 2005 8:32 am

Re: BUG: WaitKeyDown

Post by fightcancer » Tue Jun 28, 2022 8:02 pm

JRL wrote:
Tue Jun 28, 2022 5:29 pm
Out of curiosity, Does this script wait until you press the KeyPad's minus key? Or does it run straight to "Done"?

Code: Select all

OnEvent>Key_Down,VK109,0,srtVK109

Let>VK109_wait_Flag=1

Label>VK109IdleLoop
  If>VK109_wait_Flag=1
    Goto>VK109IdleLoop
  EndIf

MDL>Done

SRT>srtVK109
  Let>VK109_wait_Flag=0
END>srtVK109
After it's broken, then MS runs straight to "Done."

First I run my script (not Dorian's) in my post immediately above this post. Then WKD magically breaks. Then I can run either my script in the OP or Dorian's script and WKD does absolutely nothing for any key that I've so far tested.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: BUG: WaitKeyDown

Post by JRL » Tue Jun 28, 2022 9:22 pm

If you are running this script at the same time that you are running a game, the "bug" is the game. Games do things to control your computer and peripherals that only the game programmers can explain and they of course will not.

Reboot your computer, do not start any games, run the simple code you first posted or run Dorians code. You are unlikely to have any issues. If you do, I suggest that the game broke your computer.

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: BUG: WaitKeyDown

Post by Grovkillen » Wed Jun 29, 2022 6:21 pm

Not running games in full screen prohibits the game from taking "full control" of the peripherals.
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts