AutoHotkey Community

It is currently May 27th, 2012, 12:28 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: June 15th, 2005, 9:10 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
I will explain what I mean.
At first I must say that I seen the same problem on my own home PC (XP Pro - AHK 1.0.35.10) and on my PC at work (NT4 rev 6 & AHK 1.0.35.10)

Is use the following code to test on XP and almost the same on NT :

Code:
#k::
   clipboard =
   Send ^a^x
   ClipWait

   Send ^v

   Klip = %clipboard%

   Send, %klip%

   return

This is, on XP, both the code used to test and the text to be copied, in a notepad window.

As far at this point :
Code:
#k::
   clipboard =
   Send ^a^x
   ClipWait

   Send ^v

there is no problem.

But after,
Code:
   Klip = %clipboard%

   Send, %klip%

there is a problem witch is VERY annoying for me (as I use AHK in my professionnal environnement), is that as the copy in notepad using ^c is (almost) immediate, the copy of the clipboard content in a notepad window by "Send"ing a variable content in witch there is the clipboard contents (Send, %klip%) is done at least line by line, even character by character.

What I mean is that it is VERY SLOW. I can see each letter sended, and if not at least each line...

So "^v" is immediate and "Send, %klip%" is done at the turtle speed !!!

I don't know if it's a normal behavior, but I don't think so. I don't know if it is a clipboard problem (but I don't think so), or a variable and/or Send command problem. As "Send ^v" works perfecly, perhaps it is a variable problem ???

Chris, what must I do (can you do) to solve this problem ?

I want to use a variable because I want to preserve the content of the clipboard, before the use of each hotkey/hotstring I use in my programm witch use the clipboard (a lot off !!!) and put it back at the end of each command.

Thanks for your reply by advance.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 15th, 2005, 10:58 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nemroth wrote:
So "^v" is immediate and "Send, %klip%" is done at the turtle speed !!!
You can increase the rate at which characters are sent:

SetKeyDelay 0 ; Very fast if CPU is not maxed.
SetKeyDelay -1 ; Fastest.
SetKeyDelay -1, 0 ; Alternate method which might improve reliability for some apps.

If the target control is an Edit control, you can also try using Control, EditPaste, String, Edit1, WinTitle ; Replace Edit1 with Edit2 or higher, if needed.

Quote:
I want to use a variable because I want to preserve the content of the clipboard, before the use of each hotkey/hotstring
If you ever need to back up and restore the contents of the clipboard (including any pictures and formatting it contains), you can use the ClipboardAll variable.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2005, 5:28 am 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
Thanks for your reply, Chris
I have to say :
At first I forgot to say that at work (NT4) I use "SetKeyDelay -1" and the result is what I said.
I will try SetKeyDelay -1, 0 wiith notepad & Word.

I didn't think of Control & ClipboardAll and thanks I will try them.

But I think the major problem (for my point of view) and the reason for witch I posted in the "Bug Reports" forum, is that for "Send ^v" the result is fast/immediate and for "Send %klip%" (so send a variable) the result is (very) slow.
This is the same string witch is send
This is the same command witch is used
The only difference is that in one case it's the clipboard content witch is send and in the other a variable. So is it a normal behavior that this only difference make (without SetKeyDelay on XP and even with it on NT4) a such different speed of treatment ? So may be it is a bug, or may be I'm wrong about that.

I didn't used SetKeyDelay at home and it's true that the result in terms of speed is very fast. But the problem seems to remain on NT. I will try at work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2005, 1:30 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nemroth wrote:
...at work (NT4) I use "SetKeyDelay -1" and the result is what I said.
If keystrokes on NT4 are sent slowly even to Notepad, I'm not sure anything can be done about it.

Quote:
But I think the major problem ... is that for "Send ^v" the result is fast/immediate and for "Send %klip%" ... the result is (very) slow.
This is normal behavior. The reason Control-V is so much faster is that the application receives it as a single keystroke, decides that it means "get clipboard contents and paste them", and acts upon it immediately.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2005, 5:06 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
Chris wrote:
If keystrokes on NT4 are sent slowly even to Notepad, I'm not sure anything can be done about it.

A little explanation : Send abc or Send {F4} and so on are fast on NT. It's just Send %variable% witch is slow (so send a variable content). If I assign the variable content to the clipboard and past it, it's OK for the speed...

Chris wrote:
This is normal behavior. The reason Control-V is so much faster is that the application receives it as a single keystroke, decides that it means "get clipboard contents and paste them", and acts upon it immediately.


Thanks for the explanation. I didn't understand why the difference as the clipboard and the varaible had the same content. I follow your advice. before an hotkey/hotstring involving the use of the clipboard, I use ClipboardAll to save and then restore it and between I use ^c ^x and ^v witch are faster than Send %variable%...

Thanks again for your explanations.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2005, 8:00 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nemroth wrote:
Send abc or Send {F4} and so on are fast on NT. It's just Send %variable% witch is slow (so send a variable content).
Please test the following on NT4. I think you'll find the speed to be the same (if not, that would be very surprising and might be a bug):

Send 012345678901234567890123456789{enter}
Var = 012345678901234567890123456789{enter}
Send %Var%

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2005, 11:34 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
OK Chris I will try but I think the main difference is with large contents, not only one line.

To automate operations for my IBM 3270 Mainframe Windows emulator, I copy very often and at repeated times screens witch are 24 lines by 80 col (to verify if I am on the good screen, if the screen has changed, if there is a sentence in the screen or not and so on). I can need to send a screen content to notepad or Word, so Send ^v and Send %ScreenVar% sends a screen of 24 lines by 80 col. With ^v it's immediate, but with Send %ScreenVar% (in witch I copy the clipboard content), I can see the lines sended one by one, even with SetKeyDelay -1 on my NT machine.

I will say you if with only one line I can see a difference.

Thanks forf your very good work on AHK and of course for your time...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2005, 12:39 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
I was a little sick this morning and I thus did not go to work, but at home on XP I tried this (between {} are comments so not in the code... As I use at work a screen of 24 line of 80 cols, I tested this)
Code:
#l::
   clipboard = 01234567890123456789012345678901234567890123456789012345678901234567890123456789`n 
{22 other same lines}
01234567890123456789012345678901234567890123456789012345678901234567890123456789`n
   Send ^v{Enter 3}
   Send 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
{22 other same lines}
01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter 3}
   Var = 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
{22 other same lines}
01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter 3}
   Send %var%
   return


and the result is :
Code:
01234567890123456789012345678901234567890123456789012345678901234567890123456789
24 times


01234567890123456789012345678901234567890123456789012345678901234567890123456789
24 times


01234567890123456789012345678901234567890123456789012345678901234567890123456789
8 times plus
0123456789012345678901234567890123456789012345678901234567890123456789012

So for Send %Var% only 712 characters : 8 lines or 80 chars + 1 line of 72 chars in place of 1920 chars (24 lnes of 80 chars).
May be a bug I didn't suspect to find ???
I tried multiple times and the result is always the same.

For the speed question, you're absolutly right (I was wrong) :
^v : quasi immediate
Send & Send %var% : same speed. Can see the send char by char and more quick with "SetKeyDelay -1. 0" than without...
I'll try on NT on monday and will say you if there is a difference.

Edit : I tried :
Code:
#l::
   clipboard =  01234567890...
   Send ^v{Enter 3}
   Var = 01234567890...
   Send %var%
   Send 0123456789...
   return

and all the characters was sent. If it helps...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2005, 1:35 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I tried the script as written above but couldn't reproduce that behavior. I also ran the following simplified version:
Code:
#a::  ; Win+A hotkey.
X = 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
Var =
Loop, 24
   Var = %Var%%X%
SetKeyDelay -1
Send %var%
return

Double check that there are no hidden characters embedded in your script file. You can also try the above script if you want.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2005, 6:26 am 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
Hi Chris, I tried a many times and for me the results are :
I can do as many Send ^v I want it's always OK
With only one of :
Code:
   Send 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
{22 other same lines}
01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter 3}
or
Code:
Var = 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
{22 other same lines}
01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter 3}
   Send %var%
or
Code:
X = 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
Var =
Loop, 24
   Var = %Var%%X%
SetKeyDelay -1
Send %var%
There is no problem.
But with 2,3 or more of one of the 3 possibilities above, there are problems : the results for me in notepad or word are alway truncated. Not all the characters to send are sent (or received).
So please try
Code:
X = 01234567890123456789012345678901234567890123456789012345678901234567890123456789{Enter}
SetKeyDelay -1
Loop, 6
   {
   Var =
   Loop, 24
      Var = %Var%%X%
   Send %var%{Enter}
   }
to see if the result is truncated for you too

Thanks for your time.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2005, 1:28 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Nemroth wrote:
So please try [last script above] to see if the result is truncated for you too
I ran it and it produces 6 identical sections of 24 lines each. However, the script I ran consists only of the very last one you posted, with nothing else in it.

This might be a PC-specific problem, perhaps interference from some other software. Perhaps you could try it on a differnet PC (or maybe someone else wouldn't mind testing it).

This could still be a bug, so thanks for your continued testing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2005, 5:17 am 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
I will try at work on monday and say back to you if I have the same problem. Thanks for the time you spent in testing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2005, 5:11 pm 
Offline

Joined: September 7th, 2004, 9:20 pm
Posts: 275
Location: France
I tried at work on NT4 and on a Windows 98 computer. On twice PCs, the 6 lines are displayed correctly. It seem to be in fact a problem with my own PC.
Thanks for the time you spent, Chris.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2005, 5:02 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Here are the results I get. The last few lines are different each time and sometimes it gets to the 4th set.
Quote:
... (last block only)...
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123789
0123456789012345678901234567890190123456789012345678901234567890123456789
01234567890123456789012345678901234567890123456789012345678901234012301234567890123456789012345678901234567890123456789012345678901234567890123456789
012345678901234567890123456789012345678901234567890123456789012345678456789
01234567890123456789012345601256789012345678901234567890123456789012345678901234567845678901234567890123456789012345


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2005, 12:57 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The results might depend on the nature of the target window and the rate at which keystrokes are sent.
Reliability might be improved by reducing SetKeyDelay. If that doesn't help -- and if sending keystrokes
to a simple Edit control such as Notepad is also unreliable -- I can try to look into it further.

Thanks for testing it.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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