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

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
alawsareps
Posts: 26
Joined: 20 Jul 2016, 09:28

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

29 Apr 2024, 07:56

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 
    } 
}
User avatar
Seven0528
Posts: 390
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

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

29 Apr 2024, 08:43

 Not tested.

Code: Select all

#Requires AutoHotkey v2.0
#HotIf winActive("ahk_exe chrome.exe")
^a::  {
    msgbox("hello")
}
#HotIf
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
User avatar
xMaxrayx
Posts: 199
Joined: 06 Dec 2022, 02:56
Contact:

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

30 Apr 2024, 10:32

@alawsareps

Code: Select all


LCtrl & a:: {

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

    } 
}

-----------------------ヾ(•ω•`)o------------------------------
https://github.com/xmaxrayx/
User avatar
xMaxrayx
Posts: 199
Joined: 06 Dec 2022, 02:56
Contact:

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

30 Apr 2024, 10:33

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}")

    } 
}


-----------------------ヾ(•ω•`)o------------------------------
https://github.com/xmaxrayx/

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: ntepa, TomDonovan and 40 guests