AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hotkeys interfering with mouse movement, and beeping

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Jaegan



Joined: 12 Jul 2006
Posts: 20
Location: California

PostPosted: Sun Mar 04, 2007 8:46 am    Post subject: Hotkeys interfering with mouse movement, and beeping Reply with quote

While doing some scripting I ran into a couple of strange errors, mostly relating to mouse movement.

1. The idea behind this script is to hold down the right mouse button, and have this simulate the continous pressing of the left mouse button.

Code:
Process, priority, , High  ; Have the script set itself to high priority
#InstallMouseHook
#SingleInstance force
#InstallKeybdHook
#UseHook On
SetBatchLines 10ms
#HotString SP
#MaxThreads 20
CoordMode, mouse, Screen
SetKeyDelay, 10, 0, Play
SetMouseDelay, 10 , Play

*Rbutton::
{
loop
   {
   getkeystate, state, RButton, P
   If state = U
      Break
   send, {LButton}
      Sleep, 10     
      }
}


However, when the right key is depressed, it slows the movement of the mouse. To test this, move the cursor to the far left side of your screen and move your mouse to the far left of your mousepad. Depress the right mouse button, and drag the cursor to the right edge of the screen. Release the right mouse button, and move the cursor the left side of the screen. You will notice that your cursor reached the end of the screen before your mouse returned to the left edge of the mouse pad.

It seems that the frequency of the left click determines how much the mouse movement is delayed. With a sleep of 100, the delay is barely noticeable. With a delay of 10, it appears to slow the mouse movement rate by 15-20%.

Another odd note is that adding an additional item to the keystate up slows down the movement even more. Adding a [Shift Up] before the break makes a noticeable difference in the overall speed.

2. The idea behind this script to hold down Capslock to have it emulate the pressing of Control and Shift. This script also faced the same problem stated above.

Code:
Process, priority, , High  ; Have the script set itself to high priority
#InstallMouseHook
#SingleInstance force
#InstallKeybdHook
#UseHook On
SetBatchLines 10ms
#HotString SP
#MaxThreads 20
CoordMode, mouse, Screen
SetKeyDelay, 10, 0, Play
SetMouseDelay, 10 , Play
*Capslock::SendPlay, {LControl Down}{LShift Down}
*Capslock Up::SendPlay, {LControl Up}{LShift Up}


This also caused some system delay and temporary inability to press other keys. Changing it to Send stopped this latter problem, but not the mouse delay.

3. Finally, with regards to the above script, (after being changed to Send,) I received a strange beeping sound while using it. This occured when the capslock key was depressed, as well as W, E, and F. In addition, the W key would not fire while Capslock and E were depressed.

I was unable to eliminate the first two problems, and I believe that continuously firing a script might be resulting in a mouse delay. It seems this only applies to scripts that have both an Up and Down modifier. In the above script I also have the line

Code:
Lwin:Lctrl


Holding down Lwin caused no delay whatsoever.

As for the last problem, I have no clue what the source could be. If you have any suggestions on how to fix these problems, please let me know.

-Jaegan
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sun Mar 04, 2007 3:15 pm    Post subject: Reply with quote

I've reviewed your examples and tried the first one. I can see that the mouse seems to slow down slightly while frequent left-clicks are being sent.

However, I don't see anything obvious in the AutoHotkey code that might explain this (AutoHotkey simply calls the WinAPI to send keystrokes and mouse clicks; nothing fancy). Perhaps the mouse hook slows down the mouse during heavy clicking; but even if so, the only way to avoid it would be to avoid the mouse hook, which would defeat the purpose of your script (though maybe you could poll the mouse via GetKeyState to avoid using the mouse hook).

As for the other problems, I think they are probably just due to OS limitations with regard to keyboard and mouse handling. After all, the OS is designed and optimized to handle human input, not artificial input that overlaps fast clicking and keystrokes.

Also, don't forget that whenever you hold down a key on the keyboard, it begins to auto-repeat. These repeated keystrokes can interfere with artificial keystrokes being sent by the Send command. They might also interfere with mouse clicking. And as far as I know, the only way to stop a key from auto-repeating is to physically press some other key (the Send command is not enough).
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group