Page 1 of 1

How to perfom native action when condition is false in v2. "ctrl + a" for example.

Posted: 29 Apr 2024, 07:56
by alawsareps
When chrome is active, I want to show message "hello",
but if chrome not active, I want the native "select all" to be the action.

Code: Select all

#Requires AutoHotkey v2.0

^a:: {
    if WinActive("ahk_exe chrome.exe") {
        msgbox("hello")
    } 
    else {
        ; ^a::^a ; SELECT ALL 
    } 
}

Re: How to perfom native action when condition is false in v2. "ctrl + a" for example.

Posted: 29 Apr 2024, 08:43
by mikeyww

Re: How to perfom native action when condition is false in v2. "ctrl + a" for example.

Posted: 29 Apr 2024, 08:43
by Seven0528
 Not tested.

Code: Select all

#Requires AutoHotkey v2.0
#HotIf winActive("ahk_exe chrome.exe")
^a::  {
    msgbox("hello")
}
#HotIf

Re: How to perfom native action when condition is false in v2. "ctrl + a" for example.

Posted: 30 Apr 2024, 10:32
by xMaxrayx
@alawsareps

Code: Select all


LCtrl & a:: {

    if WinActive("ahk_exe chrome.exe") {
        Msgbox("hello")
    } 
    else {
        SendInput("{Ctrl Down}a{Ctrl up}")

    } 
}


Re: How to perfom native action when condition is false in v2. "ctrl + a" for example.

Posted: 30 Apr 2024, 10:33
by xMaxrayx

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force


$^a:: {

    if WinActive("ahk_exe chrome.exe") {
        Msgbox("hello")
    } 
    else {
        ; ; MsgBox "n0"
        ; SendInput("{" A_MenuMaskKey "}" )
        SendInput("{Ctrl Down}a{Ctrl up}")

    } 
}