AutoHotkey Community

It is currently May 27th, 2012, 3:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: October 25th, 2005, 6:22 am 
Offline

Joined: October 25th, 2005, 6:11 am
Posts: 8
Maybe I am missing something - I am new to hotkey - but I have a problem if I am busy typing away, and use one of my hotstrings. What happens is that the auto-replace characters get mixed in with anyrhing I type right AFTER the hotstring. Shouldn't autohotkey hold the new incoming key strokes until it is done with the autoreplace? Is there some way to make it do this?

For example - take this hotstring:
::dont::don't
If I type "d-o-n-t g-o" fast, I get mixed characters like "don' gto". It only happens if I am typing fast - but it happens often enough to be annoying.

Maybe I just type too fast?? <grin>

Thanks
Dan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 12:31 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Please test if SetBatchLines or SetKeyDelay have any positive influence. Just a guess.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 12:35 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
You can also test
Code:
:K-1:dont::don't

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 1:59 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Yes, Toralf's key-delay suggestion above is good for these cases. You can put it into effect for all hotstrings by putting the following line above them: #Hotstring k-1

Another thing you might try is raising the script's priority:
Process, Priority,, High
This allows the script to send keystrokes faster in many cases, or at least capitalize on the target window's keyboard buffer so that your own keystrokes won't get mixed in with those of the hotstring.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 3:59 pm 
Offline

Joined: October 25th, 2005, 6:11 am
Posts: 8
Thanks for all the suggestions. There is a lot ot learn about Autohotkey. I had read about keydelay, but was confused originally about K0 vs K-1 - what was "the smallest possible delay"? Sounded like some Zen concept - or maybe quantum physics. Now, it seems obvious - I think once I found the longer explanation under SetKeyDelay.

Dan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 4:22 pm 
Offline

Joined: October 25th, 2005, 6:11 am
Posts: 8
Well, K-1 and Setbatchlines -1 did not seem to help, but setting the script process to high priority looks like it works - I have not been able to beat it yet!

Thanks again.

Dan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 4:42 pm 
Offline

Joined: October 25th, 2005, 6:11 am
Posts: 8
Well, I spoke too soon. None of those really prevent the situation.

Just to test it, create this script:

:*:xxx::
Process, Priority,,High
Setbatchlines -1
setkeydelay -1
send yyyyyyy
return

Then hold down the x key. You should get a string of y's. You actually get varying numbers of y's with x's mixed in. I tried it with different combinations of the suggested options.

It just seems like there ought to be an explicit function in Autohotkey that says hold new keystrokes until the script is done SENDING keystrokes.

Still, it's a great utility!

Dan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 5:35 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Could you please test this?
Code:
#Persistent
Process, Priority,,High
Setbatchlines -1
setkeydelay -1
return

:*K-1:xxx::yyyyyyy

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 9:35 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
you can try too :
Code:
::dont::
BlockInput, on
Send, don't
BlockInput, off
Return

(not tested)
But during the execution of the Send command, what you type on keyboard is totally ignored and not recorded...
Hope it helps

@ Chris : May be a new option to the BlockInput command ?
Code:
BlockInput, on, Remember var

During the BlockInput command, the keyboard input is recorded in the "var" variable and so can be send after if needed ???


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 11:49 pm 
Offline

Joined: October 25th, 2005, 6:11 am
Posts: 8
toralf wrote:
Could you please test this?


Well, it still fails if you just hold down the x key. I could not get it to fail by typing x's real fast, so it maybe good enough for normal typing - I will have to test that over the next few days.

Thanks.
Dan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 11:53 pm 
Offline

Joined: October 25th, 2005, 6:11 am
Posts: 8
Nemroth wrote:
May be a new option to the BlockInput command ?
Code:
BlockInput, on, Remember var

During the BlockInput command, the keyboard input is recorded in the "var" variable and so can be send after if needed ???


BLOCKINPUT is a close fit to what I need, but I don't really want to lose the keystrokes ...

Thanks for the suggestion, tho - AHK is really a rich programming environment, and its hard for a newbie to catch all the subtleties, let alone learn all the commands.

Dan


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 26th, 2005, 1:55 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nemroth wrote:
May be a new option to the BlockInput command ? ... the keyboard input is recorded in the "var" variable and so can be send after if needed ???
It's an interesting idea. I've made a note to research it more.

By the way, I tested Toralf's variation above and it worked okay on my system even when holding down the X key. Therefore, the ability of hotstrings "to keep up" is probably sensitive to CPU speed and the load on the CPU from other applications. This is aggravated by the fact that simulating keystrokes by means of the OS's build-in keybd_event() function is a high overhead operation (keybd_event apparently uses a lot of CPU time).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 26th, 2005, 8:52 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
Chris wrote:
It's an interesting idea. I've made a note to research it more.

Thanks Chris.

I think there is an other possibility. May be you can use the clipboard !!! It is not the best solution in all the situations, but it can be an interesting alternative (with the help of the AHK help file...) :
Code:
::dont::
ClipSaved := ClipboardAll   ; Save the entire clipboard to a variable of your choice.
clipboard  = don't
Send, ^v
Clipboard := ClipSaved   ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved =
Return
** not tested **

As when you copy the clipboard, Windows think it's the send of only one key, it can be sufficent to be able to send your text and to see what you type to be added after the string copied rather than "inserted" between the characters copied.

May you can use too the continuation sections if you have a long text to send, like :
Code:
::dont::
ClipSaved := ClipboardAll   ; Save the entire clipboard to a variable of your choice.
clipboard  =
(Join`r`n
A line of text.
By default, the hard carriage return (Enter) between the previous line and this one will be written to the file.
   By default, the tab to the left of this line will also be written to the file.
By default, variable references such as %Var% are resolved to the variable's contents.
)
Send, ^v
Clipboard := ClipSaved   ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved =
Return
** not tested **

@ Chris : to come back to my precedent proposal, after re-reading it, I think its looks like ... a key logger capability !!!

May be is it anyway a thing to consider for the future, despite everything, as AHK is already like the butcher's knife : it can do a good steak or it can be in the first page of an evening newspaper !!! It's a (very good !!!) tool, and what it does depends on what the programmer wants it to do... AHK is so powerfull that somebody with bad intentions probably already can use it for bad things ... and in the future somebody that wants to Send a string and then to send the keys typed during the execution of the Send command will can do it...

But we aren't in the wish list forum...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2005, 12:28 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The clipboard approach would be a good solution for anyone who needs to send large amounts of text with a hotstring. Thanks for demonstrating how to do it.

As for how the planned hotstrings improvements will work, I don't think there's any worry because it probably won't take the form of a built-in variable. Instead, the program will do all the buffering of the user's physical keystrokes behind the scenes, or it will use the OS's built-in SendInput() to avoid interruptions while sending the hotstring's text.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2005, 1:17 am 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
(this post was accidentally deleted)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group