Jump to content

Recommended Posts

Posted (edited)

From Help file: "The called function can not be given parameters. They will be ignored."

I realise it's not the answer to your question, but IMO you already have an elegant solution....?

Edited by dmob
Posted
18 minutes ago, dmob said:

From Help file: "The called function can not be given parameters. They will be ignored."

I realise it's not the answer to your question, but IMO you already have an elegant solution....?

Test2 doesn't require any parameters though as $aVariable is optional which is why I don't understand why it's causing an error. And yeah using a 2nd function is a solution but I wouldn't say it's elegant as it bloats the script a bit. 

Posted (edited)
HotKeySet("!q", "Terminate")
HotKeySet("!s", "Test1")
HotKeySet("!z", "Test2")

While 1
    Sleep(100)
WEnd

Func Terminate()
    Msgbox(0,"", "Exit")
    Exit
EndFunc   ;==>Terminate

Func Test1()
  Test2()
EndFunc

Func Test2($aVariable = 1)
    If @HotKeyPressed = "!z" Then $aVariable = 1
    If $aVariable = 1 Then
        Msgbox(0,"", "its 2")
    EndIf
EndFunc

code edited

Edited by jugador
Posted
On 1/11/2020 at 5:03 AM, Twisted6 said:

Test2 doesn't require any parameters though as $aVariable is optional which is why I don't understand why it's causing an error.

It's because you're trying to access an undeclared variable in the Test2 function. Whether it's used or not, optional or not, you're trying to run a comparison function against the variable, and as far as AutoIt is concerned, that variable doesn't exist in that function. As stated already, the variable is ignored which means that even though it's in the function parameters, AutoIt doesn't "see" it in a HotKey function.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...