 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Gertlex
Joined: 29 Oct 2006 Posts: 39 Location: A2 MI
|
Posted: Fri Mar 12, 2010 9:25 pm Post subject: Double press F1 problem |
|
|
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 |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Fri Mar 12, 2010 9:39 pm Post subject: |
|
|
| 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 |
|
 |
Gertlex
Joined: 29 Oct 2006 Posts: 39 Location: A2 MI
|
Posted: Fri Mar 12, 2010 9:42 pm Post subject: |
|
|
| Thanks worked great. Alas I mess with AHK to infrequently to remember those modifiers. |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Fri Mar 12, 2010 10:52 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Gertlex
Joined: 29 Oct 2006 Posts: 39 Location: A2 MI
|
Posted: Sat Mar 13, 2010 5:10 am Post subject: |
|
|
Awesome. A nice concise way to do a bunch of hotkeys like this  |
|
| Back to top |
|
 |
a_h_k
Joined: 02 Feb 2008 Posts: 626
|
Posted: Sat Mar 13, 2010 5:11 am Post subject: |
|
|
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%
}
} |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|