Jump to content

Recommended Posts

Posted

Hello all,

Just started using AutoIt 3.

Nice little language, the editor is also quite nice.

I'm trying to download a file from behind a button.

I have the following function to create a button:

Func CreateIndividualButton($btnText,$pos1,$pos2,$pos3,$pos4, $toolTipText,$funcToCall)
    GUICtrlCreateButton($btnText, $pos1,$pos2,$pos3,$pos4)
    GUICtrlSetTip(-1, $toolTipText)
    GUICtrlSetOnEvent(-1, $funcToCall) 
EndFunc

As you can see, I'm passing a function to call to the button create function.

This is called like this:

CreateIndividualButton("DTaskManager",30,90,210,30,"Task Manager Alternative",'dtask')

And it works.

Now that I'm tidying up the script I have written a new function which is called like this:

DownloadCheck($appName)

As you can see it is taking a variable.

I thought it would be something like this:

CreateIndividualButton("DTaskManager",30,90,210,30,"Task Manager Alternative",'DownloadCheck("dtask.exe")')

But it doesn't work. Is there something that I'm doing wrong or is this just not possible.

Thanks for any help.

Peace,

d3

Posted

It has a void return. Just contacts the download server with the name of the application to download. And then downloads it.

In that case there is no point in using it as a parameter. Instead just add the call to the start of your function.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted (edited)

I think you have misunderstood.

I have a function to create a button, I'm setting the event of the button to be a function.

If I have a function like this:

Func dtask()

local $app = "dtask.exe"
DownloadApp($app)

EndFunc

And I pass it in like this:

CreateIndividualButton("DTaskManager",30,90,210,30,"Task Manager Alternative",'dtask')

It works.

BUT

If I want to pass the name of the app to download directly in the button function.

CreateIndividualButton("DTaskManager",30,90,210,30,"Task Manager Alternative",'DownloadApp("dtask.exe"')

It fails with the folowing error.

script.au3 (148) : ==> Unknown function name.:
GUICtrlSetOnEvent(-1, $funcToCall)
Edited by d347hm4n
Posted

Why do you need to call DownloadApp("dtask.exe") in the other function as param?

Why not call it just before it and then call it like:

DownloadApp("dtask.exe"')
CreateIndividualButton("DTaskManager",30,90,210,30,"Task Manager Alternative")
Posted

Why do you need to call DownloadApp("dtask.exe") in the other function as param?

Why not call it just before it and then call it like:

DownloadApp("dtask.exe"')
CreateIndividualButton("DTaskManager",30,90,210,30,"Task Manager Alternative")

Thanks for all of the help. I spotted the solution in Martin's Sig.

http://www.autoitscript.com/forum/index.ph...mp;#entry524975

That allows a function with parameters to be passed to a button during it's creation.

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...