# How to use Func

## Recommended Posts

Hi,

I'm trying to create a simple autoit GUI. There will be two steps, one to obtain the pc IP, then to have the user start the data backup and to show a progress bar. I would like to know if is a good idea or how to use functions when the selection is made and check for errorlevels. I appreciate any help anyone can give me. I will continue to read through the help files.

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>

GuiCreate("MyGUI", 559, 256,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW,$WS_CLIPSIBLINGS))

$IP_1 = GuiCtrlCreateButton("Get_IP", 50, 70, 190, 50)$Input_2 = GuiCtrlCreateInput("", 260, 80, 280, 30)
$Data_3 = GuiCtrlCreateButton("Backup Data", 50, 130, 190, 50)$Progress_4 = GuiCtrlCreateProgress(260, 140, 270, 30)

GuiSetState()
While 1
$msg = GuiGetMsg() Select Case$msg = $IP_1 ;???? Case$msg = $Data_3 ;??? Case$msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit #endregion --- GuiBuilder generated code End --- ;;:::Fuction Here ?? #### Share this post ##### Link to post ##### Share on other sites make a little effort... look for _GetIP() in help 8) #### Share this post ##### Link to post ##### Share on other sites Is this the correct way of calling a function? How do I set for errorlevels. I'm also trying to make the progress to run when select. How can I link it to run from Progress_4 section? #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.6 Prototype #include <GuiConstants.au3> GuiCreate("MyGUI", 559, 256,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))$IP_1 = GuiCtrlCreateButton("Get_IP", 50, 70, 190, 50)
;$Input_IpAddress = GuiCtrlCreateInput("" & @IPAddress1, 180, 250, 280, 20)$Input_2 = GuiCtrlCreateInput("", 260, 80, 280, 30)
$Data_3 = GuiCtrlCreateButton("Backup Data", 50, 130, 190, 50)$Progress_4 = GuiCtrlCreateProgress(260, 140, 270, 30)

GuiSetState()
While 1
$msg = GuiGetMsg() Select Case$msg = $IP_1 IP() Case$msg = $Data_3 Progress () Case$msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit #endregion --- GuiBuilder generated code End --- ;;:::Fuction Here ?? Func IP() GuiCtrlSetData($Input_2, @IPAddress1)
EndFunc ;==>Set_Exit

Func Progress()
ProgressOn("Progress...", "Backup in Progress", "0 percent" & $Progress_4) For$i = 10 to 100 step 10
sleep(1000)
ProgressSet( $i,$i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
EndFunc ;==>Set_Exit

make a little effort... look for _GetIP() in help

8)

##### Share on other sites

Is this the correct way of calling a function? How do I set for errorlevels. I'm also trying to make the progress to run when select. How can I link it to run from Progress_4 section?

Search in forum and in HelpFile for keywords: func,progress,@error and so on ...

##### Share on other sites

I been trying to get the function with error codes to work, but I'm stuck. When I have the correct path define it launches the setup, but I change it, the error msgbox does not appear. Any better way to do this, or what Am I missing?

Func AOLSetup()
SetError (1)
Run("V:\AOL\Setup.exe")
If @error = 1 Then
Else
EndIf
EndFunc ;==>Set_Exit

Search in forum and in HelpFile for keywords: func,progress,@error and so on ...

##### Share on other sites

I been trying to get the function with error codes to work, but I'm stuck. When I have the correct path define it launches the setup, but I change it, the error msgbox does not appear. Any better way to do this, or what Am I missing?

Func AOLSetup()
SetError (1)
Run("V:\AOL\Setup.exe")
If @error = 1 Then
Else
EndIf
EndFunc;==>Set_Exit
first solution: at your script use AutoItSetOption - RunErrorsFatal

second solution:

Func AOLSetup()
If FileExists("V:\AOL\Setup.exe") Then
Run("V:\AOL\Setup.exe")
Else
SetError (1)
EndIf
EndFunc

##### Share on other sites

Thanks, I will try it and let you know.

first solution: at your script use AutoItSetOption - RunErrorsFatal

second solution:

Func AOLSetup()
If FileExists("V:\AOL\Setup.exe") Then
Run("V:\AOL\Setup.exe")
Else
SetError (1)
EndIf
EndFunc

##### Share on other sites

One Last question.

When I compile the script, how can I set an setup icon or change the default autoit icon with something else? for example: See between the +

$Title = GuiCreate(++ Icon here++ "AOL Software Installation", 700, 440,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, \$WS_CLIPSIBLINGS))

Thanks, I will try it and let you know.

##### Share on other sites

When you compile the script by running AutToExe, you can select an icon in the GUI.

##### Share on other sites

I do not wish the use the icons in the Autoexe, instead I would like to add a customize icon. Something that represents what the application is. It's silly, but I would like to know how to do it.

When you compile the script by running AutToExe, you can select an icon in the GUI.

##### Share on other sites

You'd use PhotoShop. Check out this icon I made...

P.S. - It looks much better in Explorer then on the desktop.

B.ico

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

##### Share on other sites

And another... This looks better, I thought of adding 'progress bars' to simulate the ones in your GUI.

P.S. - Again, this looks better in explorer then on the desktop.

B2.ico

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

##### Share on other sites

Cool, the only problem is that I don't have Photoshop. Maybe I can buy one later. But I like it. Is it possible to convert an DLL Control ID # 162 to an icon? Let me know.

And another... This looks better, I thought of adding 'progress bars' to simulate the ones in your GUI.

P.S. - Again, this looks better in explorer then on the desktop.

##### Share on other sites

Finish.

Thanks everyone for all the help. I am finally done with my silly project. My friend will be really happy (I hope). I was able to create an Icon from the Shell32.dll file. There is software call "MicroAngelo" that is capable of either creating a new icon or find an icon. When the DVD is created, there's an autorun that launches the autoit executable with the Setup Icon as well. This may not be useful for most of you, but I'd thought I share this information anyway. Attached is a picture of the autorun.

Cool, the only problem is that I don't have Photoshop. Maybe I can buy one later. But I like it. Is it possible to convert an DLL Control ID # 162 to an icon? Let me know.

Finish.bmp

##### Share on other sites

One Last question.

When I compile the script, how can I set an setup icon or change the default autoit icon with something else? for example: See between the +

#Compiler_Icon=name_of_icon.ico

##### Share on other sites

Or, instead of normal compiling, choose "Compile with options"

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

##### Share on other sites

Thanks, I will add it and try it.

#Compiler_Icon=name_of_icon.ico

##### Share on other sites

or...

Technically, there's no real limit to the dimensions of icons stored in there, so you can use it for GUI images, too. And being icons, they keep thier transparencies; very handy for buttons.

I find all this very useful, you might, too.

-mu

##### Share on other sites

Thank you for the advise. I will play with it more. It's a cool software once you know how to use it.

Take care.

or...

Technically, there's no real limit to the dimensions of icons stored in there, so you can use it for GUI images, too. And being icons, they keep thier transparencies; very handy for buttons.

I find all this very useful, you might, too.

-mu

## Create an account

Register a new account