In order to write dialogs that start with an em dash (long dash), I create an em dash from 2 en dashes:
::--::—
Following that I'd like the first letter to be capitalized, as in
— I didn't know...
Is there a simple way to do that?
Capital letter following an em dash
Re: Capital letter following an em dash
Well, the simplest approach I would imagine like this:
It adds already a space after — (in order too keep the approach simple). But there is most probably a number of alternative approaches.
Code: Select all
::--::
SendInput —%A_Space%
Input, char, L1
SendInput +%char%
return
Re: Capital letter following an em dash
It works beautifully. Thanks a bunch.
Re: Capital letter following an em dash
As it turns out, there are times when my keyboard freezes as a result of this code. It stays frozen for several minutes during which I can't type anything... Can you see the reason why and suggest a change or another code?
Re: Capital letter following an em dash
Well, i haven't really tested it much. Let me see if I can reproduce the problem... can you add some details about the circumstances of the freeze?. Does it happen after typing -- or rather randomly? Do you use other scripts that might interfere?
The more details you can give about the circumstances about the freeze and de-freeze, the better... also which AHK and Windows version are you using?
The more details you can give about the circumstances about the freeze and de-freeze, the better... also which AHK and Windows version are you using?
Re: Capital letter following an em dash
I'm using AHK 1.1.22.4 on Windows 8.
I'm not able to reproduce the problem. It happens after I type -- (the string that your code converts to m dash followed by capitalization), but most of the time there is no problem with it.
I thought about possible interference with a code (obtained from this site) to capitalize sentences followed by punctuation marks and a new paragraph (see below).
When I hit return and type --, it becomes _-. I therefore added a code similar to yours but with _- instead of --.
Finally I only use those codes for a number of programs that are in Mygroup.
My script is therefore:
#IfWinActive ahk_group Mygroup
; Capitalization following punctuation and carriage return
~.::
~!::
~?::
KeyWait, Shift
input, w, L1 t5 v, {Escape}
if(w != A_Space && w !="`n")
return
SendEvent, {Shift Down}
input, w, L1 t5 V, {Escape}{BackSpace} ; Limit to 1 character, timeout after 5 seconds
SendEvent, {Shift Up}
return
; Capitalization following -- and _-
::--::
SendInput —%A_Space%
Input, char, L1
SendInput +%char%
return
::_-::
SendInput —%A_Space%
Input, char, L1
SendInput +%char%
return
#IfWinActive
Most of time it all works fine. But every now and then the keyboard freezes. Thanks for taking the time to look at this.
I'm not able to reproduce the problem. It happens after I type -- (the string that your code converts to m dash followed by capitalization), but most of the time there is no problem with it.
I thought about possible interference with a code (obtained from this site) to capitalize sentences followed by punctuation marks and a new paragraph (see below).
When I hit return and type --, it becomes _-. I therefore added a code similar to yours but with _- instead of --.
Finally I only use those codes for a number of programs that are in Mygroup.
My script is therefore:
#IfWinActive ahk_group Mygroup
; Capitalization following punctuation and carriage return
~.::
~!::
~?::
KeyWait, Shift
input, w, L1 t5 v, {Escape}
if(w != A_Space && w !="`n")
return
SendEvent, {Shift Down}
input, w, L1 t5 V, {Escape}{BackSpace} ; Limit to 1 character, timeout after 5 seconds
SendEvent, {Shift Up}
return
; Capitalization following -- and _-
::--::
SendInput —%A_Space%
Input, char, L1
SendInput +%char%
return
::_-::
SendInput —%A_Space%
Input, char, L1
SendInput +%char%
return
#IfWinActive
Most of time it all works fine. But every now and then the keyboard freezes. Thanks for taking the time to look at this.
Re: Capital letter following an em dash
Perhaps the Input command is stuck somehow (although yet I am not sure why). I would first try to add a timeout there in the last two hostrings, too, something like L1 T3 - in this case timeout would be 3 seconds...
Re: Capital letter following an em dash
I just did that. One problem I see is that the word following -- is capitalized but in case it's a hotstring (I have hundreds of them) it's not replaced with its new string. No big deal for now. Let's see if this solves the freezing problem.
Who is online
Users browsing this forum: marypoppins_1, Rohwedder, Spawnova and 149 guests