How to select all text without ^a? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Gettingoldslowly
Posts: 16
Joined: 25 Nov 2021, 11:01

How to select all text without ^a?

Post by Gettingoldslowly » 25 Nov 2021, 11:23

Hello all, I am a newbie to AutoHotkey and really appreciate how good this application is. my question is how to select all text without ^a? The program I am currently using doesn't support ^a command for select all, What I wanna do is to select all text then copy and paste to outlook, I tried the 1st version of codes below, however, it only copy the first letter of the text, then I tried the 2nd version of codes, but it give me an error message, my thinking is to have the cursor move to right as fast as possible while pressing shift until the end of the text, then copy and paste. Are there any codes to achieve this effect? Thanks in advance.

1st version:

Code: Select all

^NumpadDot::
sendInput, +{right}
send ^c
WinActivate, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
2nd version

Code: Select all

^NumpadDot::
KeyWait, +
KeyWait, {right}
clipwait, 3000
send ^c
WinActivate, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
[Mod edit: [code][/code] tags added.]

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

Re: How to select all text without ^a?

Post by amateur+ » 25 Nov 2021, 15:18

Try this. You can put sleep delays somewhere if it fails.

Code: Select all

^NumpadDot::
Clipboard := ""
sendInput, ^{Home}^+{End}
send ^c
Clipwait
WinActivate, ahk_exe OUTLOOK.EXE
WinWaitActive   ; For those who will use this script, there is a mistake in this line. The correct line will be: WinWaitActive, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
Last edited by amateur+ on 25 Nov 2021, 17:14, edited 1 time in total.
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.

alancantor
Posts: 76
Joined: 11 Jun 2019, 11:28

Re: How to select all text without ^a?

Post by alancantor » 25 Nov 2021, 15:50

That's more-or-less how I would have done it: First, move the insertion point to the top of the document (or field) with Ctrl + Home, and then select to the bottom with Shift + Ctrl + End.

Not sure emptying the clipboard is necessary. Dealing with Clipboard is so flaky in Windows 10 that I try to avoid clipboard operations when scripting macros, unless they are key to solving the puzzle.

I wonder whether there might be a ControlGet solution, as this might eliminate the need to move the cursor.

Gettingoldslowly
Posts: 16
Joined: 25 Nov 2021, 11:01

Re: How to select all text without ^a?

Post by Gettingoldslowly » 25 Nov 2021, 16:01

amateur+ wrote:
25 Nov 2021, 15:18
Try this. You can put sleep delays somewhere if it fails.

Code: Select all

^NumpadDot::
Clipboard := ""
sendInput, ^{Home}^+{End}
send ^c
Clipwait
WinActivate, ahk_exe OUTLOOK.EXE
WinWaitActive
send ^v
send, {Enter}
return
Hi, amateur+ , Thank you for the codes, I tried your codes at first, however, it didn't work, but I noticed the movement of cursor and it selected all the text,
Then I modified to codes below, and it works exactly the way I want, Thank you so so much! Happy Thanksgiving!

Code: Select all

^NumpadDot::
sendInput, ^{Home}^+{End}
send ^c
WinActivate, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
[Mod edit: [code][/code] tags added.]

alancantor
Posts: 76
Joined: 11 Jun 2019, 11:28

Re: How to select all text without ^a?

Post by alancantor » 25 Nov 2021, 16:25

You may discover the script fails occasionally due to the aforementioned clipboard weirdness in Windows 10. After copying, I suggest adding a short delay (100 pr 200 ms?) to increase reliability.

Alternatively, clearing the clipboard and later, testing whether the clipboard has been populated (clipwait) is worth considering. But even this approach fails once in a while.

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

Re: How to select all text without ^a?  Topic is solved

Post by amateur+ » 25 Nov 2021, 16:36

Sorry, I wrote the script here at the forum actually and didn't test it. You should add WinWaitActive, ahk_exe OUTLOOK.EXE and it will succeed:

Code: Select all

^NumpadDot::
Clipboard := ""
sendInput, ^{Home}^+{End}
send ^c
Clipwait
WinActivate, ahk_exe OUTLOOK.EXE
WinWaitActive, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
It is better to use Clipwait, so you'll be sure that new clipboard data will be pasted later in the Outlook and not old data that was in the Clipboard earlier.
It is better to use WinWaitActive, ahk_exe OUTLOOK.EXE for you to be sure that Outlook is activated at the moment you're pasting via Ctrl+V.
Not sure emptying the clipboard is necessary.
@alancantor, Clipboard := "" is neccessary b/c otherwise later Clipwait won't wait if the clipboard was non-empty already before you launched your hotkey. Clipwait says you that now clipboard is now non-empty and you want new data in it and not old ones.
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.

Gettingoldslowly
Posts: 16
Joined: 25 Nov 2021, 11:01

Re: How to select all text without ^a?

Post by Gettingoldslowly » 25 Nov 2021, 16:48

alancantor wrote:
25 Nov 2021, 16:25
You may discover the script fails occasionally due to the aforementioned clipboard weirdness in Windows 10. After copying, I suggest adding a short delay (100 pr 200 ms?) to increase reliability.

Alternatively, clearing the clipboard and later, testing whether the clipboard has been populated (clipwait) is worth considering. But even this approach fails once in a while.
Hi, alancantor, Thank you so much for the advise, should I put like this?

Code: Select all

^NumpadDot::
sendInput, ^{Home}^+{End}
send ^c
Sleep, 200
WinActivate, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
[Mod edit: [code][/code] tags added.]

Thanks in advance!

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

Re: How to select all text without ^a?

Post by amateur+ » 25 Nov 2021, 17:41

What will you do if Outlook will be activating for a too long time? Where will ^v paste the clipboard contents?
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.

alancantor
Posts: 76
Joined: 11 Jun 2019, 11:28

Re: How to select all text without ^a?

Post by alancantor » 25 Nov 2021, 17:48

@amateur+: I also prefer to empty the clipboard and use clipwait. The approach just makes sense to me.

But sometimes the approach fails. At times, I have resorted to adding a short delay AFTER a clipwait statement. That seems to improve the reliability of a script; but then I think, "why bother with all this extra code when a single sleep statement after a clipboard operation works equally well?"

@Gettingoldslowly: I think the delay you've introduced will help improve reliability; but pay attention to @amateur+'s advise, which is sound!

Gettingoldslowly
Posts: 16
Joined: 25 Nov 2021, 11:01

Re: How to select all text without ^a?

Post by Gettingoldslowly » 25 Nov 2021, 21:39

amateur+ wrote:
25 Nov 2021, 16:36
Sorry, I wrote the script here at the forum actually and didn't test it. You should add WinWaitActive, ahk_exe OUTLOOK.EXE and it will succeed:

Code: Select all

^NumpadDot::
Clipboard := ""
sendInput, ^{Home}^+{End}
send ^c
Clipwait
WinActivate, ahk_exe OUTLOOK.EXE
WinWaitActive, ahk_exe OUTLOOK.EXE
send ^v
send, {Enter}
return
It is better to use Clipwait, so you'll be sure that new clipboard data will be pasted later in the Outlook and not old data that was in the Clipboard earlier.
It is better to use WinWaitActive, ahk_exe OUTLOOK.EXE for you to be sure that Outlook is activated at the moment you're pasting via Ctrl+V.
Not sure emptying the clipboard is necessary.
@alancantor, Clipboard := "" is neccessary b/c otherwise later Clipwait won't wait if the clipboard was non-empty already before you launched your hotkey. Clipwait says you that now clipboard is now non-empty and you want new data in it and not old ones.
Hi, amateur+, thank you for the follow up and the great help! I just tried your codes, it works good! I appreciated your help! :superhappy:

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

Re: How to select all text without ^a?

Post by amateur+ » 26 Nov 2021, 10:38

Glad to help. You can put sleep, 50 after Clipwait and WinWaitActive, ahk_exe OUTLOOK.EXE for more stability alancantor told about.
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.

Gettingoldslowly
Posts: 16
Joined: 25 Nov 2021, 11:01

Re: How to select all text without ^a?

Post by Gettingoldslowly » 26 Nov 2021, 13:22

amateur+ wrote:
26 Nov 2021, 10:38
Glad to help. You can put sleep, 50 after Clipwait and WinWaitActive, ahk_exe OUTLOOK.EXE for more stability alancantor told about.
@amateur+ @alancantor Thank you, I noticed the codes failed occasionally. I will definitely try out the sleep, 50, Thank you both for making this codes perfect!

Post Reply

Return to “Ask for Help (v1)”