long text paste Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

long text paste

Post by dostroll » 21 Nov 2021, 12:49

Paste of long text is slow.
"SetKeyDelay, -1" has no effect.
What is the ideas for speed up?

Code: Select all

Critical, On
SetKeyDelay, -1
Send, ^c
ClipWait, 2
Run, ***.exe
Sleep, 100
ControlSend, RICHEDIT50W1, %Clipboard%
Return
Image

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: long text paste  Topic is solved

Post by amateur+ » 21 Nov 2021, 13:06

Maybe this?

Code: Select all

Critical, On
SetKeyDelay, -1
Clipboard := ""
Send, ^c
ClipWait, 2
Run, ***.exe,,,pid
WinWaitActive, ahk_pid %pid%
ControlSend, RICHEDIT50W1, ^v, ahk_pid %pid%
Return
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

Re: long text paste

Post by dostroll » 21 Nov 2021, 20:55

It was a problem that it was simply "^ v" to solve it.
thank you! I learned a lot.

dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

Re: long text paste

Post by dostroll » 21 Nov 2021, 22:34

It is different from the purpose of the thread, but is it better to specify the application PID?

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: long text paste

Post by amateur+ » 21 Nov 2021, 22:51

Glad to help.
Also pay attention to Clipboard := "", otherwise Clipwait won't work if Clipboard was already non-empty.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

Re: long text paste

Post by dostroll » 21 Nov 2021, 23:29

amateur+ wrote: Glad to help.
Also pay attention to Clipboard := "", otherwise Clipwait won't work if Clipboard was already non-empty.
Thank you for your valuable advice!

The clipboard is stored at ^ C.
Do you need to be empty?

Code: Select all

Clipboard := ""
Send, ^c
ClipWait, 2

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: long text paste

Post by boiler » 22 Nov 2021, 01:55

dostroll wrote: The clipboard is stored at ^ C.
Do you need to be empty?

Code: Select all

Clipboard := ""
Send, ^c
ClipWait, 2
If you don’t empty the clipboard first, then as @amateur+ pointed out, the ClipWait command won’t wait for the clipboard to be populated with what it is capturing via the ^c if it already contained some text. It would not wait at all, and your code may start working with the previous contents of the clipboard, whatever they were.

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: long text paste

Post by boiler » 22 Nov 2021, 02:00

dostroll wrote: It is different from the purpose of the thread, but is it better to specify the application PID?
Yes, because your Sleep, 100 may not be long enough to wait for the window to appear before your code starts acting on it. That little amount of time is typically not enough for allowing a program to run and its window to be generated. Rather than waiting a longer, arbitrary amount of time, using the pid as was shown will wait long enough and only long enough for the window associated with that pid to appear.

dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

Re: long text paste

Post by dostroll » 22 Nov 2021, 03:57

boiler wrote: Yes, because your Sleep, 100 may not be long enough to wait for the window to appear before your code starts acting on it. That little amount of time is typically not enough for allowing a program to run and its window to be generated. Rather than waiting a longer, arbitrary amount of time, using the pid as was shown will wait long enough and only long enough for the window associated with that pid to appear.
Thank you for advice.
Added to code.(Clipboard := "")

About PID.
Is it okay to EXE or CLASS? Is PID recommended?
PID is uniquely changing value. The reason to avoid "WinGet" is because the code becomes complicated.
Since there is a sufficient machine power, the processing time has been set short.
"SLEEP" is always worried.
"ClipWait" is peace of mind. The behavior to wait for the previous process is ideal.

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: long text paste

Post by boiler » 22 Nov 2021, 07:24

You aren’t meant to type in the PID where he has put PID. It automatically grabs the value of the newly run process ID from the Run command. It doesn’t matter that it changes every time. His code grabs it whatever it is (unless you changed the code by typing in a value for it or something).

dostroll
Posts: 40
Joined: 03 Nov 2021, 08:56

Re: long text paste

Post by dostroll » 30 Nov 2021, 07:33

I was a little mistaken.
We learned about Loop processing and using functions to simplify the process.

Thanks Master for your valuable advice.

Code: Select all

Process_High(Process_p1){
    Loop,parse,Process_p1,/
    {
        Process,Exist,%A_LoopField%
        if (  NewPID:=ErrorLevel )
            Process,Priority,%NewPID%,High
    }
    Return
}

Post Reply

Return to “Ask for Help (v1)”