AutoHotkey Community

It is currently May 27th, 2012, 5:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Double press F1 problem
PostPosted: March 12th, 2010, 10:25 pm 
Offline

Joined: October 29th, 2006, 4:09 am
Posts: 39
Location: A2 MI
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 10:39 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 10:42 pm 
Offline

Joined: October 29th, 2006, 4:09 am
Posts: 39
Location: A2 MI
Thanks worked great. Alas I mess with AHK to infrequently to remember those modifiers.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 11:16 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
See also RapidHotkey()

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2010, 11:52 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
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 :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2010, 6:10 am 
Offline

Joined: October 29th, 2006, 4:09 am
Posts: 39
Location: A2 MI
HotKeyIt wrote:
See also RapidHotkey()

Awesome. A nice concise way to do a bunch of hotkeys like this :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2010, 6:11 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
With this you can select which Help you want... :)
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%
  }
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: dra, Google [Bot], HotkeyStick, rbrtryn, XstatyK and 63 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group