Jump to content

Recommended Posts

Posted (edited)

Hi!

In the last days it seems to me that AutoIt3 will not work properly any more on my machine.

This simple script does not work for me. Neither the "Start" nor the "Quit"-function will be called.

Nearly every day I use the GUI functions of AutoIt and it works well but this script does not work and I don't see any mistake.

#NoTrayIcon
#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Func OnAutoItStart()
ShowGUI()
EndFunc

Func ShowGUI()
Local $gui
Local $inp_OldFile, $inp_NewFile, $inp_DiffFile
Local $btn_Start, $btn_Quit
    
$gui  = GUICreate("Test-GUI", 396, 140)
GUICtrlCreateLabel("Source",  12,  16,  80, 12)
$inp_OldFile  = GUICtrlCreateInput("",  80,  12, 280, 20)
$inp_OldFile  = GUICtrlCreateButton("...", 366,  12,  20, 20)
GUICtrlCreateLabel("Target",  12,  42,  80, 12)
$inp_NewFile  = GUICtrlCreateInput("",  80,  40, 280, 20)
$btn_NewFile  = GUICtrlCreateButton("...", 366,  40,  20, 20)
GUICtrlCreateLabel("Folder",  12,  68,  80, 12)
$inp_DiffFile = GUICtrlCreateInput("",  80,  66, 280, 20)
$btn_DiffFile = GUICtrlCreateButton("...", 366,  66,  20, 20)
GUICtrlCreateGroup  ("" ,  -4,  92, 410, 50)
$btn_Start = GUICtrlCreateButton ("&Start",  80, 108, 100, 24)
$btn_Quit = GUICtrlCreateButton ("&Quit", 184, 108, 100, 24)
    
GUICtrlSetOnEvent($btn_Quit, "Quit")
GUICtrlSetOnEvent($btn_Start, "Start")
    
GuiSetState(@SW_SHOW)
    
While 1
    Sleep(10)
WEnd
EndFunc

Func Quit()
MsgBox(32, "Quit", "")
Exit
EndFunc

Func Start()
MsgBox(32, "Start", "")
EndFunc

Can you see any mistake and help me?

Regards,

Buffo

Edited by Buffo
Posted (edited)

#NoTrayIcon
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

ShowGUI()

Func ShowGUI()
    Local $gui
    Local $inp_OldFile, $inp_NewFile, $inp_DiffFile
    Local $btn_Start, $btn_Quit, $btn_NewFile, $btn_DiffFile

    $gui = GUICreate("Test-GUI", 396, 140)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
    GUICtrlCreateLabel("Source", 12, 16, 80, 12)
    $inp_OldFile = GUICtrlCreateInput("", 80, 12, 280, 20)
    $inp_OldFile = GUICtrlCreateButton("...", 366, 12, 20, 20)
    GUICtrlCreateLabel("Target", 12, 42, 80, 12)
    $inp_NewFile = GUICtrlCreateInput("", 80, 40, 280, 20)
    $btn_NewFile = GUICtrlCreateButton("...", 366, 40, 20, 20)
    GUICtrlCreateLabel("Folder", 12, 68, 80, 12)
    $inp_DiffFile = GUICtrlCreateInput("", 80, 66, 280, 20)
    $btn_DiffFile = GUICtrlCreateButton("...", 366, 66, 20, 20)
    GUICtrlCreateGroup("", -4, 92, 410, 50)
    $btn_Start = GUICtrlCreateButton("&Start", 80, 108, 100, 24)
    $btn_Quit = GUICtrlCreateButton("&Quit", 184, 108, 100, 24)

    GUICtrlSetOnEvent($btn_Quit, "Quit")
    GUICtrlSetOnEvent($btn_Start, "Start")

    GUISetState(@SW_SHOW)

    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>ShowGUI

Func Quit()
    MsgBox(32, "Quit", "")
    Exit
EndFunc   ;==>Quit

Func Start()
    MsgBox(32, "Start", "")
EndFunc   ;==>Start

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

I don't understand!?

It works if I omit the Func OnAutoItStart()?

Why is that so? I use OnAutoItStart() because I don't like other code than declarations of global vars and constants and the header of the script out of a function.

Can you explain? This function should only call the other function when the script starts.

:ph34r: Ah... now I understand...

...while writing this I recognized my mistake: The function will be called BEFORE the Opt("GUIOnEventmode", 1) is passed.

I have to go to bed because my whole concentration seems to be lost :lmao:

Regards,

Buffo

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
  • Recently Browsing   0 members

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