Shortcutkey works only once?
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Shortcutkey works only once?
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.
Re: Shortcutkey works only once?
It could be so many thingsPuzzledGreatly wrote:Under what circumstance would a shortcut key only work once?
- 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.
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: Shortcutkey works only once?
Thanks, it's not the first two. Would you comment a little more about blocked functionality and no returns.
Re: Shortcutkey works only once?
honestly, your better of posting the code. if its really long use gist.
-
- Posts: 60
- Joined: 03 Oct 2013, 19:49
- Location: Seattle Area
- Contact:
Re: Shortcutkey works only once?
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.
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: Shortcutkey works only once?
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.
-
- Posts: 60
- Joined: 03 Oct 2013, 19:49
- Location: Seattle Area
- Contact:
Re: Shortcutkey works only once?
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.
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.
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: Shortcutkey works only once?
Thanks for the suggestion about run. I have a script that has the following as a test:
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?
Code: Select all
~lbutton:: soundbeep
-
- Posts: 60
- Joined: 03 Oct 2013, 19:49
- Location: Seattle Area
- Contact:
Re: Shortcutkey works only once?
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.