Jump to content
  • Sign Up
Sign in to follow this  
enbmule

Problem with Keys command executing twice

Recommended Posts

This is driving me nuts.  Pretty simple, straight-forward code.  I want to execute a few actions when I hit the F5 key like click a target and then a keypress that is a hotkey that executes a skill. 

 

For some reason though, when I hit F5, it executes the keypress twice.  it winds up enabling the skill and then immediately disables it because the hotkey is being pressed twice. 

 

Stripped it down to the essentials...

Constants
  TriggerF5=116             // F5
End

CommandDelay 250

// Procedure to Join Formation
Procedure JoinFormation When {GlobalKeys} Contains $TriggerF5
  MousePos 50, 50
  Delay 500
  LeftClick
  Delay 1000
  Keys 4
  Delay 1000
  TimeStamp The hotkey was pressed.
End  // Procedure

// Executes Global Key Presses
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages
  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys
  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End
Here is the Test Log data,  It will be one of these two results for every key press...
DELAY: 300
DELAY: 300
DELAY: 1000
Keys: 4
4
DELAY: 1000
TimeStamp: 05/14/2019 04:03:04:889 am - Join Group hotkey pressed.
or...
DELAY: 300
DELAY: 300
DELAY: 1000
Keys: 44
DELAY: 1000
TimeStamp: 05/14/2019 04:03:04:889 am - Join Group hotkey pressed.

What am I doing wrong? 

 

For now, I have it just use MousePos and click the actionbar.  However, I'd rather use a keypress for certain skills that have keybinds and free up the actionbar slots for something else.  

Share this post


Link to post
Share on other sites

This is driving me nuts.  Pretty simple, straight-forward code.  I want to execute a few actions when I hit the F5 key like click a target and then a keypress that is a hotkey that executes a skill. 

 

For some reason though, when I hit F5, it executes the keypress twice.  it winds up enabling the skill and then immediately disables it because the hotkey is being pressed twice. 

 

Stripped it down to the essentials...

Constants
  TriggerF5=116             // F5
End

CommandDelay 250

// Procedure to Join Formation
Procedure JoinFormation When {GlobalKeys} Contains $TriggerF5
  MousePos 50, 50
  Delay 500
  LeftClick
  Delay 1000
  Keys 4
  Delay 1000
  TimeStamp The hotkey was pressed.
End  // Procedure

// Executes Global Key Presses
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages
  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys
  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End
Here is the Test Log data,  It will be one of these two results for every key press...

DELAY: 300
DELAY: 300
DELAY: 1000
Keys: 4
4
DELAY: 1000
TimeStamp: 05/14/2019 04:03:04:889 am - Join Group hotkey pressed.
or...

DELAY: 300
DELAY: 300
DELAY: 1000
Keys: 44
DELAY: 1000
TimeStamp: 05/14/2019 04:03:04:889 am - Join Group hotkey pressed.

What am I doing wrong? 

 

For now, I have it just use MousePos and click the actionbar.  However, I'd rather use a keypress for certain skills that have keybinds and free up the actionbar slots for something else.  

 

 

After running your code as is. And pressing the F5 key multiple times each test run. This is what i get in the Test Log when I run your code:

DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
MouseMove 50, 50
DELAY: 500
Mouse Left Click
ChangeWindowEvent In: 6227662
ChangeWindowEvent Out: 6227662
DELAY: 1000
Keys: 4
DELAY: 1000
TimeStamp: 05/14/2019 06:35:08:573 am - The hotkey was pressed.
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
ChangeWindowEvent In: 198036
ChangeWindowEvent Out: 198036
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
MouseMove 50, 50
DELAY: 500
Mouse Left Click
ChangeWindowEvent In: 6227662
ChangeWindowEvent Out: 6227662
DELAY: 1000
Keys: 4
DELAY: 1000
ChangeWindowEvent In: 198036
ChangeWindowEvent Out: 198036
TimeStamp: 05/14/2019 06:35:18:445 am - The hotkey was pressed.
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300

So, I am assuming that there must be something going on on your end.

 

Ego, test this bit of code and see if you to see what happens for you.

Share this post


Link to post
Share on other sites

Weird... it ran fine on the first try today. 

 

Try running this.  I commented out the mouse move and left click and saved it.  Ran it again and it had the same results as last night.

Constants
  TriggerF5=116             // F5
End

CommandDelay 300

// Procedure to set Pipe Formation
Procedure JoinFormation When {GlobalKeys} Contains $TriggerF5   
  //MousePos 50, 50
  //Delay 500
  //LeftClick
  Delay 1000
  Keys 4
  Delay 1000
  TimeStamp The hotkey was pressed.
End  // Procedure

// Executes Global Key Presses
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages
  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys
  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End 

I'll try and post a video of it happening so you see that I'm not going crazy.

Share this post


Link to post
Share on other sites

I'm just getting

 

TimeStamp The hotkey was pressed.

 

nothing else

Share this post


Link to post
Share on other sites

Did you turn on Run AC with Test Log?    :)

 

 

Found something weird Wabbit... In AC, if I hit F5 while the Commands and Macro, Performance or Debug tabs are active, it will work properly.  You'll see just one 4 printed out in the Test Log.  Now if I have the Test Log tab active and hit F5, multiple 4s will be generated in the Test Log.  

Constants
  TriggerF5=116             // F5
End

CommandDelay 300

// Procedure to set Pipe Formation
Procedure JoinFormation When {GlobalKeys} Contains $TriggerF5   
  //MousePos 50, 50
  //Delay 500
  //LeftClick
  Delay 1000
  Keys 4
  Delay 1000
  TimeStamp The hotkey was pressed.
End  // Procedure

// Executes Global Key Presses
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages
  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys
  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End 

I took a new video showing it.  Ignore the creepy breathing in background.  It's the dog sleeping lol.  

 

 

https://imgur.com/ZH8v4GH

 

 

 

So whatever condition that causes the keypress to fire twice while the Test Log tab is active, is also happening while the game is running.  That's with running the code with just a delay, keys and another delay. 

 

For some reason, adding in the mousepos and left click at the beginning of the procedure, keeps it from happening at all.

Share this post


Link to post
Share on other sites

TimeStamp: 05/15/2019 04:46:12:723 pm - The hotkey was pressed.

TimeStamp: 05/15/2019 04:46:17:935 pm - The hotkey was pressed.

TimeStamp: 05/15/2019 04:46:22:243 pm - The hotkey was pressed.

It did go top left on screen at 50, 50

Share this post


Link to post
Share on other sites

Okay, watching your vids I see what you are talking about. And I am able to see the same thing happen on my end.

 

But, here is the problem. There is nothing wrong with your code or in AC Tool when executing your code.

 

When you press the F5 key, the script will send to the currently Active Window the pressing of the 4 key. Since you do not have a SetActiveWindow command to direct all key/mouse/Color/Object commands towards. It will send the pressing of the 4 key to its self. But, the 4 will only will show up when viewing the Test Log tab. (That is because the View Log tab's Edit box is not set for read only. So, things can be written to it. And yes this is a bug. If the Edit Box in the View Log tab was set to be readonly the second number 4 would not show up.)

 

Try opening a Notepad with a new document. Then set a SetActiveWindow for that Notepad instance in your script in the JoinFormation procedure before any statements you have there.  Then run your script. You will now see that Notepad will become the active window and that the number 4 will show up there when ever you press the F5 key, and not in AC Tool. Even if you are viewing the Test Log.

 

So, in the future make sure that you have a SetActiveWindow to make active the window that AC Tool will be working with and send everything to.

Share this post


Link to post
Share on other sites

Unfortunately I do use SetActiveWindow.  Here's the exact code Im using...

// This is the Join Formation sub-macro for the Slave computer 
// -----------------------------------------------------------------------


// Main Procedure
// -----------------------------------------------------------------------
Procedure SubJoinFormation
	// Join Formation Routine for Ws Window
	IsWindow Earth & Beyond - $AvatarWs
		SetActiveWindow Earth & Beyond - $AvatarWs
		Delay 800
		Keys 0    
		Delay 1500
	End	

	// Join Formation Routine for Es Window
	IsWindow Earth & Beyond - $AvatarEs
		SetActiveWindow Earth & Beyond - $AvatarEs
		Delay 800
		Keys 0    
		Delay 1500
	End	

	// Join Formation Routine for Ts Window
	IsWindow Earth & Beyond - $AvatarTs
		SetActiveWindow Earth & Beyond - $AvatarTs
		Delay 800
		Keys 0    
		Delay 1500
	End		

	// Join Formation Routine for JE Window
	IsWindow Earth & Beyond - $AvatarJEs
		SetActiveWindow Earth & Beyond - $AvatarJEs
		Delay 800
		Keys 0    
		Delay 1500
	End	

	// Join Formation Routine for TT Window
	IsWindow Earth & Beyond - $AvatarTTs
		SetActiveWindow Earth & Beyond - $AvatarTTs
		Delay 800
		Keys 0    
		Delay 800
	End	
	
	SetActiveWindow Earth & Beyond - $AvatarWs
	Delay 500
End

It's called from this code in the main file...

// Procedure to have Alts Join the Formation
Procedure JoinFormation When {GlobalKeys} Contains $TriggerF5   
  Call SubJoinFormation
End  // Procedure

I even tried just a single instance of the game without it's application title being renamed, no IsWindow check and running from it's own file and it still happens.

// This is the Join Formation sub-macro for the Slave computer 
// -----------------------------------------------------------------------
Constants	
  TriggerF5=116             // F5 
End

// Main Procedure
// -----------------------------------------------------------------------
Procedure SubJoinFormation When {GlobalKeys} Contains $TriggerF5
	SetActiveWindow Earth & Beyond
	Delay 800
	Keys 0    
	Delay 800
End	

// Executes Global Key Presses
// ---------------------------------------------------------------------------
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End

For each one, It joins the formation and then leaves the formation because it fires twice.   

 

I've tried everything I could think of.  I've played with longer delays, adding in a CommandDelay at the beginning. adding in ClearGlobalKeys at the beginning or end of each IsWindow or at the beginning of the Procedure.  I've tried KeyDown, KeyRate.   Nothing I've tried keeps it from firing twice.

Share this post


Link to post
Share on other sites

Unfortunately I do use SetActiveWindow.  Here's the exact code Im using...

// This is the Join Formation sub-macro for the Slave computer 
// -----------------------------------------------------------------------


// Main Procedure
// -----------------------------------------------------------------------
Procedure SubJoinFormation
	// Join Formation Routine for Ws Window
	IsWindow Earth & Beyond - $AvatarWs
		SetActiveWindow Earth & Beyond - $AvatarWs
		Delay 800
		Keys 0    
		Delay 1500
	End	

	// Join Formation Routine for Es Window
	IsWindow Earth & Beyond - $AvatarEs
		SetActiveWindow Earth & Beyond - $AvatarEs
		Delay 800
		Keys 0    
		Delay 1500
	End	

	// Join Formation Routine for Ts Window
	IsWindow Earth & Beyond - $AvatarTs
		SetActiveWindow Earth & Beyond - $AvatarTs
		Delay 800
		Keys 0    
		Delay 1500
	End		

	// Join Formation Routine for JE Window
	IsWindow Earth & Beyond - $AvatarJEs
		SetActiveWindow Earth & Beyond - $AvatarJEs
		Delay 800
		Keys 0    
		Delay 1500
	End	

	// Join Formation Routine for TT Window
	IsWindow Earth & Beyond - $AvatarTTs
		SetActiveWindow Earth & Beyond - $AvatarTTs
		Delay 800
		Keys 0    
		Delay 800
	End	
	
	SetActiveWindow Earth & Beyond - $AvatarWs
	Delay 500
End

It's called from this code in the main file...

// Procedure to have Alts Join the Formation
Procedure JoinFormation When {GlobalKeys} Contains $TriggerF5   
  Call SubJoinFormation
End  // Procedure

I even tried just a single instance of the game without it's application title being renamed, no IsWindow check and running from it's own file and it still happens.

// This is the Join Formation sub-macro for the Slave computer 
// -----------------------------------------------------------------------
Constants	
  TriggerF5=116             // F5 
End

// Main Procedure
// -----------------------------------------------------------------------
Procedure SubJoinFormation When {GlobalKeys} Contains $TriggerF5
	SetActiveWindow Earth & Beyond
	Delay 800
	Keys 0    
	Delay 800
End	

// Executes Global Key Presses
// ---------------------------------------------------------------------------
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End

For each one, It joins the formation and then leaves the formation because it fires twice.   

 

I've tried everything I could think of.  I've played with longer delays, adding in a CommandDelay at the beginning. adding in ClearGlobalKeys at the beginning or end of each IsWindow or at the beginning of the Procedure.  I've tried KeyDown, KeyRate.   Nothing I've tried keeps it from firing twice.

 

This is completely different code from the script you have initially posted. And that code there is nothing wrong. And the Test log supports that. The Test log shows that it is executing the command Keys 4, and if you happen to viewing the log at that time the 4 shows up in the test log.

 

So, does the test log show that AC Tool is executing the Keys 0, in the current shown script, twice, or just once, for each open game client? Have you tried actually tested the current script with using a Notepad document, and see how many times 0 shows up? Based on your current script the Notepad document should have 10 0's, instead of the 5, if it is being executed twice.

Share this post


Link to post
Share on other sites

After taking your newest test code, changing the setactivewindow to use a Notepad document, and running it. This is what my Test Log shows:

ChangeWindowEvent In: 198424
ChangeWindowEvent Out: 198424
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
SetActiveWindow Untitled - Notepad
DELAY: 800
Keys: 0
DELAY: 800
ChangeWindowEvent In: 198424
ChangeWindowEvent Out: 198424
DELAY: 300
DELAY: 300
DELAY: 300
SetActiveWindow Untitled - Notepad
DELAY: 800
Keys: 0
DELAY: 800
DELAY: 300
ChangeWindowEvent In: 198424
ChangeWindowEvent Out: 198424
DELAY: 300
DELAY: 300
SetActiveWindow Untitled - Notepad
DELAY: 800
Keys: 0
DELAY: 800
ChangeWindowEvent In: 198612
ChangeWindowEvent Out: 198612
DELAY: 300
DELAY: 300
DELAY: 300
DELAY: 300
ChangeWindowEvent In: 198424
ChangeWindowEvent Out: 198424
DELAY: 300
DELAY: 300
DELAY: 300

I pressed the F5 key 3 times. For each time i pressed the F5 key the log shows that it changed to the Notepad 3 times and only executed the Keys 0 statement once for each pressing of the F5 key. There is not additional 0 showing up in the log. And my empty Document in Notepad only has 3 0's in it. So, I am not seeing, by the log or 0's showing up in Notepad, that AC Tool is executing the Keys 0 statment, or even sending the 0, twice.

 

Here is the code as I have tested it:

// This is the Join Formation sub-macro for the Slave computer
// -----------------------------------------------------------------------
Constants    
  TriggerF5=116             // F5
End

// Main Procedure
// -----------------------------------------------------------------------
Procedure SubJoinFormation When {GlobalKeys} Contains $TriggerF5
    SetActiveWindow Untitled - Notepad

    Delay 800
    Keys 0    
    Delay 800
End    

// Executes Global Key Presses
// ---------------------------------------------------------------------------
While 1 = 1
  //Check for special procedures like the one above...see Procedure under help
  ProcessMessages  
  //Clear so the procedure does not keep on firing unless a key is pressed
  ClearGlobalKeys  
  //Always keep some delay on uncontrolled infinite loops
  Delay 300
End

When I changed the code to use your Join Formation code, again using Notepad to receive the 0's, I get the same results. Pressing the F5 key shows in the Test Log that Keys 0 is executed 5 times, once per window without any additional 0's show up in the log, and i have only 5 0's in Notepad.

 

Since I do not have multiple accounts with toons to be able to create a formation. I am unable to test your actual code within the game. But, since my test log, and the number of 0's showing up in Notepad, shows that the Keys 0 statement is not being executed twice. Then it should be working fine on your end.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...