Jump to content

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 ??
Link to comment
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)

Link to comment
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
        MsgBox(0x10,"Error", "Executable Not Found!")
    Else
    EndIf
EndFunc ;==>Set_Exit

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

Link to comment
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
        MsgBox(0x10,"Error", "Executable Not Found!")
    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)
        MsgBox(0x10,"Error", "Executable Not Found!")
    EndIf
EndFunc
Link to comment
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)
        MsgBox(0x10,"Error", "Executable Not Found!")
    EndIf
EndFunc
Link to comment
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.

Link to comment
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.

Link to comment
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
Link to comment
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.

Link to comment
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

Link to comment
Share on other sites

or...

#Compiler_Icon = C:\path\to\where\I\keep\my\icons\my-icon.icooÝ÷ Øò¢ébëhç©jYr¢êârìz'zZq㧶¬¹¸ÞrÚÊ'°È®'éh«yéíç(¢W¬¶'(çb¶ß¢¹,j»éÞjÛax"¶¬Ëaz«¨¶X­ªâjz®¢Ð,Áéejǧi¹b¨ºÚ­¨"rì®(!¶­¡÷eƧuì^rëZnW¬¦ëm«[i¼¢*.­Ê'µìméî~ÞÅçâë7Þ+ZZ0³*.¶½ë(ëaxjY^v«¨¶'(X­ªâzÊ®¢×âë¢{Zx§©òézºÊ'±8^±èZ½æ§ªê-Éjº^Æק²*'nër¢ç欩àzØZ¶Ú*º]Z®¢Öµêðj·ljwn±èî²Ùb쨺h Û¬zÈ^]övYM£¨¹Æ§iDzËaz'(Æò¶¢®)Ý{§v붦h¢¼¨º¶©¦Xjبlv.éí±»­~â¶Æî¶Ú'°ezW¦z{lz׵Ʈ¶­sduT7G&Å6WDÖvRb33c¶×ö'WGFöâÂgV÷C¶×ö6öç2æFÆÂgV÷C²Âb33c¶6öåöæFW

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

Link to comment
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...

#Compiler_Icon = C:\path\to\where\I\keep\my\icons\my-icon.icooÝ÷ Øò¢ébëhç©jYr¢êârìz'zZq㧶¬¹¸ÞrÚÊ'°È®'éh«yéíç(¢W¬¶'(çb¶ß¢¹,j»éÞjÛax"¶¬Ëaz«¨¶X­ªâjz®¢Ð,Áéejǧi¹b¨ºÚ­¨"rì®(!¶­¡÷eƧuì^rëZnW¬¦ëm«[i¼¢*.­Ê'µìméî~ÞÅçâë7Þ+ZZ0³*.¶½ë(ëaxjY^v«¨¶'(X­ªâzÊ®¢×âë¢{Zx§©òézºÊ'±8^±èZ½æ§ªê-Éjº^Æק²*'nër¢ç欩àzØZ¶Ú*º]Z®¢Öµêðj·ljwn±èî²Ùb쨺h Û¬zÈ^]övYM£¨¹Æ§iDzËaz'(Æò¶¢®)Ý{§v붦h¢¼¨º¶©¦Xjبlv.éí±»­~â¶Æî¶Ú'°ezW¦z{lz׵Ʈ¶­sduT7G&Å6WDÖvRb33c¶×ö'WGFöâÂgV÷C¶×ö6öç2æFÆÂgV÷C²Âb33c¶6öåöæFW

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

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...