[Ex] AutoItObject

Partagez vos scripts, et vos applications AutoIt.
Règles du forum
.
Répondre
Avatar du membre
matwachich
Membre émérite
Membre émérite
Messages : 986
Enregistré le : lun. 19 oct. 2009 04:04
Localisation : Algérie
Status : Hors ligne

[Ex] AutoItObject

#1

Message par matwachich »

Je ne sais pas si vous connaissez cet Bibliothèque, elle sert à utiliser une syntaxe de POO (Programmation Orientée Objet) avec AutoIt.

En tous cas, je me dis qu'elle en vaut la peine, alors j'ai fait un petit exemple qui montre sont fonctionnement basique (Ceux qui ont lu le cours de M@teo21 du site du zero sur le C++ reconnaîtront cet exemple!)
personne.au3
(2.9 Kio) Téléchargé 340 fois
Et maintenant, avec 2 classes, enchevêtrées!
Fichiers joints
personne.au3
(4.57 Kio) Téléchargé 270 fois
Modifié en dernier par matwachich le sam. 11 déc. 2010 23:59, modifié 1 fois.
Sortons VW du coté obscure! - La curiosité est un vilain défaut! Cliquez ici
Avatar du membre
Yogui
Niveau 9
Niveau 9
Messages : 689
Enregistré le : ven. 18 avr. 2008 17:29
Status : Hors ligne

Re: [Ex] AutoItObject

#2

Message par Yogui »

Super exemple bien plus parlant que ceux fournit dans l'archive :) en tout cas plus ludique
Avatar du membre
matwachich
Membre émérite
Membre émérite
Messages : 986
Enregistré le : lun. 19 oct. 2009 04:04
Localisation : Algérie
Status : Hors ligne

Re: [Ex] AutoItObject

#3

Message par matwachich »

Bah heureux que ça vous plaise!
Je compte ajouter des trucs, genre (comme le tuto C++) une 2e classe (Arme) et de faire (si possible en AutoIt) une interaction entre les 2 classes!
Sortons VW du coté obscure! - La curiosité est un vilain défaut! Cliquez ici
Avatar du membre
matwachich
Membre émérite
Membre émérite
Messages : 986
Enregistré le : lun. 19 oct. 2009 04:04
Localisation : Algérie
Status : Hors ligne

Re: [Ex] AutoItObject

#4

Message par matwachich »

Voila c'est fait! (voire 1er post)
Sortons VW du coté obscure! - La curiosité est un vilain défaut! Cliquez ici
Avatar du membre
funkey
Niveau 2
Niveau 2
Messages : 17
Enregistré le : mer. 25 nov. 2009 08:32
Localisation : Austria
Status : Hors ligne

Re: [Ex] AutoItObject

#5

Message par funkey »

Grand exemple.
Je viens de commencer un peu avec AutoItObject.
Voici un échantillon pour un dialogue de download:

Code : Tout sélectionner

#include <AutoItObject.au3>
#include <WinAPI.au3>

;===============================================================================
#API "Windows Progress Dialog"
; IProgressDialog
;===============================================================================

Global Const $PROGDLG_NORMAL = 0x00000000 ;default normal progress dlg behavior
Global Const $PROGDLG_MODAL = 0x00000001 ; the dialog is modal to its hwndParent (default is modeless)
Global Const $PROGDLG_AUTOTIME = 0x00000002 ; automatically updates the "Line3" text with the "time remaining" (you cant call SetLine3 if you passs this!)
Global Const $PROGDLG_NOTIME = 0x00000004 ; we dont show the "time remaining" if this is set. We need this if dwTotal < dwCompleted for sparse files
Global Const $PROGDLG_NOMINIMIZE = 0x00000008 ; Do not have a minimize button in the caption bar.
Global Const $PROGDLG_NOPROGRESSBAR = 0x00000010 ; Don't display the progress bar
Global Const $PROGDLG_MARQUEEPROGRESS = 0x00000020 ; Vista and above only
Global Const $PROGDLG_NOCANCEL = 0x00000040 ; Vista and above only

Global Const $PDTIMER_RESET = 0x00000001
Global Const $PDTIMER_PAUSE = 0x00000002
Global Const $PDTIMER_RESUME = 0x00000003

Global Const $AVI_SEARCH = 150
Global Const $AVI_SEARCH_DOC = 151
Global Const $AVI_SEARCH_PC = 152
Global Const $AVI_MOVE = 160
Global Const $AVI_COPY = 161
Global Const $AVI_DELETE = 162
Global Const $AVI_EMPTY_RECYCLEBIN = 163
Global Const $AVI_DELETE_DIRECT = 164
Global Const $AVI_COPY_DOC = 165
Global Const $AVI_SEARCH_IE = 166
Global Const $AVI_MOVE_OLD = 167
Global Const $AVI_COPY_OLD = 168
Global Const $AVI_DELETE_DIRECT_OLD = 169
Global Const $AVI_DOWNLOAD = 170

;===============================================================================
#interface "IProgressDialog"
Global Const $sCLSID_IProgressDialog = "{F8383852-FCD3-11d1-A6B9-006097DF5BD4}"
Global Const $sIID_IProgressDialog = "{EBBC7C04-315E-11d2-B62F-006097DF5BD4}"

; Definition
Global Const $dtagIProgressDialog = $dtagIUnknown & _
        "StartProgressDialog hresult(hwnd;ptr;dword;ptr);" & _
        "StopProgressDialog hresult();" & _
        "SetTitle hresult(wstr);" & _
        "SetAnimation hresult(handle;uint);" & _
        "HasUserCancelled int();" & _
        "SetProgress hresult(dword;dword);" & _
        "SetProgress64 hresult(uint64;uint64);" & _
        "SetLine hresult(dword;wstr;int;ptr);" & _
        "SetCancelMsg hresult(wstr;ptr);" & _
        "Timer hresult();"
; List
Global Const $ltagIProgressDialog = $ltagIUnknown & _
        "StartProgressDialog;" & _
        "StopProgressDialog;" & _
        "SetTitle;" & _
        "SetAnimation;" & _
        "HasUserCancelled;" & _
        "SetProgress;" & _
        "SetProgress64;" & _
        "SetLine;" & _
        "SetCancelMsg;" & _
        "Timer;"
;===============================================================================

_AutoItObject_StartUp()

Global $FileToDownload = "http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"
Global $FileDestination = @ScriptDir & "/autoit-v3-setup.exe"

Global $oDlg = _AutoItObject_ObjCreate($sCLSID_IProgressDialog, $sIID_IProgressDialog, $dtagIProgressDialog)

$oDlg.SetTitle("Downloading...")
$oDlg.SetAnimation(Number(_WinAPI_GetModuleHandle("shell32.dll")), $AVI_DOWNLOAD)
$oDlg.SetLine(1, "autoit-v3-setup.exe from http://www.autoitscript.com", 0, 0)
$oDlg.StartProgressDialog(0, 0, $PROGDLG_NOMINIMIZE, 0)

Global $FileSize = InetGetSize($FileToDownload)
Global $hDownload = InetGet($FileToDownload, $FileDestination, 1, 1)
Global $Loaded, $Loaded_old[6], $TimeConstant = 100000
Global $dwCompleted = 0
Global $Diff, $Start = TimerInit()

Do
    Sleep(500)
    $Diff = TimerDiff($Start)
    $dwCompleted = StringFormat("%.0f", $Diff / 100)
    $Canceled = $oDlg.HasUserCancelled()
    $Loaded = InetGetInfo($hDownload, -1)
    $TimeConstant = StringFormat("%.0f", 1 / (($Loaded[0] - $Loaded_old[0]) * 2) * ($FileSize - $Loaded[0]) * 10) + $dwCompleted
    $oDlg.SetProgress($dwCompleted, $TimeConstant)
    $oDlg.SetLine(2, StringFormat("%.0f %% from %.2f MB (%.0f kB/sec)", $Loaded[0] / $FileSize * 100, $FileSize / (1024 * 1024), ($Loaded[0] - $Loaded_old[0]) * 2 / 1024), 0, 0)
    $Loaded_old = $Loaded
Until $Canceled[0] = 1 Or $Loaded[2]

InetClose($hDownload)

$oDlg.StopProgressDialog()

If $Loaded[2] Then
    MsgBox(64, "Info", "File successfully downloaded")
Else
    FileDelete($FileDestination)
    MsgBox(16, "Error", "The download was aborted")
EndIf

_AutoItObject_Shutdown()
 
Fichiers joints
Download AutoIt-Setup.au3
(4.36 Kio) Téléchargé 197 fois
Autoit toujours
Répondre