 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
skrommel
Joined: 30 Jul 2004 Posts: 190
|
Posted: Wed Jul 20, 2005 4:16 pm Post subject: CAPshift: Slow down and extend the caps lock key |
|
|
The ultimate Caps Lock extender!
CAPshift slows down and extends the caps lock key.
Hold down caps lock for 0.4 sec to toggle caps lock on or off.
Hold for 0.9 sec to show a menu that converts selected text to UPPER CASE, lower case, Title Case or iNVERT cASE.
Some of the ideas came from Ampa on another forum.
Skrommel
| Code: | ;CAPshift.ahk
;Slows down and extends the cap locks key.
;
;Hold for 0.4 sec to toggle caps lock on or off.
;Hold for 0.9 sec to show a menu that converts selected text to
; UPPER CASE, lower case, Title Case or iNVERT cASE.
;Skrommel @2005
SetTimer,TOOLTIP,1500
SetTimer,TOOLTIP,Off
CapsLock::
counter=0
Loop,90
{
Sleep,10
counter+=1
If counter=40
SoundPlay,%SYSTEMROOT%\Media\ding.wav
GetKeyState,state,CapsLock,P
If state=U
Break
}
If counter=90
Gosub,MENU
Else
If counter>40
{
GetKeyState,state,CapsLock,T
If state=D
Gosub,OFF
Else
Gosub,ON
}
Return
MENU:
Menu,convert,Add
Menu,convert,Delete
Menu,convert,Add,CAPshift,EMPTY
Menu,convert,Add,
Menu,Convert,Add,CapsLock &On,On
Menu,Convert,Add,&CapsLock Off,Off
Menu,convert,Add,
Menu,convert,Add,&UPPER CASE,UPPER
Menu,convert,Add,&lower case,LOWER
Menu,convert,Add,&Title Case,TITLE
Menu,convert,Add,&iNVERT cASE,INVERT
Menu,convert,Add,
Menu,convert,Add,&About,ABOUT
Menu,convert,Add,&Quit,QUIT
Menu,convert,Default,CapShift
Menu,convert,Show
Return
EMPTY:
Return
TOOLTIP:
ToolTip,
SetTimer,TOOLTIP,Off
Return
ON:
SetCapsLockState,On
ToolTip,CapsLock On
SetTimer,TOOLTIP,On
Return
OFF:
SetCapsLockState,Off
ToolTip,CapsLock Off
SetTimer,TOOLTIP,On
Return
CUT:
Send,^x
ClipWait,1
string=%clipboard%
Return
PASTE:
clipboard=%string%
Send,^v
Return
UPPER:
Gosub,CUT
StringUpper,string,string
Gosub,PASTE
ToolTip,Selection converted to UPPER CASE
SetTimer,TOOLTIP,On
Return
LOWER:
Gosub,CUT
StringLower,string,string
Gosub,PASTE
ToolTip,Selection converted to lower case
SetTimer,TOOLTIP,On
Return
TITLE:
Gosub,CUT
StringLower,string,string,T
Gosub,PASTE
ToolTip,Selection converted to Title Case
SetTimer,TOOLTIP,On
Return
INVERT:
AutoTrim,Off
StringCaseSense,On
Gosub,CUT
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,length,string
Loop,%length%
{
StringLeft,char,string,1
StringGetPos,pos,lower,%char%
pos+=1
If pos<>0
StringMid,char,upper,%pos%,1
Else
{
StringGetPos,pos,upper,%char%
pos+=1
If pos<>0
StringMid,char,lower,%pos%,1
}
StringTrimLeft,string,string,1
string=%string%%char%
}
ToolTip,Selection converted to iNVERTED cASE
SetTimer,TOOLTIP,On
Gosub,PASTE
Return
ABOUT:
MsgBox,0,CAPshift,CAPshift slows down and extends the caps lock key.`n`nHold down caps lock for 0.4 sec to toggle caps lock on or off.`nHold for 0.9 sec to show a menu that converts selected text to UPPER CASE, lower case, Title Case or iNVERT cASE.`n`nSkrommel @2005
Return
QUIT:
ExitApp |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Wed Jul 20, 2005 5:26 pm Post subject: |
|
|
| "Overloading" the Caps Lock key in this way seems to be a great innovation. Thanks for posting it. |
|
| Back to top |
|
 |
jack
Joined: 04 Sep 2004 Posts: 74 Location: UK
|
Posted: Thu Sep 29, 2005 7:35 pm Post subject: |
|
|
really nice!
i abandoned capslock ages ago -- it's far more useful to have it run my file manager -- but with a tiny edit i can have the file manager and your functionality too.
great stuff.
thanks
jack
tomorrow's almost over, today went by so fast... |
|
| Back to top |
|
 |
bor Guest
|
Posted: Wed Sep 19, 2007 8:04 am Post subject: |
|
|
I mad a little extension to this script.
It changes someTextHere to SOME_TEXT_HERE
| Code: |
DASHES:
AutoTrim,Off
StringCaseSense,On
Gosub,COPY
lower=abcdefghijklmnopqrstuvwxyzaoa
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZAOA
StringLen,length,string
iter:=0
Loop,%length%
{
StringLeft,char,string,1
StringGetPos,pos,lower,%char%
pos+=1
If pos<>0
StringMid,char,upper,%pos%,1
Else ;pos==0
{
StringGetPos,pos,upper,%char%
pos+=1
If pos<>0
{
StringMid,char,upper,%pos%,1
If iter<>0
char=_%char%
}
}
StringTrimLeft,string,string,1
string=%string%%char%
iter+=1
}
ToolTip,Selection converted to KRECHY
SetTimer,TOOLTIP,On
Gosub,PASTE
Return
|
|
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1237
|
Posted: Fri Oct 12, 2007 4:31 am Post subject: |
|
|
Nice ideas. I made a few changes to the script and added a progress bar to display how long the button has been pressed (and it changes colour to show the phase you can turn the Capslock on).
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
About =
(LTrim0
Slows down and extends the capslock key.
Hold for 0.2 sec to toggle capslock on or off.
Hold for 0.5 sec to show a menu that converts selected text to
UPPER CASE, lower case, Title Case, iNVERT cASE, etc
)
SetTimer,TOOLTIP,1500
SetTimer,TOOLTIP,Off
TimeCapsToggle =20
TimeOut =50
CapsLock::
counter=0
Progress, ZH16 ZX0 ZY0 B R0-%TimeOut%
Loop, %TimeOut%
{
Sleep,10
counter+=1
Progress, %counter% ;, SubText, MainText, WinTitle, FontName
If (counter = TimeCapsToggle)
Progress, ZH16 ZX0 ZY0 B R0-%TimeOut% CBFF0000
GetKeyState,state,CapsLock,P
If state=U
Break
}
Progress, Off
If counter=%TimeOut%
Gosub,MENU
Else If (counter>TimeCapsToggle)
Gosub, CapsLock_State_Toggle
Return
MENU:
Winget, Active_Window, ID, A
Send,^c
ClipWait,1
Menu,convert,Add
Menu,convert,Delete
Menu, misc ,Add,&About,ABOUT
Menu, misc ,Add,&Quit,QUIT
Menu,convert,Add,CAPshift, :misc
Menu,convert,Add,
Menu,Convert,Add,&CapsLock Toggle,CapsLock_State_Toggle
Menu,convert,Add,
; NOTE: A_ThisMenuItem is used to determine the action to take
Menu,convert,Add,&UPPER CASE,MENU_ACTION
Menu,convert,Add,&lower case,MENU_ACTION
Menu,convert,Add,&Title Case,MENU_ACTION
Menu,convert,Add,&iNVERT cASE,MENU_ACTION
Menu,convert,Add,Remove_&under_scores,MENU_ACTION
Menu,convert,Add,Remove.&full.stops,MENU_ACTION
Menu,convert,Default,&CapsLock Toggle
Menu,convert,Show
Return
MENU_ACTION:
AutoTrim,Off
string=%clipboard%
clipboard:=Menu_Action(A_ThisMenuItem, string)
WinActivate, ahk_id %Active_Window%
Send,^v
ToolTip,Selection converted to %A_ThisMenuItem%
SetTimer,TOOLTIP,On
Return
Menu_Action(ThisMenuItem, string)
{
If ThisMenuItem =&UPPER CASE
StringUpper,string,string
Else If ThisMenuItem =&lower case
StringLower,string,string
Else If ThisMenuItem =&Title Case
StringLower,string,string,T
Else If ThisMenuItem =&iNVERT cASE
{
StringCaseSense,On
lower=abcdefghijklmnopqrstuvwxyz
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
StringLen,length,string
Loop,%length%
{
StringLeft,char,string,1
StringGetPos,pos,lower,%char%
pos+=1
If pos<>0
StringMid,char,upper,%pos%,1
Else
{
StringGetPos,pos,upper,%char%
pos+=1
If pos<>0
StringMid,char,lower,%pos%,1
}
StringTrimLeft,string,string,1
string.=char
}
StringCaseSense,Off
}
Else If ThisMenuItem =Remove_&under_scores
StringReplace, string, string,_,%A_Space%, All
Else If ThisMenuItem =Remove.&full.stops
StringReplace, string, string,.,%A_Space%, All
Return string
}
EMPTY:
Return
TOOLTIP:
ToolTip,
SetTimer,TOOLTIP,Off
Return
CapsLock_State_Toggle:
If GetKeyState("CapsLock","T")
state=Off
Else
state=On
CapsLock_State_Toggle(state)
Return
CapsLock_State_Toggle(State)
{
SetCapsLockState,%State%
ToolTip,CapsLock %State%
SetTimer,TOOLTIP,On
}
ABOUT:
MsgBox,0,CAPshift,%About%
Return
QUIT:
ExitApp
|
|
|
| Back to top |
|
 |
jfty.009260
Joined: 18 Mar 2008 Posts: 8
|
Posted: Fri May 16, 2008 10:27 am Post subject: |
|
|
| Wow, evl, that is a very nice mod of CAPshift! |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 783 Location: Greeley, CO
|
Posted: Thu May 29, 2008 1:33 pm Post subject: |
|
|
I've meant to post here a million times (really, I kept track) and finally getting around to it.
I am forever hitting the capslock and this is my only saving grace.
Thanks - I love it. _________________
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played." |
|
| Back to top |
|
 |
vahju
Joined: 17 Feb 2008 Posts: 296
|
Posted: Thu May 29, 2008 5:14 pm Post subject: |
|
|
This is a great script and I love evl's version.
When I go to include this script with mine (using include) depending on where I put the include it either doesn't work or works and prevents my other code from working.
When using include with evl's version is there anything I should remove? |
|
| Back to top |
|
 |
steve264
Joined: 16 Jun 2008 Posts: 1
|
Posted: Mon Jun 16, 2008 4:05 pm Post subject: CAPshift.ahk - need to cope with double-press of caps lock |
|
|
Hi,
Great script, but it causes me a problem because another application I use has a double-press of the Caps Lock key as a hard-coded keystroke.
I would like to modify the CAPshift.ahk script to recognise that the Caps Lock has been pressed twice rapidly, and if so, just exit without doing anything.
I don't have the knowledge or skill to do this mod myself, can anyone please help out?
Many thanks,
Steve
 |
|
| Back to top |
|
 |
Mike the K
Joined: 17 Dec 2007 Posts: 2
|
Posted: Sat Oct 03, 2009 11:47 pm Post subject: Add CAPshift option to add parentheses? |
|
|
Hi.
Can someone help me add CAPshift menu options to surround the current selection with parens and maybe brackets? I tried returning the entire string with SubStr(string,1), but I couldn't figure out how to concatenate the extra characters...
Thanks in advance,
-Mike. |
|
| Back to top |
|
 |
Mike the K
Joined: 17 Dec 2007 Posts: 2
|
Posted: Sat Oct 10, 2009 1:04 pm Post subject: Re: Add CAPshift option to add parentheses? |
|
|
| Mike the K wrote: | Can someone help me add CAPshift menu options to surround the current selection with parens and maybe brackets?
|
Never mind: string=(%string%).
Next time I'll try the painfully obvious before asking...
-Mike. |
|
| Back to top |
|
 |
k.freeman
Joined: 31 Aug 2010 Posts: 1 Location: Oregon
|
Posted: Tue Aug 31, 2010 4:19 am Post subject: Added functionality |
|
|
At the risk of getting chewed out for waking up a 5 year old thread: I ran across this script and love it. I use this at work in converting procedural steps into Title Case. The only thing missing was the ability to convert them back to Sentence case when I copy/paste them out of our procedure program for use in emails or other correspondence.
Changed in this version:
- Moved HotKey higher up in code in order to make it work on my laptop (Not sure if this is due to Win7, the AutoHotKey version or what).
- Added ability to change the Toggle timer and TimeOut timer with an ini file for storing options.
- Added Sentence Case option
- 'About' displays current timer settings (haven't worked it over enough to make it round nicely though)
| Code: | ; Slows down and extends the capslock key.
; Original programming by skrommel with modifications by evl and k.freeman.
; Code for Sentence case borrowed from JDN and ManaUser.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CapsLock::
SetTimer,TOOLTIP,1500
SetTimer,TOOLTIP,Off
iniRead, TimeCapsToggle, CAPShift.ini, Settings, TimeCapsToggle, 40
iniRead, TimeOut, CAPShift.ini, Settings, TimeOut, 100
ToggleTimer := TimeCapsToggle/1000
MenuTimer := TimeOut/1000
About =
(LTrim0
Slows down and extends the capslock key.
Hold for %ToggleTimer% sec to toggle capslock on or off.
Hold for %MenuTimer% sec to show a menu that converts selected text to
UPPER CASE, lower case, Title Case, iNVERT cASE, etc
)
counter=0
Progress, ZH16 ZX0 ZY0 B R0-%TimeOut%
Loop, %TimeOut%
{
Sleep,10
counter+=1
Progress, %counter% ;, SubText, MainText, WinTitle, FontName
If (counter = TimeCapsToggle)
Progress, ZH16 ZX0 ZY0 B R0-%TimeOut% CBFF0000
GetKeyState,state,CapsLock,P
If state=U
Break
}
Progress, Off
If counter=%TimeOut%
Gosub,MENU
Else If (counter>TimeCapsToggle)
Gosub, CapsLock_State_Toggle
Return
MENU:
Winget, Active_Window, ID, A
Send,^c
ClipWait,20
Menu,convert,Add
Menu,convert,Delete
Menu, misc ,Add,&About,ABOUT
Menu, misc ,Add,&Quit,QUIT
Menu, misc ,Add,&Toggle Timer,TTIMER
Menu, misc ,Add,&Menu Timer, MTIMER
Menu,convert,Add,CAPShift, :misc
Menu,convert,Add,
Menu,Convert,Add,&CapsLock Toggle,CapsLock_State_Toggle
Menu,convert,Add,
; NOTE: A_ThisMenuItem is used to determine the action to take
Menu,convert,Add,&UPPER CASE,MENU_ACTION
Menu,convert,Add,&lower case,MENU_ACTION
Menu,convert,Add,&Sentence case,MENU_ACTION
Menu,convert,Add,&Title Case,MENU_ACTION
Menu,convert,Add,&iNVERT cASE,MENU_ACTION
Menu,convert,Add,Remove_&under_scores,MENU_ACTION
Menu,convert,Add,Remove.&full.stops,MENU_ACTION
Menu,convert,Default,&CapsLock Toggle
Menu,convert,Show
Return
MENU_ACTION:
AutoTrim,Off
string=%clipboard%
clipboard:=Menu_Action(A_ThisMenuItem, string)
WinActivate, ahk_id %Active_Window%
Send,^v
ToolTip,Selection converted to %A_ThisMenuItem%
SetTimer,TOOLTIP,On
Return
Menu_Action(ThisMenuItem, string)
{
If ThisMenuItem =&UPPER CASE
StringUpper,string,string
Else If ThisMenuItem =&lower case
StringLower,string,string
Else if ThisMenuItem =&Sentence case
{
MsgBox, 4, WARNING, This WILL affect proper nouns. Continue anyway?
ifMsgBox, Yes
StringLower, string, string
string := RegExReplace(string, "(((^|([.!?]\s+))[a-z])| i | i')", "$u1")
}
Else If ThisMenuItem =&Title Case
StringLower,string,string,T
Else If ThisMenuItem =&iNVERT cASE
{
StringCaseSense,On
lower=abcdefghijklmnopqrstuvwxyz
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
StringLen,length,string
Loop,%length%
{
StringLeft,char,string,1
StringGetPos,pos,lower,%char%
pos+=1
If pos<>0
StringMid,char,upper,%pos%,1
Else
{
StringGetPos,pos,upper,%char%
pos+=1
If pos<>0
StringMid,char,lower,%pos%,1
}
StringTrimLeft,string,string,1
string.=char
}
StringCaseSense,Off
}
Else If ThisMenuItem =Remove_&under_scores
StringReplace, string, string,_,%A_Space%, All
Else If ThisMenuItem =Remove.&full.stops
StringReplace, string, string,.,%A_Space%, All
Return string
}
EMPTY:
Return
TOOLTIP:
ToolTip,
SetTimer,TOOLTIP,Off
Return
CapsLock_State_Toggle:
If GetKeyState("CapsLock","T")
state=Off
Else
state=On
CapsLock_State_Toggle(state)
Return
CapsLock_State_Toggle(State)
{
SetCapsLockState,%State%
ToolTip,CapsLock %State%
SetTimer,TOOLTIP,On
}
TTIMER:
inputBox, TTIME, CAPShift, Enter the amount of time you want to press the key to toggle CapsLock on/off (1000 = 1 second),, 320, 140
if TTIME !=
{
iniWrite, %TTIME%, CAPShift.ini, Settings, TimeCapsToggle
sleep 100
reload
}
return
MTIMER:
inputBox, MTIME, CAPShift, Enter the amount of time you want to press the key to bring up the CAPShift Menu (1000 = 1 second),, 320, 140
if MTIME !=
{
iniWrite, %MTIME%, CAPShift.ini, Settings, TimeOut
sleep 100
reload
}
return
ABOUT:
MsgBox,0,CAPShift,%About%
Return
QUIT:
ExitApp
|
Hope this is useful to somebody.
I also modified this (a lot) to use as a custom print menu tied to the prntscrn key. That script currently isn't usable on any other machine though, its too dependent on my personal printer settings.
-k.freeman |
|
| Back to top |
|
 |
nascent
Joined: 10 Nov 2011 Posts: 1
|
Posted: Thu Nov 10, 2011 1:12 am Post subject: Awesome! |
|
|
Update: All versions of this script fail when caps lock is pressed along with another modifier key. My version now fixes this:
I've been using some shareware by the name of sMaRTcaPs for a while, and while it worked, it wasn't free, and was very buggy (randomly will toggle caps, randomly decides it wants indefinite caps lock ON, etc).
Finally discovered this script, which is awesome!
I didn't want the visual mods, the sound effect didn't work on Win7 for me (don't think I have the wav), there is a bug in the other scripts where additional modifier keys break the script and I wanted a longer delay for the menu.
So I too did a version of the script, which I compiled with an icon I found:
So here's my version:
(exe download link for those that don't want to compile it themselves)
| Code: | ;CAPshift.ahk
;Slows down and extends the cap locks key.
;
;Hold for 0.4 sec to toggle caps lock on or off.
;Hold for 1.2 sec to show a menu that converts selected text to
; UPPER CASE, lower case, Title Case or iNVERT cASE.
;Original Author=Skrommel @2005
;Modified by nascent
SetTimer,TOOLTIP,1500
SetTimer,TOOLTIP,Off
*CapsLock::
counter=0
Loop,200
{
Sleep,10
counter+=1
If counter=40
;SoundPlay,%SYSTEMROOT%\Media\ding.wav
SoundBeep
GetKeyState,state,CapsLock,P
If state=U
Break
}
If counter=200
Gosub,MENU
Else
If counter>40
{
GetKeyState,state,CapsLock,T
If state=D
Gosub,OFF
Else
Gosub,ON
}
Return
MENU:
Menu,convert,Add
Menu,convert,Delete
Menu,convert,Add,CAPshift,EMPTY
Menu,convert,Add,
Menu,Convert,Add,CapsLock &On,On
Menu,Convert,Add,&CapsLock Off,Off
Menu,convert,Add,
Menu,convert,Add,&UPPER CASE,UPPER
Menu,convert,Add,&lower case,LOWER
Menu,convert,Add,&Title Case,TITLE
Menu,convert,Add,&iNVERT cASE,INVERT
Menu,convert,Add,
Menu,convert,Add,&About,ABOUT
Menu,convert,Add,&Quit,QUIT
Menu,convert,Default,CapShift
Menu,convert,Show
Return
EMPTY:
Return
TOOLTIP:
ToolTip,
SetTimer,TOOLTIP,Off
Return
ON:
SetCapsLockState,On
ToolTip,CapsLock On
SetTimer,TOOLTIP,On
Return
OFF:
SetCapsLockState,Off
ToolTip,CapsLock Off
SetTimer,TOOLTIP,On
Return
CUT:
Send,^x
ClipWait,1
string=%clipboard%
Return
PASTE:
clipboard=%string%
Send,^v
Return
UPPER:
Gosub,CUT
StringUpper,string,string
Gosub,PASTE
ToolTip,Selection converted to UPPER CASE
SetTimer,TOOLTIP,On
Return
LOWER:
Gosub,CUT
StringLower,string,string
Gosub,PASTE
ToolTip,Selection converted to lower case
SetTimer,TOOLTIP,On
Return
TITLE:
Gosub,CUT
StringLower,string,string,T
Gosub,PASTE
ToolTip,Selection converted to Title Case
SetTimer,TOOLTIP,On
Return
INVERT:
AutoTrim,Off
StringCaseSense,On
Gosub,CUT
lower=abcdefghijklmnopqrstuvwxyzĉĝċ
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZĈĜĊ
StringLen,length,string
Loop,%length%
{
StringLeft,char,string,1
StringGetPos,pos,lower,%char%
pos+=1
If pos<>0
StringMid,char,upper,%pos%,1
Else
{
StringGetPos,pos,upper,%char%
pos+=1
If pos<>0
StringMid,char,lower,%pos%,1
}
StringTrimLeft,string,string,1
string=%string%%char%
}
ToolTip,Selection converted to iNVERTED cASE
SetTimer,TOOLTIP,On
Gosub,PASTE
Return
ABOUT:
MsgBox,0,CAPshift,CAPshift slows down and extends the caps lock key.`n`nHold down caps lock for 0.4
sec to toggle caps lock on or off.`nHold for 1.2 sec to show a menu that converts selected text to
UPPER CASE, lower case, Title Case or iNVERT cASE.`n`nSkrommel @2005 (Modified by nascent)
Return
QUIT:
ExitApp |
Last edited by nascent on Sat Dec 03, 2011 4:05 am; edited 2 times in total |
|
| Back to top |
|
 |
Carrozza
Joined: 05 Jul 2009 Posts: 184
|
Posted: Thu Nov 10, 2011 7:09 am Post subject: |
|
|
| Interesting stuff here. |
|
| Back to top |
|
 |
Foo
Joined: 09 Feb 2006 Posts: 37
|
Posted: Sun Nov 20, 2011 3:19 pm Post subject: |
|
|
| Thank you all. This is soooo useful! KUDOS! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|