Automatic Capitalisation

Share your favorite FastKeys commands
Post Reply
User avatar
ShadeBlack
Posts: 19
Joined: Dec 10th, ’14, 10:18

Post by ShadeBlack » Feb 28th, ’15, 20:41

Hi there.

please move this to the appropriate forum section if you feel it's better suited elsewhere... I wasn't quite sure!

I was wondering if it would be possible to have a feature / script that automatically sends {capslock} if the user is on a line of text where the last character is capitalised.
I think this might be a little odd for people to understand why I would want this.. so I'll try to explain.

when I write comment blocks in any coding language, I always write in capital letters, and then any code is usually done in lower case with the exception of declarations, which i do in case-type.

basic vb example:

Code: Select all

'DECLARE
Dim strSQL as string
Dim strMsg as string

'SET
strMsg = "example text"
strSQL = "INSERT INTO tbl_Log ( Log ) SELECT '" & strMsg & "' AS Log;"
CurrentDb.Execute (strSQL)
I do lots of languages in this style of commenting:
html, php, css, js, sql, .net and more

The ctrl+caps lock utility helps a lot when I've done something in the wrong case, which is really great, but it would be really nice to make this semi-automated for me.
I'm not sure exactly how this would work though - so if it's possible to script it easily in fastkeys, I'll give that a go too. A point in the right direction for this method would be appreciated too :)

Hope that all made sense!
kind regards,
kyle.
User avatar
Marko
Posts: 1719
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Mar 1st, ’15, 18:56

Very interesting idea but hard to implement. It would require a timer which would constantly (every 100ms or so) check the last character in a line and switch CapsLock key on or off. This would make a typing non-responsive and possibly introduce other issues.

Therefore I would propose something similar. Set the code below to the shortcut - when triggered it checks the last line character and changes the text caps accordingly. Let me know if this helps. Maybe it would be better to check the first character in a line (if comment).

Code: Select all

Send, {Home}+{End}
Old:=Clipboard
Clipboard:=""
Send, ^c
ClipWait 1
Clipboard=%Clipboard%
char:=SubStr(Clipboard, 0)
if char is upper
	StringUpper Clipboard, Clipboard
Send %Clipboard%
Sleep 500
Clipboard:=Old
User avatar
ShadeBlack
Posts: 19
Joined: Dec 10th, ’14, 10:18

Post by ShadeBlack » Mar 3rd, ’15, 00:11

I will definitely give this a proper go when i get some time to myself over the weekend.

thanks for the quick start! :)
Post Reply