If same button is pressed, execute this code, if not, dont

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
chef423
Posts: 213
Joined: 28 Aug 2016, 12:10
Contact:

If same button is pressed, execute this code, if not, dont

27 Jul 2017, 13:09

Code: Select all

; Beer
F1::
Clipboard=
Send, +{Left 5}
Send, ^{Ins}
Send, {Backspace}
Send, 1091{Enter}
Sleep 25
Send, ^v
Send, {Enter}
Return
This is a basic piece of code I wrote for a POS system and customization keyboard...the cashier enters 1500 and presses, BEER on the keyboard, the amount from the San Barcode Box is copied and pasted into the Open Beer 'enter price' applet and then places that amount on the Invoice for sale.
Beer is tired to the F1 key that executed the above code. This mimics a SAM4s cash register workflow. But what I would like to do is, if they press the BEER key, immediately after, say entering 1500 and pressing the BEER key, I want it to simply increment the quantity without the clerk having to enter the same amount again and then press BEER.

Workflow:
1. Customer comes to counter with a six pack of beer
2. Clerk rings in beer amount, touches 799 on keyboard then presses the BEER key on the Keyboard
3. The above F1 code is executed
4. IF clerk presses BEER key again, repeat the code above with the 799 amount already in Clipboard (to repeat, and increment the quantity to 2)
5. ELSE do not repeat code, no matter if the BEER is key presses immediately one other key is depressed.

IF ELSE is the solution? Or

if F1 (repeats) {
...
}
Clipboard=
Send, +{Left 5}
Send, ^{Ins}
Send, {Backspace}
Send, 1091{Enter}
Sleep 25
Send, ^v
Send, {Enter}}
{
...
} else {
DO NOTHING
...
}

Thank you to anyone that can help. I am getting better at AHK but still need direction at times with my coding.
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: If same button is pressed, execute this code, if not, dont

27 Jul 2017, 13:12

A_LastHotkey is a built in variable. Check it out in docs.

Talked too fast, like ususal. It's prior hotkey

https://autohotkey.com/docs/Variables.htm#PriorHotkey

Also check out A_TimeSince... PriorHotkey, ThisHotkey.


Have fun!
try it and see
...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 231 guests