Multi Action hotkey not working.

Get help with using AutoHotkey and its commands and hotkeys
User avatar
ZoLatKam
Posts: 3
Joined: 01 Sep 2016, 10:29

Multi Action hotkey not working.

01 Sep 2016, 10:43

Based on the code below, I'm wanting the F5 key to always send F5 when pressed once, but then send "Shift + F9" when pressed twice, rapidly.

I have tried multiple variations, using just the "sc" code or just the "vk" code of the respective keys {including using "{SHIFTDOWN}" & "{SHIFTUP}" in place of the "+" for the secondary action}, however, the result is always the same:

The single press function does not work, while the double press function does work.

Any help, suggestions, constructive criticism would be most appreciated! :)

Code: Select all

F5::			;Performs Multiple Actions Based On # Of Keypresses.
  If F5HK > 0	;SetTimer Already Started; Log Keypresses Instead.
	{    F5HK += 1
		Return
	}
  F5HK = 1	;Otherwise, This Is The First Press Of A New Series, Therefore Set Count To 1 & Start Timer:
  SetTimer KeyF5HK, 350		;Wait For Additional Press For 350ms.
  Return
  KeyF5HK:
  SetTimer KeyF5HK, Off
  If F5HK = 1				;Hotkey Pressed Once: Create New Task On Current Ticket.
	{	Send {vk74sc03F}	;Sends F5.
	}
  Else If F5HK = 2			;Hotkey Pressed Twice: Initiates A Refresh In Outlook.
	{	Send +{vk78sc043}	;Sends Shift+F9
	}
  Else If F5HK > 2			;Hotkey Pressed Thrice: Reload Script.
	{	Reload
	}
  F5HK = 0	;Regardless Of Action Triggered Above, Reset Count To 0.
  Return
Image
Guest

Re: Multi Action hotkey not working.

01 Sep 2016, 11:59

I replaced your sends with message boxes below. Works fine with msgboxes. Could this be an issue with Outlook?

Code: Select all

F5::			;Performs Multiple Actions Based On # Of Keypresses.
  If F5HK > 0	;SetTimer Already Started; Log Keypresses Instead.
	{    F5HK += 1
		Return
	}
  F5HK = 1	;Otherwise, This Is The First Press Of A New Series, Therefore Set Count To 1 & Start Timer:
  SetTimer KeyF5HK, 350		;Wait For Additional Press For 350ms.
  Return
  KeyF5HK:
  SetTimer KeyF5HK, Off
  If F5HK = 1				;Hotkey Pressed Once: Create New Task On Current Ticket.
	{	msgbox, F5 ONCE		;Sends F5.
	}
  Else If F5HK = 2			;Hotkey Pressed Twice: Initiates A Refresh In Outlook.
	{	msgbox, F5 TWICE	;Sends Shift+F9
	}
  Else If F5HK > 2			;Hotkey Pressed Thrice: Reload Script.
	{	Reload
	}
  F5HK = 0	;Regardless Of Action Triggered Above, Reset Count To 0.
  Return
hunter99
Posts: 128
Joined: 20 Jan 2014, 17:57

Re: Multi Action hotkey not working.

01 Sep 2016, 19:44

Hi, this works. Here it is using wordpad and its F1 key. Single click gives Help.
Double click give a dialog box at cursor. You needed the $F1, the $ prefix.

Code: Select all

$F1::			;Performs Multiple Actions Based On # Of Keypresses.
  If F5HK > 0	;SetTimer Already Started; Log Keypresses Instead.
	{    F5HK += 1
		Return
	}
  F5HK = 1	;Otherwise, This Is The First Press Of A New Series, Therefore Set Count To 1 & Start Timer:
  SetTimer KeyF5HK, 350	;Wait For Additional Press For 350ms.
  Return
  KeyF5HK:
  SetTimer KeyF5HK, Off
  If F5HK <= 1				;Hotkey Pressed Once: Create New Task On Current Ticket.
	{   sendinput, {F1}     ;Sends F1.    Help
	}
  Else If F5HK = 2			;Hotkey Pressed Twice: Initiates A Refresh In Outlook.
	{	sendinput, +{F10}   ;Sends Shift+F10    Dialog at the cursor.
	}
  Else If F5HK > 2			;Hotkey Pressed Thrice: Reload Script.
	{	Reload
	}
  F5HK = 0	;Regardless Of Action Triggered Above, Reset Count To 0.
  Return
hunter99
See this link for $ prefix and see why it worked without it for msgbox.
https://autohotkey.com/docs/Hotkeys.htm#Symbols
User avatar
ZoLatKam
Posts: 3
Joined: 01 Sep 2016, 10:29

Re: Multi Action hotkey not working.

02 Sep 2016, 01:04

Thank you for your suggestions, hunter99!

Unfortunately, adding "$" in front of "F5" still yielded the same result.

However, something the Anon poster said {thx, btw!} about Outlook made me think, "What if it's an issue with the proprietary software my company uses for ticketing?"

After changing the hotkey in said proprietary software itself from "F5" to "Shift + F5" & making the necessary change for the single press action, the hotkey works exactly as desired!

Thanks again to both of you for enabling me to consider alternate solutions which ultimately helped me with a solution!
Image

Return to “Ask For Help”

Who is online

Users browsing this forum: anhnha, Bing [Bot], casperharkin, Chunjee, Google [Bot], littlegandhi1199, sobuj53, Xeo786 and 42 guests