topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:59 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: DONE: SelectAll: Using the Control and A Keys to Select All Text  (Read 18909 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Background

I find that Control+A doesn't necessarily select all text in various contexts and typically notice this after typing Control+A.

Not finding anything that seemed to help, I put together a little utility tentatively named "SelectAll" in an attempt to improve the situation a bit.  I have been using it for a bit now and have found that it has turned out to be useful in my particular situation.  After some discussion with mouser a decision to post it was reached.  (Please let me know if you know of something similar or better.)

How to Use
  
While this program is running, if Control+A does not select all text for a field with focus, try entering Control+A twice quickly to get all of the text selected.
  
The invocation may be done in at least two ways:
  
1. An initial Control+A sequence, then letting go of both keys, and a subsequent Control+A sequence.
    
2. An initial Control+A sequence, then without letting go of the control key, let go of the A key and press the A key again.
        
(I prefer the second approach, but both seem to work as far as triggering an attempt to select all text.)

Caveat

Unfortunately, it doesn't work with a number of (all?) NirSoft utilities -- and it seems likely there are other things it won't work with.  I might make an exception list, but haven't decided whether it's worth it or if it makes sense just yet.  Also, depending on the size of the text field, after text is selected there may be some scrolling.  Anyway, perhaps the code can be improved upon or someone can come up with a better idea :)

Credits

The code is basically an adaptation of an AHK Forum post (thanks to the author "jonny"):

  http://www.autohotkey.com/forum/topic15537-1.html

The selection method was improved by lanux128 -- thanks to him for that  :Thmbsup:

Code

Source:

/*

   Name: SelectAll
   Description: Select All Text via Hotkey
  
   Control+A does not always select all text unfortunately.
   This program is an attempt to improve the situation a bit.
  
   While this program is running, if Control+A does not select all
   text for a field with focus, try entering Control+A twice
   quickly.
  
   This may be done in at least two ways:
  
     1. An initial Control+A sequence, then letting go of both keys,
        and a subsequent Control+A sequence.
    
     2. An initial Control+A sequence, then without letting go of the
        control key, let go of the A key and press the A key again.
        
   FWIW, the author finds the second form easier to execute.
        
   Example locations of relevance (Windows XP):
  
     -7-zip: address/path text field [1]
     -Code::Block: multiple text fields
     -Everything: options dialog: multiple text fields
     -FileZilla: multiple text fields
     -Free Download Manager: multiple text fields
     -grepWin: multiple text fields
     -Internet Explorer:
       home page text field [1]
     -IrfanView: multiple text fields
     -Notepad++: Preferences dialog: multiple text fields
     -ReNamer: multiple text fields
     -Universal Extractor: multiple text fields
     -Windows Explorer:
       address/path text field [1]
       file/folder name when renaming via F2 [1]
     -WinMerge:
       Select Files and Folders: mulitple text fields [1]
       Options dialog: multiple text fields
     -WinSpy++: multiple text fields
     -Save / Open Dialogs: filename text field [1]
     -Run Dialog: name text field [1]
     -File/Folder Properties Dialog:
       various text fields
     -HTMLHelp (hh.exe, .chm viewing): keyword text field [2]
      
   Where this code does not work (Windows XP):
    
     -Windows Explorer:
        file name text field in searching for files
        string text field in searching for files    
    
   [1] Though initial focus selects all text
   [2] Double-clicking on field selects some text
  
   code based on http://www.autohotkey.com/forum/topic15537-1.html

*/

#NoEnv
#Persistent

; XXX: place in .ini?
delay = 400
hkmod = ^
hkletter = a
hk = %hkmod%%hkletter%
fullhk = ~%hk%
Hotkey, %fullhk%, Invoke
Return

Invoke:
; 'delay' is the maximum allowed delay (in ms) between presses.
If ((A_PriorHotKey = fullhk) && (A_TimeSincePriorHotkey < delay))
{
  BlockInput, On
  ; thanks to lanux128 for the following
  Send, {Control Down}{Home}{Control Up}{Control Down}{Shift Down}{End}{Shift Up}{Control Up}
  BlockInput, Off
}
; XXX: don't know what this Sleep is for...
Sleep, 0
KeyWait, %hkletter%
Return

Executable

Meta

Posted this here as per:

https://www.donation....msg199036#msg199036

Please move if necessary :)
« Last Edit: March 22, 2010, 08:24 AM by ewemoa »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: SelectAll: Using the Control and A Keys to Select All Text
« Reply #1 on: March 22, 2010, 02:10 AM »
thanks for posting this, will come in handy.. :)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: SelectAll: Using the Control and A Keys to Select All Text
« Reply #2 on: March 22, 2010, 05:25 AM »
I think this is a great idea, thanks for sharing  :up:

ghacks

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 50
    • View Profile
    • Donate to Member
Re: SelectAll: Using the Control and A Keys to Select All Text
« Reply #3 on: March 22, 2010, 10:36 AM »
Interesting application. Can you name one or two scenarios where you make use of the app?

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: SelectAll: Using the Control and A Keys to Select All Text
« Reply #4 on: March 22, 2010, 07:19 PM »
Below are some brief examples (note: have only used tool with Windows XP):

Windows Explorer:
  Select a file or folder that has a name with at least one space in it
    Right-click to bring up the context-sensitive menu
      Choose the Properties menu item to bring up the corresponding dialog box
        Bring focus to the text field [1] with the name of the File or Folder
          Notice that neither double-clicking nor Control+A select all of the text

SelectAll - File or Folder Properties Dialog.pngDONE: SelectAll: Using the Control and A Keys to Select All Text

SumatraPDF:
  Open some document for viewing
    In the Find field, type a phrase to search for that contains at least one space
      Press tab to move focus off of the Find field
        Bring focus back to the Find field
          Notice that neither double-clicking nor Control+A select all of the text

SelectAll - SumatraPDF.pngDONE: SelectAll: Using the Control and A Keys to Select All Text

Standard Save Dialog:
  Right-click on an appropriate link in Firefox to bring up the context-sensitive menu
    Choose the "Save Link As" menu item to bring up a Save As dialog
      Edit the file name field to contain a string with at least one space
        Notice that neither double-clicking nor Control+A select all of the text

SelectAll - Save As Dialog.pngDONE: SelectAll: Using the Control and A Keys to Select All Text

Other examples briefly mentioned in source.

(Note that tabbing off of a text field and using Shift+Tab to return focus to the text field can be a handy work-around for situations where initial focus to the text field selects all of the text.)


[1] Other text fields in the dialog also seem to behave similarly -- the file and folder name text field seemed easiest to describe.
« Last Edit: March 22, 2010, 08:42 PM by ewemoa »

ghacks

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 50
    • View Profile
    • Donate to Member
Re: SelectAll: Using the Control and A Keys to Select All Text
« Reply #5 on: March 23, 2010, 03:30 AM »
Thanks a lot, have reviewed your app

http://www.ghacks.ne...t-all-text-behavior/

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: SelectAll: Using the Control and A Keys to Select All Text
« Reply #6 on: March 23, 2010, 04:15 AM »
Thanks for the nice review :)

Regarding:

Tapping the Ctrl A shortcut a second time whenever the first does not select all text in an active form, field or window will select all the text in most applications.

The current code has a timeout, so I think if the second Control+A doesn't occur soon enough, the code's selection action will not be triggered.

Please let me know if this is not the case.