TheSwamp
Code Red => VB(A) => Topic started by: MP on April 05, 2005, 03:35:43 PM
-
... in a forum similarly unnamed posted a response to another poster, all in annoying uppercase.
A lengthy paragraph of BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA ...
I responded with this --
Private Declare Sub keybd_event _
Lib "user32" _
(ByVal virtualKeyCode As Byte, _
ByVal stubbed As Byte, _
ByVal flags As Long, _
ByVal pointerToExtraInfo As Long)
Private Declare Function MapVirtualKey _
Lib "user32" _
Alias "MapVirtualKeyA" _
(ByVal virtualKeyCode As Long, _
ByVal translate As Long) _
As Long
Private Declare Function GetKeyState _
Lib "user32" _
(ByVal virtualKeyCode As Long) _
As Long
Private Const _
VKC_CAPSLOCK = &H14, _
TRANSLATE_TO_SCANCODE = 0, _
SCANF_KEYUP = &H2, _
SCANF_KEYEXT = &H1, _
SCANF_KEYNOTEXT = &H0, _
NULL_POINTER = 0
Sub StopShouting()
If (GetKeyState(VKC_CAPSLOCK) And 1) Then
Call keybd_event( _
VKC_CAPSLOCK, _
MapVirtualKey(VKC_CAPSLOCK, TRANSLATE_TO_SCANCODE), _
SCANF_KEYEXT Or SCANF_KEYNOTEXT, _
NULL_POINTER)
Call keybd_event( _
VKC_CAPSLOCK, _
MapVirtualKey(VKC_CAPSLOCK, TRANSLATE_TO_SCANCODE), _
SCANF_KEYEXT Or SCANF_KEYUP, _
NULL_POINTER)
End If
End Sub
Sub Main()
Call StopShouting
End Sub
Person sends me an email, "NOT TO SOUND MORE STUPID THAN I ALREADY AM ... WHAT DID ALL THAT CODING STUFF MEAN?"
True story.
An aside, if you propeller heads are curious ... keybd_event (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/keybd_event.asp), MapVirtualKey (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/mapvirtualkey.asp) and GetKeyState (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getkeystate.asp).
-
Bawahahah! Thats funny!
Hey BTW, thats perdy cool, did you write that MP?
-
I found (http://groups.google.ca/groups?hl=en&lr=&selm=224AAE92B1F4456FA9F7D827E13C0320%40in.WebX.maYIadrTaRb) a couple links (http://groups.google.ca/groups?hl=en&lr=&selm=E6DF28C54FED15C6B71EC02BC86543A5%40in.WebX.maYIadrTaRb) using google. Neither of them did exacty what I wanted and / or worked under XP, but it was enough that when I went to MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput.asp) I knew what I was looking for which enabled me to write what I wanted. Funny code (in the context that it was provided) but it does work.
I write my VB similar to my LISP, insomuch as the vertical style is concerned.
:)
-
Thanks for the code bit, that will be really helpful. I am thinking about putting it into a module that will take off caps lock when the browser has focus. That should prevent me from shouting at everyone ...
-
Glad you can use it for something Keith. I wrote and posted it as a joke - when the lads at work found out it was actually functional they lost it. Admittedly, we're a weird bunch. :)
-
That's when i found i the funniest. I teied it out and i almost wet my pants laughing!
Keith, make it so that anytime you launch TEXT, DTEXT it turns caps on.
-
I can do that ... Look for a neat little VBA app coming soon to a swamp near you..
-
Ok, boys and girls ... here (http://www.theswamp.org/lilly_pond/keith/CapsMan.exe?nossi=1) is the very first incarnation ... well if you count the code above, it is the second. I had to do alot of changes to the code so it would work properly in other Windows platforms, but credit for the original idea goes to MP.
The premise is that when a window becomes active it notifies the OS, we can intercept those calls with a simple timer, get the active window, determine what application it is from, and if it is AutoCAD, turn Caps Lock ON if it is a browser window, turn Caps Lock OFF. Well, that is how it is SUPPOSED to work.
I don't have FireFox installed here unfortunately so I am not able to verify it working properly with it. If anyone has a problem with it working properly send me a screenshot of the browser window or AutoCAD window and I will attempt to resolve the problem.
And give me some feedback ...
Enjoy .. I know that I am going to use it...
-
It works just fine in Firefox and Autocad. That is sweet.
-
Did you see that it puts a little icon in the systray? To close the app, simply right click on the icon and select EXIT, otherwise it stays running in the background.
Total memory usage in my tests has been observed between 3 and 5 megs, while it is a little high for the size of the app, I think most of it can be attributed to the overhead needed to run in the systray.
-
Well, it works fine going to FireFox, but does not work going to Autocad(Actually LandDesktop3 which is based on R2002)
How hard would it be to add options for email/newsgroup clients?
-
*lol* Awesome! I love it!
What about this option. (Maybe this will be easier) In Acad; Toggle the caps on before the Text is typed and after the command is over, toggle it off.
-
It shouldn't be too difficult to add email and newsreaders. I was thinking of making it so that the user could add their own apps and state of CapsLock for those apps, but that was a whole lot more coding than I found myself wanting to do on a project that might amount to nothing.
I didn't have access to LDD or any of the other add-on packages offered by Autodesk, as a result I was not able to determine what criteria to use in order to properly manage it.
I'll see what I can do, in the meantime, if you can let me know which ones you want to add or simply send me a screenshot of each app you would like it to work with.
-
I'll see what I can do, in the meantime, if you can let me know which ones you want to add or simply send me a screenshot of each app you would like it to work with.
Thanks Keith.
Here's (http://www.theswamp.org/lilly_pond/jeff_m/Jeff_M_Apps4Caps.jpg?nossi=1) a pic of what I use other than Firefox.
-
I think Se7en's idea would be ideal, since there are a few areas that would be useful to have them off, such as login after screensaver was activated.
-
I DL and tried, and it appears to work when I start acad, in that it turns caplock on. When I click/alttab toa browser, it turns it off. BUT when I give acad focus, it does not turn it back on. I checked both boxes in the setup. Was that right?
BTW, I have this code that does the same thing that Se7en is suggesting, in that my code turns on caps for text commands.
Option Explicit
Private WithEvents AutoCAD As AcadApplication
'Begin Code Block
Private Const VK_CAPITAL = &H14
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private kbArray As KeyboardBytes
Private Declare Function GetKeyState Lib "user32" _
() ' (ByVal nVirtKey As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" _
() ' (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" _
() ' (kbArray As KeyboardBytes) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "TEXT" Or CommandName = "EATTEDIT" Or CommandName = "DTEXT" Or CommandName = "INSERT" Or CommandName = "DDATTE" Or _
CommandName = "DDEDIT" Then
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = 1
SetKeyboardState kbArray
End If
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "TEXT" Or CommandName = "EATTEDIT" Or CommandName = "DTEXT" Or CommandName = "INSERT" Or CommandName = "DDATTE" Or _
CommandName = "DDEDIT" Then
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = 0
SetKeyboardState kbArray
End If
End Sub
'End Code Block
I got this from CadVault , I think Randall Rath is the author
this goes inthe "This Drawing " module
-
I can't try your utility out because our security won't allow downloads but I'm sure it's pretty derned cool, so kudos to you Keith.
-
Can you get it by email? I'll send it to you w/o the EXE extension if that would help
-
That's a very kind offer CmdrDuh, but that will just set off a triple alarm (our scanner is not so easily fooled), so please don't.
:cheesy:
-
Updated -
Internet Explorer
FireFox
Netscape
Outlook
Outlook Express
AutoCAD products
Daron, I'll look into the possibility of having it interact with password boxes
-
That'd be cool, thanks.
-
This is a sweet app Keith.
You are without doubt one of the finest individuals I know, in fact that goes for everyone on this site. There isn't anyone here who is pretentious or too important to lend a bit of advice or support, and yes I'm even including Dent in that. Even if he is a wee bit weird.
You are all amazing.
-
Good job, Keith....albeit just one glitch I've found in the new version. Since, I assume, you are using the Title in the application bar to determine what status to use there is a conflict when using Outlook Express to access the autodesk.autocad.anything newsgroups......it appears that the "autocad" overrides the "outlook".
Thanks again, this should save a lot of us some embarassment or at least a ton of retyping..... :D
-
Well, I'll see what I can do about that ... That is why we have beta testers ... (ya didn't know you were one of them buggers did you)
*edited*
Updated .... it "should" work properly now ... If not, I'll try again ... It was basically an error in the parsing ... all should be well..
-
Keith, When I click the about button, I get a runtime error 713 message and then the app crashes.
-
Check to see if you have these files on your system.
FM20.dll
comctl32.dll
stdole2.tlb
msvbvm60.dll
-
Key Keith, looks to me like you got it nailed now!
I like it!
Thanks again,
Jeff
Oh, and I couldn't duplicate Hudster's error......
-
I have them all except the fm20.dll file.
-
Ok, then that is your problem ... It can be downloaded from Microsoft from here (http://download.microsoft.com/download/office97pro/fm2past/97/WIN98/EN-US/fm2paste.exe)
-
Keith I know this was all done in jest but it works really well. I have mine set to autoload at windows startup. Do you think you might be able to add in a quiet startup so the dialog box does not come up every time windows starts?
please!please!please!please!please!please!
-
Ok, you got what you wanted ...
To make it load quietly during windows startup, simply add /quiet to the shortcut properties i.e.
C:\MyProgs\CapsMan.exe /quiet
I was gonna do it anyway ... the new version is uploaded here (http://www.theswamp.org/lilly_pond/keith/CapsMan.exe?nossi=1) for your convenience.
Hudster, did you get the fm20.dll file downloaded and installed?
Enjoy ....
-
That's a sweet little program Keith :)
-
Thanks Keith
That was too easy.
:D
-
Maybe I'll make a little install proggie for it ... I have also been looking at giving the user the ability to add their own programs to the list. That will likely be a little bit down the road though.. I don't really have the time to devote to it right now...
-
Your little proggy is great. Thanks very much!
-
BTW ... I tried this little utility out (on Sunday I think) and have to say it's pretty nifty, good job Keith.
If you want to get ambitious you could have it (as an option on the settings dialog of course) install a shortcut in the startup folder.
Also, you could have it "learn", by pointing to a running instance of a program: "Yes, that window right there <click>. When it gets focus force caps lock on/off".
When you're not doing anything else of course.
:)
-
Hey, Pop it into the CVS and maybe a bunch of us can help out with diff ideas and stuff. (Just an idea)
-
I'll see what I have and may just do that ...
-
Any chance of getting it to turn off Caps when I go into MS Word?
-
It is a possibility ~ this project has been on hold for now until I can find the time to get it uploaded and/or completed. It has come to the point where I think the user should be allowed to add the programs on the fly.
-
Hey Keith,
Any idea when you might update this proggy? I like it alot. :-)
Thanks.
-
I finally saw this. I will have to see if this works with Softplan instead of Acad. I'm thinking I will probably have to wait until Keith gets it to where the user can add programs and specify caps or no. This would be SO nice to have.
-
Well, I had all but forgotten about this .. I still don't have a whole lot of time to devote to it .. Let me dig up the code and look at it .. I'll have to figure out where I left off ... it has been almost a ...correction it HAS been a year since I have messed with it ....
-
Thanks for checkin' up on it Keith, no big rush, just when you get time. :wink:
-
The following error or errors occurred while posting this message:
Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
I know this was yelling at me but I had to reply in hopes to draw attention so that another Johnny-Come-Lately like myself could use this absolutely sweet loving extraordinary deliciously fabulous gift that could only come from the Gods.
Thanks Keith, MP and all the Beta testers Thank you very much!!
-
Don't know How I missed this the first times around, thanks for the bump.
-
I know this was yelling at me but I had to reply in hopes to draw attention so that another Johnny-Come-Lately like myself could use this absolutely sweet loving extraordinary deliciously fabulous gift that could only come from the Gods.
Thanks Keith, MP and all the Beta testers Thank you very much!!
I've been thinkin' about bumpin' this one to the top lately meself. THX Krushert.
Any time you can Keith...