0
votes

I want to produce something like this : 1. When i press Esc 2 times (double) i want to produce my "made-up custom action" 2. When i press Esc 1 time i want to produce the original Escape

ok, here is the explanation of my question :

  • This code should apply as global, means when i start the script it will work on all windows
  • %ALAT1% is variable the Active Windows title , abbreviation "Anime Land Akui Transform" some kind of silly anime game
  • If i press Esc one time . it will "pause" the game, but when i press Esc 2 times, it will "exit" the game"
  • I want to do a custom action when i press Esc 2 times, but i also don't want the original Esc key function got override when i press 1 time.

    Escape::
    if (A_PriorHotkey = A_ThisHotKey and A_TimeSincePriorHotkey < 400) 
    WinActivate, %ALAT1%
    IfWinActive, ahk_class TscShellContainerClass
    {
    Send {F5} ; F5 contains another action  
    }. 
    else
    {
     *Do original function of Escape i.e Send {Escape}     ; Now this is the problem    
    }
    return
    

after i try the code above : suppose i press "Escape" button it will loop the Escape as if i press Escape 2 times. So my real question is how to make "original 1 times press Esc key function" won't loop to "our custom 2 times press Esc key function" ?

1
I think you really should read up on the basics of AHK, the command docs are usually a good starting point. Your code is very confusing, e.g. the if(...) statement will only affect the following line, and since there's neither a block nor indentation, it's all a guessing game. You also never mentioned that you somehow want to distinguish between windows, and the contents of ALAT1 are unknown. I suggest you start by reading the #IfWin.. docs.MCL
@MCL eerrr i edit the question, and errr i won't need #IfWinActive if i just want to produce global action.laruffii

1 Answers

1
votes

Change the first line of your code to;

$Escape::

This will set it so that the hotkey is only triggered by real keystrokes not simulated ones.