Sign in to follow this  
Followers 0
HockeyFan

Newbie Question

2 posts in this topic

Hello... :ph34r:

Is it possible to call another Func call wihtin a func call? I have a GUI window that I want to open when I click on the OK button of the first GUI...but I'm getting the following error messages...

>Running AU3Check (1.54.3.0)  params:  from:C:\Program Files\AutoIt3
C:\...: ERROR: syntax error
Func
^
C:\... : ERROR: ExitYes(): undefined function.
    GUICtrlSetOnEvent($ExitYes, "ExitYes")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\... : ERROR: ExitNo(): undefined function.
    GUICtrlSetOnEvent($ExitNo, "ExitNo")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\...- 3 error(s), 0 warning(s)
!>AU3Check ended.rc:2
>Exit code: 0   Time: 0.625

Thanks in advance! :lmao:

Share this post


Link to post
Share on other sites



Hello... :ph34r:

Is it possible to call another Func call wihtin a func call? I have a GUI window that I want to open when I click on the OK button of the first GUI...but I'm getting the following error messages...

>Running AU3Check (1.54.3.0)  params:  from:C:\Program Files\AutoIt3
C:\...: ERROR: syntax error
Func
^
C:\... : ERROR: ExitYes(): undefined function.
    GUICtrlSetOnEvent($ExitYes, "ExitYes")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\... : ERROR: ExitNo(): undefined function.
    GUICtrlSetOnEvent($ExitNo, "ExitNo")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\...- 3 error(s), 0 warning(s)
!>AU3Check ended.rc:2
>Exit code: 0   Time: 0.625

Thanks in advance! :lmao:

GUICtrlSetOnEvent($EventID, "FunctionName") Does not allow the function to have any parameters. Take a look at the following template that I have created for my OnEvent Scripts.

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;Program Name:  Template - OnEventMode
;Description:   Template for OnEventMode GUI scripts
;Filename:      Template - OnEventMode.au3
;Used With:     
;Created by:    Jarvis J Stubblefield (support "at" vortexrevolutions "dot" com)
;Created on:    06/20/2006
;Modified on:   
;Modified by:   
;Version:       0.0.2
;Copyright:     Copyright (C) 2006 Vortex Revolutions. All Rights Reserved.
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Declare Variables ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Global $wHeight, $wWidth, $wMain            ;Window variables
Global $wTitle                              ;Window variables II

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Preprocessor ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1) ;Set GUI to ONEvent Mode.

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** File Installations ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Registry Information ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Command Line Options ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#cs UNCOMMENT FOR COMMANDLINE!
If $CmdLine[0] > 0 Then
    If StringRight($CmdLine[1], 4) = ".ext" Then
        _SomeFunc($CmdLine[1])
    Else
        _ErrorMsg("Incorret file extension. Please try again.")
        _TerminateApp()
    EndIf
EndIf
#ce

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Define Variables ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$wHeight = 300
$wWidth  = 300
$wTitle  = "Template - OnEventMode"

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Creation ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;Main GUI Creation
$wMain  = GUICreate($wTitle, $wWidth, $wHeight)
;Main Options
$btnMOptions    = GUICtrlCreateButton("Options", 5, ($wHeight - 25), 94, 20)
;Main Help
$btnMHelp       = GUICtrlCreateButton("Help", 103, ($wHeight - 25), 94, 20)
;Main Exit
$btnMExit       = GUICtrlCreateButton("Exit", 201, ($wHeight - 25), 94, 20)

;Disable Options and Help until added
GUICtrlSetState($btnMOptions, $GUI_DISABLE)
GUICtrlSetState($btnMHelp, $GUI_DISABLE)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Set Events ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;GUI Events Handled by _GUIEventHandler()
GUICtrlSetOnEvent($btnMOptions, "_GUIEventHandler")
GUICtrlSetOnEvent($btnMExit, "_GUIEventHandler")
GUICtrlSetOnEvent($btnMHelp, "_GUIEventHandler")

;System Events Handled by _SysEventHandler()
GUISetOnEvent($GUI_EVENT_CLOSE, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_RESTORE, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_RESIZED, "_SysEventHandler", $wMain)
GUISetOnEvent($GUI_EVENT_DROPPED, "_SysEventHandler", $wMain)

GUISetState(@SW_SHOW, $wMain)

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Main Program Loop ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    Sleep(100)
WEnd

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** GUI Event Functions ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Func _GUIEventHandler()
    Switch @GUI_CtrlId
        Case $btnMExit
            _TerminateApp()
        Case $btnMOptions
        Case $btnMHelp
    EndSwitch
EndFunc

Func _SysEventHandler()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            If @GUI_WinHandle <> $wMain Then
                _TerminateGUI(@GUI_WinHandle)
            Else
                _TerminateApp()
            EndIf
        Case $GUI_EVENT_MINIMIZE
        Case $GUI_EVENT_RESTORE
        Case $GUI_EVENT_MAXIMIZE
        Case $GUI_EVENT_PRIMARYDOWN
        Case $GUI_EVENT_PRIMARYUP
        Case $GUI_EVENT_SECONDARYDOWN
        Case $GUI_EVENT_SECONDARYUP
        Case $GUI_EVENT_MOUSEMOVE
        Case $GUI_EVENT_RESIZED
        Case $GUI_EVENT_DROPPED
    EndSwitch
EndFunc

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;---*** Define Functions ***---
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

#region --- Internal Functions
    ;Displays an error message to the user, and optionally times out.
    Func _ErrorMsg($message, $time = 0)
        MsgBox(48 + 262144, "Error!", $message, $time)
    EndFunc

    ;Function to be used to terminate the application. (Clean up Application)
    Func _TerminateApp()
        Exit
    EndFunc
    
    ;This function is to be used with programs that have multiple GUI's and
    ;will optionally terminate application if called incorrectly on the main
    ;GUI.
    Func _TerminateGUI($gui_hWnd, $gui_title = "")
        If $gui_title = "" Then $gui_title = $wTitle
        If $gui_hWnd = $hSome3rdLayerGUI Then
            ;Do 3rd Layer GUI stuff (for example look at RAS-NEW.au3)
            GUIDelete($gui_hWnd)
        Else
            GUIDelete($gui_hWnd)
            If $gui_hWnd = $wMain Then
                _TerminateApp()
            Else
                WinActivate($gui_title)
            EndIf
        EndIf
    EndFunc
#endregion Internal Functions

The above should help you figure out how to exit certain areas of the script, or whole program.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
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
Sign in to follow this  
Followers 0