Convert ctrl+a to (ctrl+e + ctrl+a) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Convert ctrl+a to (ctrl+e + ctrl+a)

02 Feb 2017, 07:11

Hello there!

I have a spanish windows 10 that uses different shortcuts from english version. For "select all" it uses ctrl+E instead of standard ctrl+A. But I have other applications that use the regular ctrl+A. For example, if I am in the desktop and hit ctrl+E all the items in the desktop will be selected. But if I am using application "X" and I want to select all I have to use ctrl+A.
I want to be able to use only ctrl+A, I have tried to solve this using autohotkey. I think that behaviour should be: when I press ctrl+A -> send ctrl+a and send ctrl+e
I have tried the following:

^a::
Send {^a}
Send {^e}
return

With this script in windows it works but in other apps it does not. What am I doing bad???
Lumens
Posts: 4
Joined: 02 Feb 2017, 07:35

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

02 Feb 2017, 08:21

Try without {}

^a::
Send ^a
Send ^e
return
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

02 Feb 2017, 09:56

Thanks for suggesting! I have tried: when I press ctrl+a the system starts to behave like if the keys ctrl+a or ctrl+e were pressed many times and all the time...
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

02 Feb 2017, 11:38

i think you are going to run into problems if you try to send both sequences

according to this page, CTRL+A is "open" for spanish MS Word:

https://social.technet.microsoft.com/Fo ... progeneral

probably the better idea is to use context sensitive hotkeys and only remap CTRL+A or CTRL+E in certain applications

Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

02 Feb 2017, 14:14

I agree with guest3456

If you don't know what is "context sensitive" search #ifwinactive in autohotkey tutorial
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

03 Feb 2017, 02:13

Thanks for the replies! I am investigating #ifwinactive option...
Anyway I would like to understand why when I try without { } the action is repeated continuously. This will help me to understand how AHK scripts work...
The only "application" that I have in spanish is Windows, all other programs are in English and use ctrl+a, so I really would like to give a try to my original idea to see if after that really arise other problems or not... So... what is the "correct" way to send two key combinations with AHK? Introducing a little delay between ctrl+a and ctrl+e would help?
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

03 Feb 2017, 02:41

Well, I found a solution that is working for me:

SetKeyDelay , 30, 30 ; first is delay between keypresses, and second is press duration
^a::
; we are using ControlSend here because Send and SendInput is not affected by SetKeyDelay.
ControlSend, , ^a, A
ControlSend, , ^e, A
return

But instead this does nothing:

SetKeyDelay , 30, 30 ; first is delay between keypresses, and second is press duration
^a::
; we are using ControlSend here because Send and SendInput is not affected by SetKeyDelay.
ControlSend, , {^a}, A
ControlSend, , {^e}, A
return

Could someone clarify why the curly brackets cause different behaviour in those two scripts?
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

03 Feb 2017, 10:48

see the Send help page. the {brackets} are only supposed to be used for special character such as {Enter}

and the reason why the action was repeated continuously was because you were in an endless loop:

Code: Select all

^a::
   Send, ^a    ; this causes the hotkey to trigger itself and restart at the line above
return
you would need to use the $ modifier so that the Send command doesn't trigger its own hotkey. as in $^a::

see the Hotkeys help page for the $ modifier:
https://autohotkey.com/docs/Hotkeys.htm

still, i don't think you should send both sequences, its a bad idea. if "windows" is the only thing that uses CTRL+E, then i'd get very specific as to what instances you are using it: you mentioned on the desktop, what about in the File Explorer windows? is it only when you want to select all files? what about MS Office apps?

oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

02 Mar 2017, 03:00

Hello,

I have had the time to investigate further the use of IfWinActive. Sorry for the delay.
I have tried:

Option 1:
if WinActive("ahk_class IEFrame")
^a::^e

Option 2:
IfWinActive, Compatibility Mode ahk_class IEFrame
{
^a::^e
return
}

Both options give same behaviour: this works well when an explorer windows has the focus, but in the other apps (that should ignore the script) CTRL+a is ignored and they receive CTRL+e instead...

Why?

I am also not sure if it is mandatory to put the "return" at the end, in both options.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

02 Mar 2017, 08:10

for context sensitive hotkeys, you want #IfWinActive not IfWinActive

Code: Select all

#IfWinActive, Compatibility Mode ahk_class IEFrame
^a::^e
#IfWinActive   ; this turns off #IfWinActive below here

oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

03 Mar 2017, 03:39

It seems that your suggestion does not work for me, in explorer windows CTRL+A does nothing and CTRL+E selects all (normal behaviour)

I copy here all my script because I also have other shortcuts and I don't know if there can be some kind of interference:

; select all:

#IfWinActive, Compatibility Mode ahk_class IEFrame
^a::^e
#IfWinActive ; this turns off #IfWinActive below here

; canvi d'escriptori amb el teclat:

LWin & Right::
RWin & Right::
Send, {AltDOWN}{LWinDOWN}{Right}{LWinUP}{AltUP}
return

LWin & Left::
RWin & Left::
Send, {AltDOWN}{LWinDOWN}{Left}{LWinUP}{AltUP}
return
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

29 Mar 2017, 08:26

Dear Guest3456,

Some weeks ago I tried your suggestion (to use #IfWinActive instead of IfWinActive) and in explorer windows CTRL+A does nothing and CTRL+E selects all (normal behaviour)
Do you know why?

#IfWinActive, Compatibility Mode ahk_class IEFrame
^a::^e
#IfWinActive ; this turns off #IfWinActive below here
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

29 Mar 2017, 09:13

I would guess that the #IfWinActive is not triggering.

Try running this script:

Code: Select all

#IfWinActive, Compatibility Mode ahk_class IEFrame
^a::
	Msgbox, Working!
	^e
#IfWinActive
If running that doesn't cause a messagebox to pop up, then the problem is "Compatibility Mode ahk_class IEFrame" is not correctly detecting the window you want it to. Try changing that line to different things until you can get the messagebox to appear - don't forget you can use Window Spy to get the class names for windows.
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

30 Mar 2017, 02:32

I have followed your suggestions, and it seems I have gone a step forward, but it is still not enough!

Active window info shows:

When in an explorer window:
ahk_class CabinetWClass
ahk_exe explorer.exe

When in the desktop:
ahk_class WorkerW
ahk_exe explorer.exe

(I am using windows 10)

Having in mind this info I have tried following scripts:

#IfWinActive, Compatibility Mode ahk_class WorkerW
^a::
Msgbox, Working!
^e
#IfWinActive

and

#IfWinActive, Compatibility Mode ahk_class CabinetWClass
^a::
Msgbox, Working!
^e
#IfWinActive

None of these work. It seems IfWinActive is still not triggering.... even fi now the class names seem ok...
Guest

Re: Convert ctrl+a to (ctrl+e + ctrl+a)

30 Mar 2017, 05:04

Remove "Compatibility Mode" as I doubt that it is part of the explorer windows title/class.
If the hotkeys don't work the #If.. is just incorrect, adjust it to make it work.
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

Re: Convert ctrl+a to (ctrl+e + ctrl+a)  Topic is solved

30 Mar 2017, 06:45

Removing "Compatibility Mode" did the trick! Finally the script works as I expect: many thanks to the community!!! I am happy :D
The final script for reference:

#If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class WorkerW")
^a::^e
#IfWinActive ; this turns off #IfWinActive below here

This script converts CTRL+A to CTRL+E in explorer windows and desktop (win 10)
oniscidea
Posts: 10
Joined: 02 Feb 2017, 03:58

[SOLVED] Re: Convert ctrl+a to (ctrl+e + ctrl+a)

30 Mar 2017, 06:48

I just marked the topic as solved.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 350 guests