Automatic Capitalisation

Share your favorite FastKeys commands
User avatar
Posts: 14
Joined: Wed Dec 10, 2014 10:18 am
Location: England

Automatic Capitalisation

PostPosted by ShadeBlack » Sat Feb 28, 2015 8:41 pm

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:
'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.

Site Admin
User avatar
Posts: 641
Joined: Sat Mar 02, 2013 9:02 pm

Re: Automatic Capitalisation

PostPosted by Marko » Sun Mar 01, 2015 6:56 pm

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
Posts: 14
Joined: Wed Dec 10, 2014 10:18 am
Location: England

Re: Automatic Capitalisation

PostPosted by ShadeBlack » Tue Mar 03, 2015 12:11 am

I will definitely give this a proper go when i get some time to myself over the weekend.
thanks for the quick start! :)

Return to User Commands and Scripts

Who is online

Users browsing this forum: No registered users and 0 guests