Quantcast
Channel: AutoHotkey Community
Viewing all articles
Browse latest Browse all 579

Ask for Help (v1) • Re: Error in AHK script

$
0
0
This code has actually many problems. It has a lot of invented stuff in it - does it happen to be AI-generated :problem: ? If it is, please have a look at the forum rules, https://www.autohotkey.com/forumrules/#inappropriate_content, as it wouldn't be allowed.

First, IfWinExist is not a function, but a command. WinExist() is a function - which you have in the line above for some reason without If. So simply use If WinExist() (mind the space) to check for a window.
It's just not clear what checking for the active window ("A") would achieve here... later it seems you would want its return value, though.

Other problems of your code include:
  • Your multi-line hotkey subroutines don't end with a return. Since this seems to be an AHK v1 question, based on the used syntax (erroneously posted in AHK v2 help, but now moved to v1 help), I would recommend to add the returns. In AHK v2, braces would be alright, though, since hotkeys are functions.

  • I don't think that WinGetHandle or WinDeactivate actually exist as v1 commands (or v2 functions). WinSet, Bottom and the return value of WinExist() or Winget, outvar, ID might help instead... Loop, FindWindows seems to be another creative invention.

  • The comment in this line is definitely wrong: ^+!:: ; Detect any key combination (Ctrl+Alt+Shift+) This hotkey would be triggered for the key combo Ctrl and Shift and !.

  • The use of the wintitle criterion ahk_id is also confusing - and won't have the intended effect. Are you trying to use it as a variable name?

  • The parameter hwnd in the user-defined function gets never used and A_ThisKey in the function call is not defined (it's not a built-in variable).


Since a lot of AHK basics seem to be missing, I would recommend to consult the AHK v1 docs for a bit - or to start with AHK v2 straightaway, as AHK v1 is deprecated and won't be developed any further (at least not officially). Start small. Only if your first line of code is working, add a second one.

Statistics: Posted by gregster — Today, 13:40



Viewing all articles
Browse latest Browse all 579

Trending Articles