Shortcutkey works only once?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Shortcutkey works only once?

04 Nov 2013, 16:28

I have a long script and I'm using F7 to bring up a separate GUI. The problem is that it only works once. After the first time the shortcutkey is just ignored. What can I look for to fix this problem? Under what circumstance would a shortcut key only work once? I've never encountered this kind of problem before. Thanks.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Shortcutkey works only once?

04 Nov 2013, 21:26

PuzzledGreatly wrote:Under what circumstance would a shortcut key only work once?
It could be so many things
- Loop that never breaks (common)
- Context sensitive hotkey that resolves false due to some interruption.
- Blocked functionality
- No return or return in the wrong place (very common)
- Script crash, but icon still in taskbar (like not pluging something and wondering why it isn't working, yes, it does happen lol)

Or many other things.. The only way to really get help is to post the code.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Shortcutkey works only once?

04 Nov 2013, 21:29

Thanks, it's not the first two. Would you comment a little more about blocked functionality and no returns.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Shortcutkey works only once?

04 Nov 2013, 21:32

honestly, your better of posting the code. if its really long use gist.
Wade Hatler
Posts: 60
Joined: 03 Oct 2013, 19:49
Location: Seattle Area
Contact:

Re: Shortcutkey works only once?

04 Nov 2013, 22:05

It's probably hung up in the hotkey handler. Use ListLines to see the last line that was executed and most of the time you'll see it right away.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Shortcutkey works only once?

05 Nov 2013, 19:25

Thanks for the suggestion about using listlines. The script I had suddenly started working as expected. But after adding some more code the problem returned and listlines helped me find what was wrong with the new code.
Wade Hatler
Posts: 60
Joined: 03 Oct 2013, 19:49
Location: Seattle Area
Contact:

Re: Shortcutkey works only once?

05 Nov 2013, 19:32

Here's another handy trick I use all the time. Some scripts are just not very stable because they depend on a whole bunch of actions, timing, what you have running, etc.
Whenever I have a hotkey that will fail a high percentage of the time, I put the action in a very small script, and just launch it with RUN from the hotkey. Use #SingleInstance force, and you can just hit the hotkey again when it fails. The AutoHotkey compiler is lightning fast, so this doesn't add any significant time, but it makes them a lot more stable.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Shortcutkey works only once?

06 Nov 2013, 22:03

Thanks for the suggestion about run. I have a script that has the following as a test:

Code: Select all

	~lbutton::	soundbeep
I would expect a soundbeep every time I leftclick but with my script I'm getting the soundbeep only once and I've no idea why. Using listlines isn't helping. Could it me a memory issue?
Wade Hatler
Posts: 60
Joined: 03 Oct 2013, 19:49
Location: Seattle Area
Contact:

Re: Shortcutkey works only once?

07 Nov 2013, 12:15

You're correct that it should work. The ~ allows the click to go through to the underlying window, so I guess there's some chance it's getting hung processing the mouse event, but it's a longshot. Try it without the ~. I just tried it with a 1-liner exactly as you showed and it works on my machine running 1.1.13.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mamo691, MrDoge and 242 guests