Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Caps/Num/ScrollLock/Insert state on Start button


  • Please log in to reply
4 replies to this topic
Dragonscloud
  • Members
  • 96 posts
  • Last active: Jul 21 2010 08:33 PM
  • Joined: 16 Jul 2005
My new wireless keyboard has no lights for Capslock, ScrollLock, and Numlock, which I find really irritating in light of the fact that I often use Capslock as a modifier key.

I had a script using a ToolTip to remedy this, but was inspired by Skrommel's Start Clock script to make use of the otherwise useless Start button text. http://www.donationc...mel/#StartClock

The original script used "GoSub, Start" at the last line. I changed it to use a timer for easier integration into larger scripts.

Changes:
Added support for the Insert key.
Added #Persistent for use as a standalone script. Dashes indicate Off state, letters indicate On state. Thanks, Laszlo.
Replaced redundant If statements with Else. I had meant to do that in the first place. :oops:
Added some comments for newbies and for people like myself who need to have things spelled out for them.

#persistent ; needed only if used as a standalone script or integrated
;into a script with no hotstrings, hotkeys, or Gui commands
SetTimer, Start, 100 ;Tweak Parameter 2 to change response time
Start:
  StartButtonText = %CapsToggle%%NumToggle%%ScrollToggle%%InsToggle%
  /*
Added the above line to prevent side-scrolling in forum
On line 31, %StartButtonText% can be replaced with text after the equals 
sign on line 5
*/
  GetKeyState, CapsToggle, CapsLock, T ;Check whether Capslock is on or off
    If CapsToggle = U
      CapsToggle = -  ; If Capslock is off, place dash on Start button
    Else
      CapsToggle = C ;Otherwise, display C on Start button
  GetKeyState, NumToggle, Numlock, T
    If NumToggle = U
      NumToggle = -
    Else
      NumToggle = N
  GetKeyState, ScrollToggle, ScrollLock, T
    If ScrollToggle = U
      ScrollToggle = -
    Else
      ScrollToggle = S
  GetKeyState,InsToggle, Insert, T
    If InsToggle = U
      InsToggle = -
    Else 
      InsToggle = I
  ControlSetText,Button1,%StartButtonText%,ahk_class Shell_TrayWnd
  ; The above command is what changes the text of the Start button
Return

“yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Cool! I added your script to my main AHK script, with a little simplification. (I am sorry, I cannot resist... But you do need #Persistent!)
#Persistent

SetTimer, Start

Start:

  If GetKeyState("CapsLock","T")

    CapsToggle = -

  Else

    CapsToggle = C

  If GetKeyState("Numlock","T")

    NumToggle = -

  Else

    NumToggle = N

  If GetKeyState("ScrollLock","T")

    ScrollToggle = -

  Else

    ScrollToggle = S

  ControlSetText,Button1,%CapsToggle%%NumToggle%%ScrollToggle%,ahk_class Shell_TrayWnd

Return


shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005
Finally, a purpose for the Start button.

Reversed sense in Laszlo's code. Here is the correction:

#Persistent
SetTimer, Start
Start:
  If ! GetKeyState("CapsLock","T")
    CapsToggle = -
  Else
    CapsToggle = C
  If ! GetKeyState("Numlock","T")
    NumToggle = -
  Else
    NumToggle = N
  If ! GetKeyState("ScrollLock","T")
    ScrollToggle = -
  Else
    ScrollToggle = S
  ControlSetText,Button1,%CapsToggle%%NumToggle%%ScrollToggle%,ahk_class Shell_TrayWnd
Return

... and, here is my new Start button:

Posted Image

Dragonscloud
  • Members
  • 96 posts
  • Last active: Jul 21 2010 08:33 PM
  • Joined: 16 Jul 2005

Reversed sense in Laszlo's code. Here is the correction:

Code:

 If ! GetKeyState("CapsLock","T")
    CapsToggle = - 
  Else
    CapsToggle = C 


This works just as well:
  If GetKeyState("CapsLock","T")
    CapsToggle = C
  Else
    CapsToggle = -

“yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.

Dragonscloud
  • Members
  • 96 posts
  • Last active: Jul 21 2010 08:33 PM
  • Joined: 16 Jul 2005

Cool! I added your script to my main AHK script, with a little simplification. (I am sorry, I cannot resist... But you do need #Persistent!)


Oops! I had temporarily lost the original script and copied it out of another script that I had it integrated into, and forgot the #Persistant command.
I'm glad you caught that. I've changed the original post.

Thanks for the feedback and the lesson in alternate syntax. I like your style of syntax because it saves some lines of code, and I like my style of syntax
because there are fewer punctation marks (potential typos). When I'm more comfortable with using functions, I'll probably upgrade to your syntax style. I love the fact tha AHK supports both methods.
“yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.