Sign in to follow this  
Followers 0
RafaelMaciel

AutoitObject + Koda

4 posts in this topic

Hi peaple,
 
I'm start use AutoitObject and Koda at onde script, and the situation is:
 
The next code works perfect and the window opens normaly.

--------------------------------------------------------------------------
 
;Includes das telas
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Func _Telas_Analista_main()
   #Region ### START Koda GUI section ### Form=E:Rami SistemasProdutoTelasAnalistaFormMain.kxf
   $AnalistaFormMain = GUICreate("Analista", 224, 438, 10, 10, BitOR($WS_SYSMENU, $WS_BORDER, $WS_CAPTION))
   GUISetState(@SW_SHOW)
   #EndRegion ### END Koda GUI section ###
   While 1
   $nMsg = GUIGetMsg()
   ConsoleWrite("!...Tela  travada'" & @CRLF)
   Switch $nMsg
   Case $GUI_EVENT_CLOSE
   Exit
 
   EndSwitch
   WEnd
EndFunc
 
_Telas_Analista_main()
 

--------------------------------------------------------------------------------------------------------------------------------------------------------

but, the next code are the up code with AutoitObject, and this, when I execute, his open the window but this stop!!

--------------------------------------------------------------------------------------------------------------------------------------------------------
 
#comments-start
 AutoIt Version: 0.1
 Author:         Rafael Scolari Maciel
 Objetivo:       Gestão da execução das rotinas de analise
#comments-end
 
#include "AutoitObject.au3"
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
_AutoItObject_StartUp()
Global $C_Analista = _Analista_create();global detentora do objeto ANALISTA
 
Func _Analista_create()
Local $oClassObject = _AutoItObject_Class()
$oClassObject.Create()
$oClassObject.AddMethod("formMain", "_Analista_main")
$oClassObject.AddDestructor("_DestructorForAnalista")
Return $oClassObject.Object
EndFunc
 
Func _Analista_main($oSelf)
   #Region ### START Koda GUI section ### Form=E:Rami SistemasProdutoTelasAnalistaFormMain.kxf
   $AnalistaFormMain = GUICreate("Analista", 224, 438, 10, 10, BitOR($WS_SYSMENU, $WS_BORDER, $WS_CAPTION))
   GUISetState(@SW_SHOW)
   #EndRegion ### END Koda GUI section ###
 
   While 1
 $nMsg = GUIGetMsg()
 ConsoleWrite("!...Tela  travada'" & @CRLF)
 Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
 EndSwitch
   WEnd
EndFunc
 
Func _DestructorForAnalista($oSelf)
ConsoleWrite("!...destructing... 'Analista'" & @CRLF)
 EndFunc
 
 $C_Analista.formMain
 

--------------------------------------------------------------------------------------------------------------------------------------------------------

Please, someone can help me?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I know very little about AutoItObject, but I have made a variation of your script which shows the same problem. I tried using OnEventMode to see if it made any difference but it does not.

My conclusion is that there is something wrong with AutoItObject. But I might be using an old version and so might you, and I might be wrong. Check that the latest version gives the same problem and if it does then add a post in the autoitobject thread with this problem - you are more likely to get a reply from someone who can help you there. You should also check that this problem isn't already being dealt with of course.

;Includes das telas
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "C:\Program Files\Autoit3\include\AutoitObject.au3"

Dim $doexit

_AutoItObject_StartUp()

extern2("Window 1") ;create window without using objects


Global $C_Analista = _Analista_create();global detentora do objeto ANALISTA


$C_Analista.formMain

$C_Analista = 0;destroy th eobject

_AutoItObject_Shutdown();don't forget this line although the examples do


Func _Analista_create()
    Local $oClassObject = _AutoItObject_Class()
    $oClassObject.Create()
  
    $oClassObject.AddMethod("formMain", "_Analista_main")
    $oClassObject.AddDestructor("_DestructorForAnalista")
    Return $oClassObject.Object
EndFunc   ;==>_Analista_create

Func _Analista_main($oSelf)
    extern2("window from object")
EndFunc

func extern2($title)
    AutoItSetOption("guioneventmode",1)
    $doexit = 0
    #region ### START Koda GUI section ### Form=E:\Rami Sistemas\Produto\Telas\AnalistaFormMain.kxf
    $AnalistaFormMain = GUICreate($title, 224, 438, 10, 10);, BitOR($WS_SYSMENU, $WS_BORDER, $WS_CAPTION))
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    ConsoleWrite("step 4" & @LF)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGui")
    While $doexit = 0
        sleep(30)
    WEnd
EndFunc   ;==>_Analista_main

Func CloseGui()
    ConsoleWrite("close gui?" & @LF)
    $doexit = 1
EndFunc


Func _DestructorForAnalista($oSelf)
    ConsoleWrite("!...destructing... 'Analista'" & @CRLF)
EndFunc   ;==>_DestructorForAnalista
Edited by martin
1 person likes this

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.

Share this post


Link to post
Share on other sites

Thanks Martin,

I will use your code to show better this situation at the new post.

Very thanks!

Share this post


Link to post
Share on other sites

Hi (probably replying to late to this but I just came across it whilst looking for something else)

It is not a good idea to put your main loop inside a method.

Basically the code will run inside the method and it doesn't get a chance to process your input.

Here is an alternative approach (hope it helps):

#include 'AutoitObject.au3'
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
_AutoItObject_StartUp()

#region Form Class ========================================
Func Form()
    Local $this = _AutoItObject_Class()

    ; field properties
    $this.AddProperty('Handle', $ELSCOPE_READONLY)
    $this.AddProperty('IsInitialised', $ELSCOPE_READONLY, False)

    ; get/set propeties
    $this.AddMethod('Visible', '___Form_Visible')

    ; methods
    $this.AddMethod('Load', '___Form_Load')

    ; destructors
    $this.AddDestructor('_Analista_Finalise')
    Return $this.Object
EndFunc   ;==>Form
;-------------------------------------------------------
Func ___Form_Load($self, $iCaption = 'Form', $iLeft = Default, $iTop = Default, $iWidth = Default, $iHeight = Default, $iStyle = Default, $iStyleEx = Default)
    $self.Handle = String(GUICreate($iCaption, $iWidth, $iHeight, $iLeft, $iTop, $iStyle, $iStyleEx))
    $self.IsInitialised = True
EndFunc   ;==>___Form_Load
;-------------------------------------------------------
Func ___Form_Visible($self, $iVisible = Default)
    If Not $self.IsInitialised Then Return SetError(1)
    Switch @NumParams
        Case 1 ; get
            Return (BitAND(WinGetState(HWnd($self.Handle), ''), 2) = 1) ; 2 = Window is visible
        Case 2 ; set
            If Not IsBool($iVisible) Then Return SetError(2)
            Switch $iVisible
                Case True
                    Return WinSetState(HWnd($self.Handle), '', @SW_SHOW)
                Case False
                    Return WinSetState(HWnd($self.Handle), '', @SW_HIDE)
            EndSwitch
    EndSwitch
EndFunc   ;==>___Form_Visible
;-------------------------------------------------------
Func ___Form_Finalise($self)
    If Not $self.IsInitialised Then Return SetError(1)
    GUIDelete(HWnd($self.Handle))
EndFunc   ;==>___Form_Finalise
#endregion Form Class ========================================


; Main Program
Global $C_Analista = Form()
$C_Analista.Load('Analista', 10, 10, 224, 438, BitOR($WS_SYSMENU, $WS_BORDER, $WS_CAPTION))
$C_Analista.Visible = True

While 1
    $nMsg = GUIGetMsg()
    ConsoleWrite('!...Tela  travada' & @CRLF)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $C_Analista.Visible = False
            $C_Analista = 0
            _AutoItObject_Shutdown()
            Exit
    EndSwitch
WEnd

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