I need a script that allows me to use the C key normaly and long pressing it sending the Ç key.
I've managed to make a script that does that but when I press C in the middle of a word it has some kind of delay, for instante, if I try to write "Corsair" it comes out as ocrsair, unless I type it really, really slowly.
This is what I have so far:
$c::
KeyWait, c, T0.5
If ErrorLevel {
Send {ç}
KeyWait, c
} Else
Send {c}
return
I'm a noob at autokeys, I usually make my scripts by copying similar codes from the internet and change a couple of things by trial and error but this time I'm really stuck. I'm pretty sure this is fairly easy stuff for you guys. Please help me figure this out, it would mean a lot to me.
Long press C to send Ç Topic is solved
-
- Posts: 48
- Joined: 11 Sep 2018, 12:37
Re: Long press C to send Ç
Normally a character is sent when to press down on a key. Using your code, it is sent when you release the key. This makes sense because AHK doesn't know in advance how long you'll be keeping the key pressed. However during quick typing you'll be pressing the next key before releasing this key, resulting in the problem.
Try is small alteration which will send the c on the down event but when you keep it down it will backspace and send the replacement character.
Try is small alteration which will send the c on the down event but when you keep it down it will backspace and send the replacement character.
Code: Select all
$*c::
Send {Blind}{c}
KeyWait, c, T0.5
If ErrorLevel {
Send {BackSpace}{ç}
KeyWait, c
}
return
Re: Long press C to send Ç
Here is an alternative to look at:
It's not what you asked for, but the uppercase version might make it worthwhile.
- Use triple press c to get ç
- Use Shift and triple press c gets you Ç. You only need to shift for the first c.
Code: Select all
::ccc::ç
-
- Posts: 48
- Joined: 11 Sep 2018, 12:37
Re: Long press C to send Ç
Oh my God it works like a charm!Nextron wrote:Normally a character is sent when to press down on a key. Using your code, it is sent when you release the key. This makes sense because AHK doesn't know in advance how long you'll be keeping the key pressed. However during quick typing you'll be pressing the next key before releasing this key, resulting in the problem.
Try is small alteration which will send the c on the down event but when you keep it down it will backspace and send the replacement character.Code: Select all
$*c:: Send {Blind}{c} KeyWait, c, T0.5 If ErrorLevel { Send {BackSpace}{ç} KeyWait, c } return
I'm buying a keyboard with US layout wich I'll have to get used to and this is a great way to make the Ç, wich is used very often in Portuguese. Thank you so much for your help!
-
- Posts: 48
- Joined: 11 Sep 2018, 12:37
Re: Long press C to send Ç
I'm sorry if I'm pushing it Nextron but would it be possible to add something to the script you gave me so It can send yet another key, depending on how long I press it? Dor instance at the moment if I press c it sends c if I press c for 0.5 sends ç, I wanted to press c for like 0.7 to send A for example. Is it possible?
- divanebaba
- Posts: 804
- Joined: 20 Dec 2016, 03:53
- Location: Diaspora
Re: Long press C to send Ç
Hi.
Super nice solution.
Long time I was using way below to get desired special keysNow I'm using suggestion of Nextron modified even for capital charsThis hotkey seems to block all hotstrings beginning with same char. Maybe hotkeys are always confusing hotstrings.
As long as the superstrings of Stephen Hawking are not affected, everything is fine.
@sulphuricsaliva - I can't give you any suggestion for your new task
Super nice solution.
Long time I was using way below to get desired special keys
Code: Select all
:?*c:c#:: ; <-- c# types ç
SendInput, ç
return
Code: Select all
$*c::
Send {Blind}{c}
KeyWait, c, T0.5
If ErrorLevel {
If GetKeyState("Shift", "P")
Send {BackSpace}{Ç}
else
Send {BackSpace}{ç}
KeyWait, c
}
return
As long as the superstrings of Stephen Hawking are not affected, everything is fine.
@sulphuricsaliva - I can't give you any suggestion for your new task
Re: Long press C to send Ç
You could put in another KeyWait, but for me that didn't work very reliable, so try this instead:sulphuricsaliva wrote:I'm sorry if I'm pushing it Nextron but would it be possible to add something to the script you gave me so It can send yet another key, depending on how long I press it? Dor instance at the moment if I press c it sends c if I press c for 0.5 sends ç, I wanted to press c for like 0.7 to send A for example. Is it possible?
Code: Select all
*c::
If c_remap
Return
Send {Blind}{c down}
c_remap:=A_TickCount
Return
*c up::
Send {Blind}{c up}
If (A_TickCount-c_remap>700)
Send {BackSpace}Long
Else If (A_TickCount-c_remap>400)
Send % "{BackSpace}" (GetKeyState("Shift", "P") ? "Ç" : "ç")
c_remap:=0
Return
Something like that: They're either not seen or ignored. In order to enable that, you need to make sure output is sent using SendEvent and not SendInput, and that the SendLevel is increased. See the code below. I tried to incorporate it in the code above, but I encountered a bug there.divanebaba wrote:This hotkey seems to block all hotstrings beginning with same char. Maybe hotkeys are always confusing hotstrings.
Code: Select all
#InputLevel 1
*c::
Send {Blind}c
KeyWait, c, T0.5
If ErrorLevel
SendEvent % "{BackSpace}" (GetKeyState("Shift", "P") ? "Ç" : "ç")
KeyWait, c
return
#InputLevel 0
::çc::Test
Re: Long press C to send Ç
Wow!! very nice man!!
is this kind of coding able to intercept keys before they get written in specific gui edit controls?
Lets say you want a custom "Number only" "Minus sign/negative value" "commas replaced by dots"?
is this kind of coding able to intercept keys before they get written in specific gui edit controls?
Lets say you want a custom "Number only" "Minus sign/negative value" "commas replaced by dots"?
Re: Long press C to send Ç
It could, but using a keyboard hook is system wide, so it's like taking a cannon to kill a mosquito. Even then, you could get around it by pasting content or ControlSetText. I think you're better of by using the edit's g-label to set some content validation on each change of the edit box and restoring the last valid content if it contains something not allowed.
Re: Long press C to send Ç
Thanks for confirmation! We are trying to do just that with Wolf_II in the thread named "Gui Edit Control Number and decimals..."Nextron wrote:It could, but using a keyboard hook is system wide, so it's like taking a cannon to kill a mosquito. Even then, you could get around it by pasting content or ControlSetText. I think you're better of by using the edit's g-label to set some content validation on each change of the edit box and restoring the last valid content if it contains something not allowed.
thank you for help
-
- Posts: 48
- Joined: 11 Sep 2018, 12:37
Re: Long press C to send Ç
Ok maybe this last request is probably impossible. Is there a way to long press a key to create dinamic accents. Something like long pressing - to make a tilde (~) that'll be applied to the next letter I press, like a or o to get ã or õ.
Re: Long press C to send Ç Topic is solved
There are probably better ways, since this requires you to manually define each of your keys, but it should get you started.
Code: Select all
#UseHook,On
-::
'::
Send,% A_ThisHotkey
KeyWait,% A_ThisHotkey,T0.5
If ErrorLevel {
Send {BackSpace}
DeadKey:=A_ThisHotkey
}
KeyWait,% A_ThisHotkey
Return
#If DeadKey("'")
o::ó
O::Ó
a::á
#If DeadKey("-")
o::õ
a::ã
#If
DeadKey(Key){
Global DeadKey
If _:=(DeadKey=Key)
DeadKey:=""
Return _
}
-
- Posts: 48
- Joined: 11 Sep 2018, 12:37
Re: Long press C to send Ç
Works perfectly, thank you once more
- divanebaba
- Posts: 804
- Joined: 20 Dec 2016, 03:53
- Location: Diaspora
Re: Long press C to send Ç
To prevent unwanted char when pressing Ctrl + c key I choosed this wayHow to use SendEvent or SendLevel to prevent hotstrings by using this code I could not realize.
Code: Select all
...
Send % (GetKeyState("Ctrl", "P") ? "^c" : GetKeyState("Shift", "P") ? "{BackSpace}Ç" : "{BackSpace}ç")
...
Who is online
Users browsing this forum: Google [Bot], tiska and 100 guests