Double press F1 to perform another action Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
OnTheWayAHK
Posts: 8
Joined: 30 Jan 2017, 12:20

Double press F1 to perform another action

22 Apr 2017, 16:25

Hello,

I've done a bunch of searching to get me to the point I'm at, but need some pointers...

I need F1 to function as normal, but if pressed twice within half a second, it opens Notepad++, then a new tab. This works, but when double pressing F1, it also sends the F1 key; so when in NPP, it pulls up the 'About' screen, etc. (The odd thing is that if I simplify the code so that the double press only pops up a test message box, it works...but of course I need it to plays some beeps an then open NPP etc.)

Code: Select all

$F1::
If (A_PriorHotKey = "$F1" AND A_TimeSincePriorHotkey < 500)
{
  SoundBeep, 750, 250
  Sleep, 250
  SoundBeep, 1000, 250
  Sleep, 250
  SoundBeep, 1250, 250
  Sleep, 250
  GoSub MarkerForPressingF1KeyTwice
  SetTimer, F1KeyPressDefault, Off
}
else
  SetTimer, F1KeyPressDefault, -500
Return

F1KeyPressDefault:
  Send, {F1}
Return

MarkerForPressingF1KeyTwice:
Process, Exist,- notepad++.exe
If Not ErrorLevel ; errorlevel will = 0 if process doesn't exist
   Run, "C:\Program Files (x86)\Notepad++\notepad++.exe"
If (ErrorLevel != 0){ 
  SetTitleMatchMode 2
  WinWait,- Notepad++
  IfWinNotActive,- Notepad++, WinActivate,- Notepad++
  WinWaitActive,- Notepad++
}
Sleep, 500
Send {Ctrl Down}{Shift Down}{N}
Send {Ctrl Up}{Shift Up}
Return
Thanks!
Xeno234
Posts: 71
Joined: 24 Mar 2017, 18:14

Re: Double press F1 to perform another action  Topic is solved

22 Apr 2017, 16:53

Move SetTimer, F1KeyPressDefault, Off earlier to just before the beeps.
OnTheWayAHK
Posts: 8
Joined: 30 Jan 2017, 12:20

Re: Double press F1 to perform another action

22 Apr 2017, 18:23

Thanks Xeno234, that worked!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 267 guests