Topics - hgondalf [ switch to compact view ]

Pages: [1]
1
Coding Snacks / re-map capslock function
« on: July 05, 2013, 07:38 AM »
I’m a thumb-fingered typist, so I keep hitting capslock by mistake, and sometimes +capslock.  I tried CapShift, but because of the accidental pressing of +capslock, I still get lines of ALL CAPS. I don’t need a beep or popup window. 

What I would like to do is:

  • Map Capslock to Shift. Make it a shift key. When I use the remapping suggestions in the Autohotkey help, pressing and holding Capslock and typing aaaaaa gives me Aaaaa, not AAAAA as I would get by pressing and holding Shift.
     
  • Toggle the capslock function on and off with ^Capslock.

Many thanks...

2
Finished Programs / SOLVED: convert html tags/attributes to lowercase
« on: September 02, 2012, 11:59 AM »
The problem I need to solve is this: I have lot of books that I have typeset in Framemaker 5.5.6, Pagemaker 7, or Word format.  I need t o convert them to e-books: mobi, epub, etc format. I will be using calibre.exe for the conversion. E-book source is always in html. I want to use proper html/css programming so that there is a uniformity to the look & feel of the e-publications.

All of the word processing apps have an “export to html” function. Trouble is, the output html is all upper case, e.g., <P ALIGN="center">. I like to code web pages so that they comply with xhtml 1.0 strict, which means no upper case tags or attributes, among other things. (No ALIGN attribute, for instance!)

I have in mind a little app that would rest on the desktop, that I could drag and drop a file onto. Something like the good old DOS2UNIX.exe that converts line endings from CRLF to LF. No GUI, in other words.

I have started working on a little autohotkey app, but I''m not so skilled. (If someone would just help me with the code, I would be very grateful!) The code I have so far is copied below, but I consider it to be pseudocode rather than actual code.

BTW, this is exactly the type of app that is best written in assembler, because it's so simple. Why didn't anybody think of it before? --Google searches don't even come close. 

Logic, in brief:
Set a couple of boolean variables to false, and a pointer to 0
Scan through the file byte by byte looking for "<"   ** NOTE
If found, go into conversion mode, lowercase everything
if converting, and next character is " quote mark, temporarily stop converting
on second " quote mark, resume converting
until ">" is found
until EOF

** Since the source file is output from a word processor, all instances of “<” etc are automatically converted to their html codes &lt; etc, so any “<” encountered will have to be the start of an html tag.

------------------------------------ code follows

; maxmem default = 64 MB. Inputfile must be less than 64MB

filecopy, test-case.html, test-case.bak, 1 ; overwrite any existing bak file
filegetsize, FSize, test-case.html             ; test-case.html is my test file
; msgbox, "Size is "%FSize%

Ptr = 0       ; pointer to character position in BigStr
InMarkup = 0  ; false
QuoStr = 0    ; false
TChar =       ; temp char to hold bigstr character

fileread, BigStr, test-case.html
FSize := StrLen(BigStr)
; msgbox Outside loop. Filesize: %FSize% Ptr: %Ptr%     ; for debugging
if not errorlevel
{
;  msgbox Not errorlevel              ; for debugging
  loop while (%Ptr% < %FSize%)
  {
    msgbox In loop while...          ; for debugging
    if (InMarkup)
      {
      if (!QuoStr)
        {
          if (TChar >= "A" && TChar <= "Z") {
            BigStr%Ptr% := %TChar%+32 }
          if (TChar==34) {
            QuoStr:=1  }
          if (TChar= ">") {
            InMarkup:=0 }
        }
      if (TChar==34) {
        QuoStr:=0 }
      }
    else
      {
        if (TChar = "<" && BigStr%Ptr%+1<>"!") {
          InMarkup:=1 }
      }
    Ptr:=%Ptr%+1
  }
 }
  FileDelete, test-case.html
  FileAppend, %BigStr%, test-case.html
  BigStr =  ; Free the memory.



------------------------------------ code ends

3
I find the use of a shortcut bar, even with lots of submenus, much faster to navigate than the Start menu. I use old MS Office (97) shortcut bar. 

Being greedy for desktop space (because I often have a half-dozen or more apps up and running, I have formerly put the Office shortcut bar into the title bar area. Even so, this blocks the control buttons on some windows or the extended information in the title bar in others.

If I simply hide the shortcut bar, I'm always tripping it when I run the cursor to the top menu of an app.

Could  that nifty run-and-hide macro be modified to hide/restore the MS Office Shortcut bar?

I would be ever so grateful!

-Harry


4
Post New Requests Here / Silent msgbox() popup in VBA for Word
« on: May 06, 2010, 09:08 AM »
I write lots of VBA applications in the course of my work.  Often I use a msgbox() function, with buttons Yes, No, Cancel, to get a 3-way selection, e.g.,

Select case msgbox("Are you Hot (yes), Cold (no), or Lukewarm (cancel)", VBYesNoCancel)
   case vbyes :  <some code>
   case vbno :  <some code>
   case vbcancel :  <some code>
end select

Trouble is, looping through a long document causes the message box to pop up dozens of times, severely annoying my co-workers and driving me crazy. 

I know I can turn off the notification sound in the Control Panel.  How about writing a little app that could be called from VBA, that would turn on/turn off the sound?  My VBA code would then look like this:

   x = shell ("c:\utils\soundoff.exe off")
  < a little timer delay >
   messgebox ( ) parsing
   x = shell ("c:\utils\soundoff.exe on")

The shell function in VBA returns a value, 0 if no problem, or the program ID otherwise, which is why I have the dummy parameter variable x. 

One can set/reset the sounds in the registry, but I wonder if it is tempting fate to write/rewrite the registry...

How about simply muting the speakers for a moment while the messgebox come up?

BTW I'm running Windows XP HE, but I have Vista and 98 also.

Thanks! 

5
Dear coders,

For reasons of security and privacy I start my Windows XP with the login screen. No auto-login.  I would like to use AHK to write an app that would run (once) at boot time, that is, at or before the appearance of the login screen.

Could anyone give me tips on how to do this? 

Thanks

-Harry

Pages: [1]
Go to full version