Debugging my hotkey, beginner Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Debugging my hotkey, beginner

16 Jan 2020, 10:21

I'm still new to this. I have created the following hotkey and it does not like my first line CP::

Code: Select all

CP::
Send, +F8
Sleep, 100
Send, ZD00
Sleep, 100
Send, F2
Sleep, 100
Send, LOCL
Sleep, 100
Send, TAB
Sleep, 100
Send, TAB
Sleep, 100
Send, SPACE
Sleep, 100
Send, F3
Sleep, 100
Send, F5
Sleep, 100
Send, 4
Sleep, 100
Send, CtrlS
return
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Debugging my hotkey, beginner

16 Jan 2020, 11:48

If you're trying to use the keys C and P held down one after the other try:C & P::msgbox you pressed %A_ThisHotkey%

If you're trying to use type C then P normally try

Code: Select all

:*:CP::  
msgbox you typed this hotstring
return
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 11:55

C & P worked as far as allowing the hotkey to "run" without an error coming up. But now when I go to actually use the hotkey, it fails. Any ideas why it would fail at this point?
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Debugging my hotkey, beginner

16 Jan 2020, 12:00

paquirl wrote:
16 Jan 2020, 11:55
...when I go to actually use the hotkey, it fails. Any ideas why it would fail at this point?
Please explain how it fails.

You can test if the hotkey's firing with:

Code: Select all

C & P::
msgbox %A_ThisHotkey% hotkey combo fired!
return
Also because all of your sleeps are the same duration you can shorten the code like this (assuming CP multi-hotkey):

Code: Select all

SetKeyDelay, 100
C & P::Send, {+}{F8}ZD00{F2}LOCL{TAB 2}{SPACE}{F3}{F5}4^S
Note: if you're trying to send Shift+F8 at the start change Send, {+}{F8} to Send, +{F8}
htms
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 12:56

Ok it gets stranger and stranger.

I've tried both codes at this point. (changed hotkey to #C and removed brackets from +)
As you can see in the below screenshots, when using your version, it fails at the point of doing the ZD00 and just leaves the field blank. In my version, I ran it once with it populating some random letters instead of ZD00, and then a second run it populated the below screenshot 4Ctr instead of ZD00. Am I guessing correctly that I need to extend the sleep delay?

Code: Select all

#C::
Send, +{F8}
Sleep, 500
Send, ZD00
Sleep, 100
Send, F2
Sleep, 100
Send, LOCL
Sleep, 100
Send, TAB
Sleep, 100
Send, TAB
Sleep, 100
Send, SPACE
Sleep, 100
Send, F3
Sleep, 100
Send, F5
Sleep, 100
Send, 4
Sleep, 100
Send, CtrlS
return

Code: Select all

SetKeyDelay, 100
#C::Send, +{F8}ZD00{F2}LOCL{TAB 2}{SPACE}{F3}{F5}4^S
CaptureHotkeyTest2.PNG
CaptureHotkeyTest2.PNG (14.36 KiB) Viewed 1322 times
CaptureHotkeyTest1.PNG
CaptureHotkeyTest1.PNG (14 KiB) Viewed 1322 times
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 12:57

ALSO, the snipping tool pops up ... ???
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 13:14

OK, I extended the delay prior to ZD00. Now it works to the point of inputting the ZD00 and snipping tool does not come up anymore. However, now it stops at ZD00 and fails.
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 13:24

I put brackets around the F2 and it gets a little further. Now the problem is evident in the below screenshot.
Attachments
CaptureHotkeyTest3.PNG
CaptureHotkeyTest3.PNG (9.53 KiB) Viewed 1305 times
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 13:31

Duh, I put brackets around the TAB and SPACE as well. Now the code gets all the way to inputting the 4 and instead of saving with the final ^S , the snipping tool pops up.
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 13:54

I have snipping tool on a hotkey to come up with CTRL+S, but it should not be coming up when this hotkey is doing CTRLS
gregster
Posts: 8988
Joined: 30 Sep 2013, 06:48

Re: Debugging my hotkey, beginner

16 Jan 2020, 14:07

What is the meaning of CTRLS?
Obviously not Ctrl+s, but is it a literal string - or do you want it to first press and release Ctrl, then press s ?

Code: Select all

send {Ctrl}s
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 14:10

I didnt realize so many things needed the brackets.

I have added the brackets to do {Ctrl}s as you mentioned. But I'm wanting to hold control and then hit S.
gregster
Posts: 8988
Joined: 30 Sep 2013, 06:48

Re: Debugging my hotkey, beginner  Topic is solved

16 Jan 2020, 14:13

Special keys need brackets, so that son't get confused with literal strings.
paquirl wrote:
16 Jan 2020, 14:10
I have added the brackets to do {Ctrl}s as you mentioned. But I'm wanting to hold control and then hit S.
Then you need ^s. But then your snipping tool comes up, as could be expected:
I have snipping tool on a hotkey to come up with CTRL+S
Sorry, I don't understand what you are trying to do...
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 14:14

This snipping tool is set to come up with holding control and shift then hitting S. On this new hotkey I'm wanting it to save, which is just hold control and hit S without the Shift key being involved.
paquirl
Posts: 53
Joined: 28 Aug 2017, 13:36

Re: Debugging my hotkey, beginner

16 Jan 2020, 15:19

it works now! ^s fixed it when I made the s lower case.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 256 guests