Welcome Guest.   Make a donation to an author on the site November 26, 2014, 04:58:54 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Learn about the DonationCoder.com microdonation system (DonationCredits).
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE: SelectAll: Using the Control and A Keys to Select All Text  (Read 7755 times)
ewemoa
Honorary Member
**
Posts: 2,492



View Profile Give some DonationCredits to this forum member
« on: March 22, 2010, 01:14:46 AM »

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 smiley

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:

[copy or print]
/*

   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:

http://www.donationcoder....22126.msg199036#msg199036

Please move if necessary smiley
« Last Edit: March 22, 2010, 08:24:19 AM by ewemoa » Logged
lanux128
Global Moderator
*****
Posts: 6,133



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: March 22, 2010, 02:10:22 AM »

thanks for posting this, will come in handy.. smiley
Logged

mouser
First Author
Administrator
*****
Posts: 33,700



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: March 22, 2010, 05:25:32 AM »

I think this is a great idea, thanks for sharing  thumbs up
Logged
ghacks
Honorary Member
**
Posts: 49


View Profile Give some DonationCredits to this forum member
« Reply #3 on: March 22, 2010, 10:36:45 AM »

Interesting application. Can you name one or two scenarios where you make use of the app?
Logged
ewemoa
Honorary Member
**
Posts: 2,492



View Profile Give some DonationCredits to this forum member
« Reply #4 on: March 22, 2010, 07:19:55 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



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



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



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:22 PM by ewemoa » Logged
ghacks
Honorary Member
**
Posts: 49


View Profile Give some DonationCredits to this forum member
« Reply #5 on: March 23, 2010, 03:30:47 AM »

Thanks a lot, have reviewed your app

http://www.ghacks.net/201...select-all-text-behavior/
Logged
ewemoa
Honorary Member
**
Posts: 2,492



View Profile Give some DonationCredits to this forum member
« Reply #6 on: March 23, 2010, 04:15:23 AM »

Thanks for the nice review smiley

Regarding:

Quote
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.

Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.034s | Server load: 0.07 ]