topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Wednesday April 17, 2024, 11:03 pm
  • 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: IDEA: Selected Text Count  (Read 3480 times)

Nzyme

  • Participant
  • Joined in 2011
  • *
  • Posts: 100
    • View Profile
    • Donate to Member
IDEA: Selected Text Count
« on: December 09, 2011, 04:44 AM »
Hi,

I am looking for a program which would instantly show the count of the selected items (list). I know that this can be done in Excel but I need this on a global basis (everywhere - desktop, inside a program, Notepad, Word, etc). In short any text that can be selected.

For example: When I select 3 icons on the desktop, it should show the count as 3 besides the mouse pointer (like tool help tip). Similarly, when I select text like:

Hello
This
is what
i need

it should show a count as 4 (4 lines selected). Additional information like number of characters, words, lines etc would be an icing to the cake.

Is such a program possible on a global basis in Windows?

Thanks!

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Selected Text Count
« Reply #1 on: December 09, 2011, 11:54 AM »
You can experiment with this AHK script. I'm using AutoHotKey_L as sometimes that makes a difference.

For it to show the ToolTip you need to have the left mouse button down, then press and release the Left Control key. If you prefer right control key change LControl to RControl.

Should work for situations where you can select with the mouse, then keep the
mouse button down. The ToolTip clears the next time you click the mouse.

The reason for that is if it's active regardless of the mouse button state, it will be churning stuff to the clipboard to get the count.  Also it would likely interfere with using the clipboard normally. As it is, in the script I save clipboard text and restore it.  Saving everything, such as large graphics, would likely slow it down quite a bit.

If you get it to work to your liking you can compile with AHK_L and even add a custom icon to show in the tray. To get it to display the icon compiled into the exe, use these lines near the top:
if (A_IsCompiled)
  Menu Tray,Icon,%A_ScriptFullPath%,1

Selected Count Script

#SingleInstance force
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

count := 0
Selected := ""
SaveClipboard := ""
Return

~LButton::
  ToolTip
Return

~LControl::
  if not GetKeyState("LButton")
    Return
  SaveClipboard := Clipboard
  Clipboard =
  Send ^c
  ClipWait,1
  Selected = %Clipboard%
  if not Selected
    Return
  gosub,doToolTip
  Clipboard := SaveClipboard
Return

doToolTip:
  Loop, parse, clipboard, `n, `r
  {
    count := A_Index
  }
  ToolTip,%count%
Return
« Last Edit: December 09, 2011, 11:59 AM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Selected Text Count
« Reply #2 on: December 09, 2011, 07:54 PM »
This version should be a bit smoother.  Instead of having to hold the mouse key down, select text or folders in Explorer, whatever.  Then hold down both Control keys, and release, to get the count. The ToolTip will display near the mouse cursor. The ToolTip will disappear on next mouse click.

#SingleInstance force
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
if (A_IsCompiled)
  Menu Tray,Icon,%A_ScriptFullPath%,1

count := 0
Selected := ""
SaveClipboard := ""
Return

~LButton::
  ToolTip
Return

~LControl & ~RControl::
  SaveClipboard := Clipboard
  Clipboard =
  Send ^c
  ClipWait,1
  Selected = %Clipboard%
  if not Selected
    Return
  gosub,doToolTip
  Clipboard := SaveClipboard
Return

doToolTip:
  Loop, parse, clipboard, `n, `r
  {
    count := A_Index
  }
  ToolTip,%count%
Return


anandcoral

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 777
    • View Profile
    • Free Portable Apps
    • Donate to Member
Re: IDEA: Selected Text Count
« Reply #3 on: December 10, 2011, 01:03 AM »
Nzyme you can give Paste Text Like a try. A pledge for NANY 2012.

https://www.donation...ex.php?topic=27967.0

It gives the selected text line and character count along with some text manipulation options.

I will appreciate feedback to make it better.

Regards,

Anand