AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Double press F1 problem

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Gertlex



Joined: 29 Oct 2006
Posts: 39
Location: A2 MI

PostPosted: Fri Mar 12, 2010 9:25 pm    Post subject: Double press F1 problem Reply with quote

I believe this code is good, except for the part where I'm calling F1 again....
Code:
F1::
   If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 300) {
        Send {F1}
   }
   Else {
   }
Return


Basically the point is to disable single presses of F1, and require a double press of F1 to trigger the usual action (e.g. help file)

Problem I'm getting is that the double click doesn't work, and then I get a "71 hotkeys were sent in the last 1.5ish seconds" type message... obviously it's looping.

Can someone point me to a workaround for doing this?
Back to top
View user's profile Send private message AIM Address
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Fri Mar 12, 2010 9:39 pm    Post subject: Reply with quote

Code:
$F1::
   If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 300) {
        Send {F1}
   }
   Else {
   }
Return



http://www.autohotkey.com/docs/Hotkeys.htm#Symbols
$ This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself.
Back to top
View user's profile Send private message
Gertlex



Joined: 29 Oct 2006
Posts: 39
Location: A2 MI

PostPosted: Fri Mar 12, 2010 9:42 pm    Post subject: Reply with quote

Thanks worked great. Alas I mess with AHK to infrequently to remember those modifiers.
Back to top
View user's profile Send private message AIM Address
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Fri Mar 12, 2010 10:16 pm    Post subject: Reply with quote

See also RapidHotkey()
_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
None



Joined: 28 Nov 2009
Posts: 3086

PostPosted: Fri Mar 12, 2010 10:52 pm    Post subject: Reply with quote

Alternative you have to hold F1 for one second to get normal function
Code:
$F1::
F1Down:=A_TickCount
Keywait F1
If ((A_TickCount-F1Down)>1000)
Send {F1}
Return

Just an idea no obligation Smile
Back to top
View user's profile Send private message
Gertlex



Joined: 29 Oct 2006
Posts: 39
Location: A2 MI

PostPosted: Sat Mar 13, 2010 5:10 am    Post subject: Reply with quote

HotKeyIt wrote:
See also RapidHotkey()

Awesome. A nice concise way to do a bunch of hotkeys like this Smile
Back to top
View user's profile Send private message AIM Address
a_h_k



Joined: 02 Feb 2008
Posts: 626

PostPosted: Sat Mar 13, 2010 5:11 am    Post subject: Reply with quote

With this you can select which Help you want... Smile
Code:
#NoTrayIcon
SetTitleMatchMode, 3

$F1::
  Gui, -MaximizeBox -MinimizeBox
  Gui, Add, Button, x1 y1 w130 h30 gAutohotkey, Autohotkey
  Gui, Add, Button, x130 y1 w130 h30 gApplication, Application
  Gui, Add, Button, x260 y1 w130 h30 gWindows, Windows
  Gui, Add, Button, x396 y1 w130 h30 gCancel, Cancel
  Gui, Show, w527 h32, Help  -  Please choose ...
Return

#IfWinActive, Help  -  Please choose ... ahk_class AutoHotkeyGUI
Esc::Gui, Destroy
Enter::Send {Space}

GuiClose:
  Gui, Destroy
Return

Autohotkey:
  Gui, Destroy
  pathname = %A_AhkPath%\AutoHotkey.chm
  RunOrActivate(pathname, "hh.exe", "AutoHotkey Help ahk_class HH Parent")
Return

Application:
  Gui, Destroy
  Send {F1}
Return

Windows:
  Gui, Destroy
  Send {F1}
Return

Cancel:
  Gui, Destroy
Return

RunOrActivate(Target, InternalExeName="", WinTitle="")
{
  SplitPath, Target, TargetNameOnly   ;Get the filename without a path
  Process, Exist, %TargetNameOnly%
  ErrorLevel1 := ErrorLevel      ;In case just a FILE (eg help.chm)

  Process, Exist, %InternalExeName%
  ErrorLevel2 := ErrorLevel      ;In case PROGRAM (eg hh.exe)

  If (ErrorLevel1 > 0)
    PID := ErrorLevel1
  Else If (ErrorLevel2 > 0)
    PID := ErrorLevel2
  Else
    Run, %Target%, , , PID

  ; Activate by title if given, otherwise use PID
  If (WinTitle <> "")
  {
    SetTitleMatchMode, 2
    WinWait, %WinTitle%, , 3
    TrayTip, , Activating Window Title "%WinTitle%" (%TargetNameOnly%)
    WinActivate, %WinTitle%
  }
  Else
  {
    WinWait, ahk_pid %PID%, , 3
    WinActivate, ahk_pid %PID%
  }
}
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group