Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
lluke
Posts: 36
Joined: 12 Feb 2018, 19:10

Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

11 Mar 2018, 16:49

I have remaping code for Ctrl. Ctrl + key behaves as normal. If Ctrl is pressed alone it behaves as ESC.

#InstallKeybdHook

Code: Select all

LControl::
g_DoNotAbortSendEsc := true
Send {LControl Down}
KeyWait, LControl
Send {LControl Up}
if ( A_PriorKey = "LControl")
{
	if(g_DoNotAbortSendEsc){
		Send {Esc}
	}
}
return

~*^a::
~*^b::
~*^c::
~*^d::
~*^e::
~*^f::
~*^g::
~*^h::
~*^i::
~*^j::
~*^k::
~*^l::

~*^m::
~*^n::
~*^o::
~*^p::
~*^q::
~*^r::
~*^s::
~*^t::
~*^u::
~*^v::
~*^w::
~*^x::
~*^y::
~*^z::
~*^1::
~*^2::
~*^3::
~*^4::
~*^5::
~*^6::
~*^7::
~*^8::
~*^9::
~*^0::
~*^Space::
~*^Backspace::
~*^Delete::
~*^Insert::
~*^Home::
~*^End::
~*^PgUp::
~*^PgDn::
~*^Tab::
~*^Return::
~*^,::
~*^.::
~*^/::
~*^;::
~*^'::
~*^[::
~*^]::
~*^\::
~*^-::
~*^=::
~*^`::
~*^F1::
~*^F2::
~*^F3::
~*^F4::
~*^F5::
~*^F6::
~*^F7::
~*^F8::
~*^F9::
~*^F10::
~*^F11::
~*^F12::

    g_DoNotAbortSendEsc := false
    return
Problem appears when I type polish characters like: "ą"(Alt Gr + a) etc. "ę","ń". Scripts behaves like Ctrl is presssed and not released. I have to press ESC(or Ctrl alone) to release this action.

How to fix this behaviour so I type polish characters and not beeing blocked?
Rohwedder
Posts: 1521
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

12 Mar 2018, 02:02

Hallo,
only a try:

Code: Select all

~<^>!::Return
LControl::
g_DoNotAbortSendEsc := true
etc.
lluke
Posts: 36
Joined: 12 Feb 2018, 19:10

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

12 Mar 2018, 04:43

What is going on here actually?
Rohwedder wrote:~<^>!::Return
It looks like it solve a problem. Thank you. :)
Rohwedder
Posts: 1521
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs  Topic is solved

12 Mar 2018, 06:41

Hallo,
~ (Tilde) when the hotkey fires, its key's native function will not be blocked.
<^>! = AltGr see http://ahkde.github.io/docs/Hotkeys.htm#AltGr
:: = Hotkey
Return = do not do anything else!
lluke
Posts: 36
Joined: 12 Feb 2018, 19:10

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

10 Apr 2018, 07:32

This solution works for pervious example but I have tried this solution:

Code: Select all

~<^>!::Return
for script below and unfortunatelly it dosn't work in this case and accent characters blocks. What might be wrong?

Code: Select all

$Ctrl::Send {Ctrl Down}
$Ctrl UP::
    ChordIsBroken := True
    Send {Ctrl Up}
    Return
^q::
    ChordIsBroken := False
    Input, OutputVar, L1 M
    If (!ChordIsBroken && Asc(OutputVar) = 6)
    {
        MsgBox "Hello, World!"
    }
    Else
    {
        SendInput %OutputVar%
    }
    Return
Rohwedder
Posts: 1521
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

13 Apr 2018, 03:59

Hallo,
my "solution" unblocks Alt Gr and this is unnecessary here because Alt Gr seems not to be blocked
(my german "Alt Gr"-characters: @€µ|~²³{[]}\ can be entered).
Which accent characters are blocked, and how exactly are they entered?
I do not know what your script should do, but I would replace this:

Code: Select all

$Ctrl::Send {Ctrl Down}
$Ctrl UP::
    ChordIsBroken := True
    Send {Ctrl Up}
    Return
with that:

Code: Select all

~Ctrl Up::ChordIsBroken := True
lluke
Posts: 36
Joined: 12 Feb 2018, 19:10

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

13 Apr 2018, 11:20

Thank you for your reply :)
My goal with this script is to have many fast shortcuts to run apps. I copied it from here:
https://superuser.com/questions/724653/ ... 303#725303
I want to have shortcuts while holding CTRL all the time:

Code: Select all

CTRL + g g  = run gvim
 CTRL + g t  = run todo
 CTRL + g e  = reload explorer
 etc...
This script:

Code: Select all

$Ctrl::Send {Ctrl Down}
$Ctrl UP::
    ChordIsBroken := True
    Send {Ctrl Up}
    Return
^q::
    ChordIsBroken := False
    Input, OutputVar, L1 M
    If (!ChordIsBroken && Asc(OutputVar) = 6)
    {
        MsgBox "Hello, World!"
    }
    Else
    {
        SendInput %OutputVar%
    }
    Return
is simplified version of my script (with a lot of such a shortcuts). Script works fine, but for some reason, while my normal typing, CTRL is blocked. It behaves like it is still pressed. Then when I press for ex: 'a' it behaves like CTRL + a (select all). So it is quite anoying :problem: This behaviour is for ALL letters that are typed with ALTGr, not only polish letters, even if I press ex: AltGr + P it not produce letter but CTRL is blocked.
Ex: I press
ALTGr + o it typed ó and next charater let say is 'a' so it behaves like Ctrl + a. To release this behaviour (holded Ctrl) you need to press ESC key.

Your last solution:

Code: Select all

~Ctrl Up::ChordIsBroken := True
blocks even more so I cannot easly get rid of this behaviour by pressing ESC
Rohwedder
Posts: 1521
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

19 Apr 2018, 05:09

Hallo,
try:
If the Ctrl key is pressed alone, Esc will be sent after releasing
(In my opinion, you should better do without THIS!)
Typing polish characters like: "ą"(Alt Gr + a) etc. should be possible.
^g -shortcuts while holding CTRL all the time:
CTRL + g g = run gvim
CTRL + g t = run todo
CTRL + g e = reload explorer etc...also.
^g alone has its native function.

Code: Select all

~Ctrl UP::
	If GotoApp
	{
		Input ;interrupts GotoApp-Input
		HotKey, ^g, Off ;allows to send ^g
		Send ^g ;^g alone has its native function
		HotKey, ^g, On
	}
	If !GetKeyState("RAlt")
		Send {Esc}
Return
^g:: ;goto App
	GotoApp := True
    Input, App, L1 M ;GotoApp-Input
	GotoApp := False
	If !App
		Return
	App := Chr(Asc(App)+96)
	If App = g
		MsgBox, run gvim
	Else If App = t
		MsgBox, run todo
	Else If App = e
		MsgBox, reload explorer
Return
lluke
Posts: 36
Joined: 12 Feb 2018, 19:10

Re: Remaping Ctrl as Esc+Ctrl with polish,accent characters hangs

24 Apr 2018, 07:58

Rohwedder wrote:Hallo,
try:
If the Ctrl key is pressed alone, ESC will be sent after releasing
...
Your script works fine for Polish charaters, but there is conflict with first script
https://autohotkey.com/boards/viewtopic ... 99#p205499
at this topic. Ctrl up+[key] combination send ESC instead do the desired operation (like ex: selection). It just send ESC while released with other key. For example: I press Ctrl + A and while I hold Ctrl key, text is selected. When I release Ctrl it just sends ESC and selection is vanished.
How to fix this?

Thank You for your help

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], SAbboushi and 104 guests