AutoHotkey Community

It is currently May 27th, 2012, 8:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: August 8th, 2005, 8:25 am 
Offline

Joined: August 8th, 2005, 3:44 am
Posts: 13
Lawdy, Miz Mawdy, you make it all look s-o-o-o easy! And so fast!! :shock:

That is just beautiful, and we can't thank you enough. You write such beautiful, logical, compact code as well. I can't begin to do anything like that, but I know just enough to appreciate good work when I see it. :D

Once we get these additions in, I will see what I can figure out next weekend about the possible ways of beating that IT trailing space into submission.

BTW, it is the Hotstrings that originally got me interested in AHk, and I love the fact they allow the whole gamut of activations from expansions in-place without delimiters, to expansions with a "marker key," to expansions on standard delimiters, or any combo one might care to devise.

However, there are a lot of things that need to be added before AHk could compete with IT as a full expander. Those trailing spaces in IT are actually a great timesaver, eliminating even more taps on the spacebar, since they do magically disappear if you type a punctuation mark or closing character. Also, IT allows for duplicate shorts with Shift/Ctrl or appended number selection from an advisory that can be set to show 1 to 15 lines of choices at the bottom of the screen, allows you to make entries without typing all the characters in your short if you don't need to. It also automatically brings up the common continuations for the words you just typed in those advisories, based on compilation of glossaries from folders of completed work. You can add continuation phrases with just one keystroke, and with a well-honed glossary you may be able to add several sentences with a half-dozen keystrokes or less. The aggravations are that it does not delete its autospaces in numeric series, it does not allow you to begin a short form with a number or use any symbols in short forms, it does not provide for in-place expansion without a preceding space, and it offers only the most primitive command and control. For all those reasons, AHk is a supplementary program to IT at the moment, not a replacement. It is on a par with ActiveWords in that respect, possessing some things AW doesn't have and lacking some things AW does have. I do hope that AHk will continue to add features, and I'm sure I will be bugging people here endlessly with questons about how to achieve some of the additions I would like to have to it.

I also hope that someday in the not too distant future, someone will decide to take a crack at a Linux port for AHk, although I understand that would be a huge project. :(

Anyway, thanks again for all your time helping us, and for being so nice and patient with a couple of dumb newbies!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2005, 9:45 am 
Offline

Joined: August 8th, 2005, 3:44 am
Posts: 13
Laszlo, again I cannot thank you enough! It took very little time to work my way through your great sample code, and below is the completed script, which has all the bells and whistles barring working out a method to check for that trailing space on an IT expansion. For the moment, I have stuck in a double strike on the single quote as a fast backspace on the home row, but I will be investigating your various suggested approaches as I work my way through the AHk help files.

Note: original code posted has been replaced with fully commented code with tweaks and revisions after a little beta testing.

Code:
;Laszlo-Rev4Autospace1c.ahk
;HOTKEY SCRIPT FOR AUTOSPACING

;Spacing is automatically added after punctuation marks.
;If a period or colon is typed inside a number string,
;the autospacing is automatically removed.
;Inadvertent manual spacing is also automatically removed.
;To manually suppress autospacing, type the punctuation mark twice.
;Manual suppression must be used for a comma inside a number string.
;2 single quotes will do quick backspace to insert delimiter following
;expansion with trailing space.
;If using this script with InstantText, you need to comment out
;  (put semicolons at the start of the lines) autospacing code
;  pertaining to any key used as a marker key and substitute that using
;  CapsLock+MarkerKey to avoid losing the removal of spaces at the end of
;  expansions when the next character typed is a delimiter.
;  Also use entries to set CapsLock+MarkerKey(s) to clear advisories.   

;Set all variable count registers to a value of 0
Comma = 0
Semic = 0
Colon = 0
Period = 0
Questn = 0
Exclam = 0
SQuote = 0

;Infinite loop constantly monitors keyboard input
;and resets count registers for variables after each
;monitored autospacing Hotkey key press/series of sequential presses
 
Loop
{
   Input key,I L1 M V,{TAB}{ENTER}{ESC}{BS}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}

;Pressing any key in curly brackets above will reset variable count registers.
;This will prevent actions associated with sequential key presses
;when you change focus after the first key press.
;You may add/subtract keys from the list as needed for the way you work
;and the actions you have assigned to various keys.   
   
   Comma = 0
   Semic = 0
   Colon = 0
   Period = 0
   Questn = 0
   Exclam = 0
   SQuote = 0
}
Return

;commented-out code under punctuation marks removes manual space
;before punctuation, which can have some undesirable effects
;(e.g., try typing .Net with this feature active;
; you'll end up in an endless loop).
 
;Comma autospacing
$,::
;    IfEqual Comma,0, {
;       IfEqual key,Space, Send {BS 1}
;       Send ,,{Space 1}
;    }
   IfEqual Comma,0, Send ,,{Space 1}
   Else IfEqual Comma,1, Send {BS 1} 
   Else Send ,,
   Comma++
Return

;Semicolon autospacing for IT compatibility (uses CapsLock+; for ;)
;Use either this semicolon entry or the one below, not both.
CapsLock & `;::
;    IfEqual Semic,0, {
;      IfEqual key,Space, Send {BS 1}
;       Send {ESC}`;{Space 1}
;    }
    IfEqual Semic,0, Send {ESC}`;{Space 1}
     Else IfEqual Semic,1, Send {BS 1} 
     Else Send `;
    Semic++
Return

;Semicolon autospacing
;$;::
;;    IfEqual Semic,0, {
;;      IfEqual key,Space, Send {BS 1}
;;       Send `;{Space 1}
;;    }
;   IfEqual Semic,0, Send `;{Space 1}
;   Else IfEqual Semic,1, Send {BS 1} 
;   Else Send `;
;   Semic++
;Return

;Colon autospacing
$+;::
;    IfEqual Colon,0, {
;       IfEqual key,Space, Send {BS 1}
;       Send +;{Space 1}
;    }
   IfEqual Colon,0, Send +;{Space 1}
   Else IfEqual Colon,1, Send {BS 1} 
   Else Send +;
   Colon++
Return

;Period autospacing
$.::
;  IfEqual Period,0, {
;     IfEqual key,Space, Send {BS 1}
;     Send .{Space 1}
;  }
   IfEqual Period,0, Send .{Space 1}
   Else IfEqual Period,1, Send {BS 1} 
   Else Send .
   Period++
Return

;Question mark autospacing
$+/::
;    IfEqual Questn,0, {
;       IfEqual key,Space, Send {BS 1}
;       Send +/{Space 1}
;    }
   IfEqual Questn,0, Send +/{Space 1}
   Else IfEqual Questn,1, Send {BS 1} 
   Else Send +/
   Questn++
Return

;Exclamation point autospacing
$+1::
;    IfEqual Exclam,0, {
;       IfEqual key,Space, Send {BS 1}
;       Send +1{Space 1}
;    }
   IfEqual Exclam,0, Send +1{Space 1}
   Else IfEqual Exclam,1, Send {BS 1} 
   Else Send +1
   Exclam++
Return

;Remove autospacing at end of line
$Enter::
   IfEqual Comma,1, Send {BS 1}
   Comma = 0
   IfEqual Semic,1, Send {BS 1}
   Semic = 0
   IfEqual Colon,1, Send {BS 1}
   Colon = 0
   IfEqual Period,1, Send {BS 1}
   Period = 0
   IfEqual Questn,1, Send {BS 1}
   Questn = 0
   IfEqual Exclam,1, Send {BS 1}
   Exclam = 0
   Send {Enter}
Return

;Remove autospacing at end of tabbed entry
$Tab::
   IfEqual Comma,1, Send {BS 1}
   Comma = 0
   IfEqual Semic,1, Send {BS 1}
   Semic = 0
   IfEqual Colon,1, Send {BS 1}
   Colon = 0
   IfEqual Period,1, Send {BS 1}
   Period = 0
   IfEqual Questn,1, Send {BS 1}
   Questn = 0
   IfEqual Exclam,1, Send {BS 1}
   Exclam = 0
   Send {Tab}
Return

;Remove inadvertent manual spacing after punctuation
$Space::
   IfEqual Comma,1, Send {BS 1}
   Comma = 0
   IfEqual Semic,1, Send {BS 1}
   Semic = 0
   IfEqual Colon,1, Send {BS 1}
   Colon = 0
   IfEqual Period,1, Send {BS 1}
   Period = 0
   IfEqual Questn,1, Send {BS 1}
   Questn = 0
   IfEqual Exclam,1, Send {BS 1}
   Exclam = 0
   Send {Space}
;The code below and the first code under punctuation marks removes manual 
;spacing before a punctuaton mark--not necessarily desirable behavior. 
;  key = Space
Return

;type 2 single quotation marks to backspace
$'::
   IfEqual SQuote,0, Send '
   Else IfEqual SQuote,1, Send {BS 2}
   SQuote++
Return

;set CapsLock+IT MarkerKey(s) to send ESC before MarkerKey(s) to clear advisories
CapsLock & ':: Send {ESC}'
Return
 
;Remove autospacing following periods and colons
;inside numeric strings
~0::
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
   If key is integer
      IfEqual Period,1
         Send {Left}{BS 1}{Right}
      IfEqual Colon,1
         Send {Left}{BS 1}{Right}
;optional removal of spacing after comma inside number string
;remove semicolon in front of next 2 lines to activate
;      IfEqual Comma,1
;         Send {Left}{BS 1}{Right}
Return

;Reset count registers when focus is changed by mouse
~LButton::
   Comma = 0
   Semic = 0
   Colon = 0
   Period = 0
   Questn = 0
   Exclam = 0
   SQuote = 0
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2005, 1:20 am 
Offline

Joined: August 4th, 2005, 3:56 pm
Posts: 41
At the end of this post is the script that I am using. Note that I have the spaces section commented out because I find it interferes with my trigger key (double spacebar) for ActiveWords, another program I use frequently, and the semicolon section also commented out, as it is my "marker key" in Instant Text. That has nothing to do with my question, though, at least I don't think so. Perhaps it could and I'm so new to AHK that I don't realize it!

It's the colon section I'm here about. It has a glitch that I cannot figure out how to cure. It seems to always work, every single time, if I type 10:00 or anything and then :00. Yet sometimes (not always), typing 10:30 will erase the colon and the last number and wind up as "103". It isn't only the 3 key, but the 2, 4, 5, etc. Typing decimal numbers with the period never causes this. It is only with the colon. And to be clear, it isn't with just 10:30. Could be 3:45 or any other combo. Just never with :00!

Here is what I have tried so far. Instead of BS, I tried using this:

Code:
;Colon autospacing
$+;::
;    IfEqual Colon,0, {
;       IfEqual key,Space, Send {Left 1}{Del}
;       Send +;{SPACE}{LEFT}{RIGHT}{SPACE}
;    }
 IfEqual Colon,0, Send +;{SPACE}{LEFT}{RIGHT}{SPACE}
  Else IfEqual Colon,1, Send {Left 2}{Del 2}
  Else Send +;
  Colon++
Return


Exact same problem occurred.

I tried this:

Code:
$+;::
IfEqual Colon,0, {
IfEqual key,Space, Send {Left 2}
Send +;{SPACE}{LEFT}{RIGHT}{SPACE}
}
Else IfEqual Colon,1, Send {Left 2}
Else Send +;
Colon++
Return


No luck there, either.

I tried sticking this in:

if GetKeyState("Shift") ; Shift key is up

Thought that was a possibility, but it did not help.

And lastly, I tried sticking in a setkeydelay, and I tried each from 0 through 10, none of them changed anything. However, I'm not certain I put it in the right place. I put it immediately below the beginning, as in:

$+;::
SetKeyDelay, 10

I'm uncertain what else to try. It's been suggested I look into Threads. Would that be the right track to pursue? I am incredibly happy with this script as it is. I can't tell you how wonderful it is for me! I have a very few other things I want to tweak on it for my own particular needs and I think I can, but I do not believe I'm going to figure out the fix for the colon issue. Can anyone help?

Thank you!

(As stated, the script I am currently using stands as below)


Code:
;ITspacingscript.ahk

Comma = 0
Semic = 0
Colon = 0
Period = 0
Questn = 0
Exclam = 0
SQuote = 0

Loop
{
  Input key,I L1 M V,{TAB}{Esc}{BS}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}
 
  Comma = 0
  Semic = 0
  Colon = 0
  Period = 0
  Questn = 0
  Exclam = 0
  SQuote = 0
}

Return

$,::
  IfEqual Comma,0, {
     IfEqual key,Space, Send {BS 1}
     Send ,,{Space 1}
  }
  Else IfEqual Comma,1, Send {BS 1} 
  Else Send ,,
  Comma++
Return

;$;::
  IfEqual Semic,0, {
     IfEqual key,Space, Send {BS 1}
     Send `;{Space 1}
  }
  Else IfEqual Semic,1, Send {BS 1} 
  Else Send `;
  Semic++
Return

$+;::
  IfEqual Colon,0, {
     IfEqual key,Space, Send {BS 2}
     Send +;{Space 2}
  }
  Else IfEqual Colon,1, Send {BS 2} 
  Else Send +;
  Colon++
Return

$.::
  IfEqual Period,0, {
     IfEqual key,Space, Send {BS 2}
     Send .{Space 2}
  }
  Else IfEqual Period,1, Send {BS 2} 
  Else Send .
  Period++
Return

$+/::
  IfEqual Questn,0, {
     IfEqual key,Space, Send {BS 2}
     Send +/{Space 2}
  }
  Else IfEqual Questn,1, Send {BS 2} 
  Else Send +/
  Questn++
Return

$+1::
  IfEqual Exclam,0, {
     IfEqual key,Space, Send {BS 2}
     Send +1{Space 2}
  }
  Else IfEqual Exclam,1, Send {BS 2} 
  Else Send +1
  Exclam++
Return

$Enter::
  IfEqual Comma,1, Send {BS 1}
  Comma = 0
  IfEqual Semic,1, Send {BS 1}
  Semic = 0
  IfEqual Colon,1, Send {BS 2}
  Colon = 0
  IfEqual Period,1, Send {BS 2}
  Period = 0
  IfEqual Questn,1, Send {BS 2}
  Questn = 0
  IfEqual Exclam,1, Send {BS 2}
  Exclam = 0
  Send {Enter}
Return

$Tab::
  IfEqual Comma,1, Send {BS 1}
  Comma = 0
  IfEqual Semic,1, Send {BS 1}
  Semic = 0
  IfEqual Colon,1, Send {BS 2}
  Colon = 0
  IfEqual Period,1, Send {BS 2}
  Period = 0
  IfEqual Questn,1, Send {BS 2}
  Questn = 0
  IfEqual Exclam,1, Send {BS 2}
  Exclam = 0
  Send {Tab}
Return

;$Space::
  IfEqual Comma,1, Send {BS 1}
  Comma = 0
  IfEqual Semic,1, Send {BS 1}
  Semic = 0
  IfEqual Colon,1, Send {BS 2}
  Colon = 0
  IfEqual Period,1, Send {BS 2}
  Period = 0
  IfEqual Questn,1, Send {BS 2}
  Questn = 0
  IfEqual Exclam,1, Send {BS 2}
  Exclam = 0
  Send {Space}
  key = Space
Return

~0::
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
  If key is integer
     IfEqual Period,1
        Send {Left}{BS 2}{Right}
     IfEqual Colon,1
        Send {Left}{BS 2}{Right}
     IfEqual Comma,1
 Send {Left}{BS 1}{Right}     
Return

^-::
Suspend, On
Return
^=::
Suspend, Off
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2005, 1:39 am 
Offline

Joined: August 8th, 2005, 3:44 am
Posts: 13
For any of you who aren't speed typists, the issue here is clearly one of typing speed versus AHk's response time. The numbers that cause the expansion to mess up are the ones typed by the left hand; in other words, this happens when typing alternate keystrokes (colon and the numeral) with opposite hands, which allows the fastest sequential key strikes. OTOH, a zero is typed with the same finger as the colon, which makes that sequence of keystrokes the slowest. All I can figure is that it is taking longer for AHk to "hear" the semicolon plus shift combo than to hear a simple period, and that causes it to miss the next number input when the keystrikes come too quickly.

So I can diagnose the problem, I just don't know the way you solve this in AHk. Surely we MTs who just stumbled on this lovely program aren't the only ones who ever tried to use it with touch typing speeds of 80 to 120 words per minute? Is there a way to buffer the keystrokes so that AHk hears them all in the right sequence every time?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2005, 2:31 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I cannot reproduce your problem (maybe I am too slow or my 2 GHz Pentium-M laptop is too fast). Try experimenting with the following
Code:
Process Priority,,High
SetKeyDelay 20,20 ; slows down Send, -1, -1 is the fastest
SetBatchLines -1 ; executes the script the fastest


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2005, 3:51 am 
Offline

Joined: August 4th, 2005, 3:56 pm
Posts: 41
Thanks for experimenting, Laszlo, I appreciate it. Putting that in the script really does cause a change I can see. I experimented with the SetKeyDelay numbers quite a bit and could watch the differences, some making it not even work as well as before, some better but not curing the problem. I experimented with Realtime and Low too, just to see.

Well, I started to look at the Repeat Delay and Repeat Rate settings under Keyboard properties, too. If you can't reproduce it and tonks can't reproduce it, well, it must be something peculiar to my setup. I'll keep trying to nail it down. Meanwhile, thanks once again for the help. As I said, I am loving this no end. 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2005, 4:06 am 
Offline

Joined: August 8th, 2005, 3:44 am
Posts: 13
Harrie, I actually can repeat the problem if I concentrate on really, really speed typing. I'm just not naturally quite as fast a typist as you and some other MTs are. It is a real issue, though, and I will be interested to hear what happens when you play around with some of Laszlo's suggested settings. We definitely do need to understand what settings produce the best response time to keyboard input if AHk is going to be universally useful as an MT tool.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2006, 7:37 pm 
Harrie wrote:
Those trailing spaces in IT are actually a great timesaver, eliminating even more taps on the spacebar, since they do magically disappear if you type a punctuation mark or closing character.


Trailing spaces after typing punctuation would be nice and I hope it is on the wish list. (The script that was provided here does this except for when an abbreviation is typed.)

BTW: If one uses AutoHotKey when typing in Microsoft Word, one can get trailing spaces after typing an AutoHotKey abbreviation by having AutoCorrect provide spaces after the puncation is typed:

, = ", "
. = ". "
; = "; "

This AutoCorrect solution works perfectly with AutoHotKey abbreviation expansions. So, for example, one can type "er," and get:

"emergency room, " (with a trailing space)

or type "er." and get:
"emergency room. " (with two trailing spaces)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2006, 11:30 pm 
Offline

Joined: August 4th, 2005, 3:56 pm
Posts: 41
Guest, who are you - please come back and say! :D

I'm personally glad you posted, for two reasons. One is that it gives me a chance to really, really thank Laszlo again. Many months have gone by now, and I use this script constantly and I just adore it. It's top on my list of "can't live without," and I'm serious. Always works like a charm. So I would like to say thanks again. I use it often when I'm not working too, and now I am spoiled, having auto-spacing wherever I type.

Secondly, your Word AC idea is so perfect! I don't use AC, but I know loads and loads of people who do, and though it seems so simple to think of now that you have put it down in writing, I know I never actually thought of that before. That's really a cool one, especially for commas. I don't think we'd want to try that with periods because it would mess up numbers with decimals, but otherwise it's too cool, and I hope you don't mind if I swipe that one to share. I'm thinking about people who both use AHK abbreviations and those who don't. Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 10th, 2006, 11:54 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Harrie wrote:
really thank Laszlo again
Don't embarrass me... It was fun to take up the challenge.

I used to have experimented with Word's AC, but abandoned the idea, because in other applications those auto correct changes are not there. Writing emails, BB messages, in web forms, in editors, PowerPoint etc., without spaces after commas or periods is not nice, otherwise I had to go back to add them manually. The beauty of a pure AHK solution is that it is available in every application, you don't have to re-train your fingers each time the active window changes.

For seldom used characters, AC can be useful. I use it for ± (+-), →(-->), ≥(\>) etc., which I don't expect to appear in a text based application. But punctuation marks caused me too much trouble.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2006, 11:17 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
Trailing spaces after typing punctuation would be nice and I hope it is on the wish list. (The script that was provided here does this except for when an abbreviation is typed.)
Interesting idea. Perhaps it could be implemented by having a configurable set of ending characters after which a space is automatically sent. By default, these ending characters could consist of :;,.?!. However, of these, .?! are less certain because there are times when the added space would be undesirable (such as wanting to start a new paragraph). The program could watch for a press of the Enter key and eliminate the extra space, but that might be getting overly complicated.

I'll add it to the to-do list. Please let me know if you can think of any further refinements.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2006, 2:06 am 
Offline

Joined: April 9th, 2006, 3:50 pm
Posts: 5
Quote:
I'll add it to the to-do list.

Thanks.

Quote:
...but that might be getting overly complicated.

Yeah, at least in my experience with abbreviation expansion, I don't think you have to bother with worrying about new paragraphs.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], sjc1000, specter333 and 68 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group