-
Posts
26 -
Joined
-
Last visited
About Elias
- Birthday 06/03/1958
Profile Information
-
Location
São Paulo - SP - Brazil
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Elias's Achievements

Seeker (1/7)
1
Reputation
-
boomingranny reacted to a post in a topic: The requested action with this object has failed.
-
The requested action with this object has failed.
Elias replied to chemthan's topic in AutoIt General Help and Support
Translating to English -
The requested action with this object has failed.
Elias replied to chemthan's topic in AutoIt General Help and Support
I once had this problem in an earlier version of AutoIt, The problem was caused by the $oError not being an Objetc. If this situation Appears it cause Object failed when accessing $oError.scriptline ou any other propriety of $oError ant the Srcript is terminated The solution was to determine whether $oErro is an Object before mounting the error se the example below ; INTERCEPTOR Of COMError for IE =========================================== Local $R = _IEErrorHandlerRegister("_ErrFunc") If $R <> 1 Or @error Then MsgBox(0x40010,Default,'ERROR Executing: $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")') Global $sCOMErr ; String with last Error Global $oCOMError ; Objeto with last Error Global $Trace = True ; Set to display the Error in the Console ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) If Not IsObj($oError) Then ; This is nessesary to prevento the program crashing ConsoleWrite("! ===================== _ErrFunc($oError) $oError Is Not Objeto ==========================================" & @LF) Return EndIf $oCOMError = $oError ; Armazena uma Copia dos Erros $sCOMErr = @ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF If $Trace Then ConsoleWrite(@CRLF & @CRLF & "! ================= Object ERROR ==========================================================" & @CRLF & @CRLF & _ ">" & StringReplace(StringReplace($sCOMErr,@CRLF & @CRLF,@CRLF,0,1),@CRLF,@CRLF & ">",0,1) & @CRLF & _ "! =========================================================================================" & @CRLF & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>_ErrFunc Another solution if you are using the AutoIt version 3.3.14.2 is to adjust the #Include <IE.au3> Func below added to row If Not IsObj ($ oCOMError) Then Return; IT can be invaluable because it can happen to $ oCOMError not be an object The doubt here is if indeed there was a COMError or not there was to have put q Return SetError ($_ IEStatus_ComError) rather than only Return if not Object ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IEInternalErrorHandler ; Description ...: to be called on error ; Author ........: Dale Hohm ; Modified ......: ; =============================================================================================================================== Func __IEInternalErrorHandler($oCOMError) If Not IsObj($oCOMError) Then Return ; ISSO É Nesessario pois pode acontecer de $oCOMError não ser um Objeto If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then ConsoleWrite("--> " & __COMErrorFormating($oCOMError, "----> $IEComError") & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle -
HotKey (Ctrl+A) for Select All in the selected Edit Box
Elias replied to DarkBoost's topic in AutoIt GUI Help and Support
Any Edit Class = Edit e InputBox The problem is basically implement Ctrl+a to the Edit Control to Select All This worked well using GUIGetMsg () but when working with GUIOnEventMode this does not work Below implementation to intercept Ctrl+a and Enter keys Create dummy for accelerator key to activate $cSelAll = GUICtrlCreateDummy() $cEnter = GUICtrlCreateDummy() ; Set accelerator for Ctrl+a , This intercepts all controls including InputBox Dim $aAccelKeys[][]=[["^a", $cSelAll],["{enter}", $cEnter]] GUISetAccelerators($aAccelKeys) The program below allows you to change the GUIGetMsg() Mode <=> GUIOnEventMode simply changing the CheckBox 26/01/2016 PROBLEM SOLVED, GUICtrlGetHande($id) returns 0 for Dummy Controls and a Was not seting the event #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Elias Assad Neto Script Function: Teste Ctrl+a To Select All text in Edit Control Problem: DOESN'T work in GUIOnEvent #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Global $EventMode = False ; Start Mode If $EventMode Then Opt("GUIOnEventMode", 1) #Region GUI #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $hGUI = GUICreate("Ctrl+a Select All Test", 502, 502, 192, 125) $idCBGUIOnEvent = GUICtrlCreateCheckbox("GUIOnEvent Test", 8, 10, 105, 17) $idLabelInput = GUICtrlCreateLabel("Input Box", 136, 12, 49, 17) $idLabelEdit = GUICtrlCreateLabel("Edit Control", 12, 32, 58, 17) $idInput = GUICtrlCreateInput("Ctrl+a Stop Workin with OnEvent", 192, 10, 289, 21) $idEdit1 = GUICtrlCreateEdit("", 10, 50, 480, 440) GUICtrlSetData(-1, "here is some text, Ctrl+a Only Whorks if Not in GUIOnEventMode Mode") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Create dummy for accelerator key to activate $cSelAll = GUICtrlCreateDummy() $cEnter = GUICtrlCreateDummy() ; Set accelerator for Ctrl+a , This intercepts all controls including InputBox Dim $aAccelKeys[][]=[["^a", $cSelAll],["{enter}", $cEnter]] GUISetAccelerators($aAccelKeys) If 1 Then ; Crate Events for All Controls It Works in Not GUIOnEventMode too For $id=-13 To -3 ; $GUI_EVENT_DROPPED(-13) to $GUI_EVENT_CLOSE(-3) GUISetOnEvent($id, "GUIEvent") Next $id = 3 ; Controls Start at id = 3 $k = 0 ; Limit Couter Do $h = GUICtrlGetHandle($id) ; test if control exist If $h <> 0 Then ; Is Control GUICtrlSetOnEvent($id, "GUIEvent") ; Id Has Contro Set Event Else $k +=1 ; Id has no control this can hapen if control is deleted EndIf $id +=1 Until $k > 20 ; No more Controls EndIf If $EventMode Then _CheckBox($idCBGUIOnEvent,1) #Region Program LOOP =============================================================================================== While 1 If $EventMode Then Sleep(100) Else GUI_Msg(GUIGetMsg()) EndIf WEnd Func GUIEvent() ; Event Parser GUI_Msg(@GUI_CtrlId) EndFunc #EndRegion Program LOOP =============================================================================================== #Region GUI Process messages/Event Func GUI_Msg($GUI_CtrlId) ; Process GUI Message or Event If $GUI_CtrlId = 0 Then Return If $EventMode Then Local $GUI_WinHandle = @GUI_WinHandle, $GUI_CtrlHandle = @GUI_CtrlHandle Else Local $GUI_WinHandle = $hGUI, $GUI_CtrlHandle = GUICtrlGetHandle($GUI_CtrlId) EndIf If $GUI_CtrlId > 0 Then ConsoleWrite(StringFormat("> $GUI_CtrlId: %3d, @GUI_WinHandle: 0x%08X, @GUI_CtrlHandle: 0x%08X\n",$GUI_CtrlId, $GUI_WinHandle, $GUI_CtrlHandle)) Switch $GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $cSelAll _SelAll() Case $cEnter _EnterKey() Case $idCBGUIOnEvent $EventMode = _CheckBox($idCBGUIOnEvent) If $EventMode Then Opt("GUIOnEventMode", 1) ; Switch to GUIOnEvent Else Opt("GUIOnEventMode", 0) ; Switch to GUIGetMsg EndIf EndSwitch EndFunc #Region GUI Process messages/Event #Region GUI Aux Funcs Func _CheckBox($idControlID, $State = -1) ; (-1)-Read, (0)-Uncheck CheckBox (1)-Check ; Return State If $State = 0 Then GUICtrlSetState($idControlID, $GUI_UNCHECKED) If $State = 1 Then GUICtrlSetState($idControlID, $GUI_CHECKED) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_CheckBox Func _SelAll() ; Select All, used for Inbox and Edit controls Intercept Ctrl+a Local $hFocus = _WinAPI_GetFocus() Local $sClass = _WinAPI_GetClassName($hFocus) ConsoleWrite(StringFormat("- Class: %-12s $hFocus: 0x%08X\n", $sClass, $hFocus)) If $sClass = "Edit" Then _GUICtrlEdit_SetSel($hFocus, 0, -1) EndFunc ;==>_SelAll Func _EnterKey() ; Shows the control's text by pressing Enter on Edit or Inbox Control Local $hFocus = _WinAPI_GetFocus() Local $sClass = _WinAPI_GetClassName($hFocus) ConsoleWrite(StringFormat("- Class: %-12s $hFocus: 0x%08X\n", $sClass, $hFocus)) If $sClass = "Edit" Then MsgBox(0,"Enter pressed",_GUICtrlEdit_GetText($hFocus)) EndFunc ;==>_SelAll #EndRegion GUI Aux Funcs -
Hi is their a way to do this using "post method" so it can translate a big text in one pass?
-
Error Solved, AutoIt Error: variable must be of type Object This error was occurring in the AutoItScript 3.3.6.1 #include <IE.au3> Func __IEInternalErrorHandler() $IEComErrorScriptline = $oIEErrorHandler.scriptline ; <<< Error here ; ; If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle ; Solution Func __IEInternalErrorHandler() If isObject($oIEErrorHandler) Then ; Solution is to test if is rely an Object $IEComErrorScriptline = $oIEErrorHandler.scriptline ; ; Else $IEComErrorOutput = "$IEComErrorOutput is Not Object" EndIf If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
Error Resolved, AutoIt Error: variable must be of type Object This error was occurring in the AutoItScript 3.3.6.1 #include <IE.au3> in: Func __IEInternalErrorHandler() $IEComErrorScriptline = $oIEErrorHandler.scriptline ; <<< Error here : : If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle ; Solution Func __IEInternalErrorHandler() If isObject($oIEErrorHandler) Then $IEComErrorScriptline = $oIEErrorHandler.scriptline ;: ;: Else $IEComErrorOutput = "$IEComErrorOutput is Not Object" EndIf If $_IEErrorNotify Or $__IEAU3Debug Then ConsoleWrite($IEComErrorOutput & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
Hello, I run with SciTE, but the memory of the system overflew before , the problem occurred, is there a way to make the memory Buffer STDOUT rotating for de debug window? tks
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
Yes I'm using SciTE now to find the problem, I had to install the System at the client ans stay watching remotely.
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
Tried, didn´t work Places as #Obfuscator_Ignore_Funcs in the first colum
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
Thanks is what I'm doing now the problem is that the error is quit difficult to happen, is a system that automatize several secure pages for input an output data whit different uses of certificates in IE and communicates with a SQL server.
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
I've got a lot of errors, I use a lot of CALL do to Removable/Addable #includes my Call works like a Swich -### StripOnly Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement. >### current Func: ProcessaMatriz D:PROGRAMMMSC_ConsultaSiscargaConsultaSisCargaConsultaSisCarga.au3(2758,1) Warning for line:If $IDENTBusy Then Call($IDENT & "_Timer") -############################################################################################# -#### Obfuscator Found 32 Error(s)!!!! This means your script could have problems running properly. #### -############################################################################################# - Iteration 1 Strip Functions result: Output 8418 lines and stripped 15749 lines - Iteration 2 Strip Variables result: Output 0 lines and stripped 0 lines Is there another way to get a continuous code .au3 ? tks
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
This is only a example PopUp window, the error I'm getting is: variable must be of type Object AutoIt Error Line 12467 "(File: D:\AutoIt_Teste\GetFileLineError.exe") Error: Arrary variable has incorrect number of subscripts or subscript dimension rage exceeded. How can a find the Source Code line that caused this error? I tried to make a program that count the lines of the Include files, but it didn't work. I'm attaching the program code, I used to find the line error on the file Executable Error in Line12452 In the test program the error is in line 110 but my program report Line 834 the program and the test program are the same. the line to make the error occur is: If @Compiled And $as[uBound($as)] = "" Then $i=$i ; PopUp ERROR wen compiled ; IS NOT WORKING if includes present ;=============================================================================== ; ; Program Name: GetFileLineError ; Description: Find the line of File given the error line reported by the compiled program ; Ueses a Recursive call Sistem ; ; Parameter(s): $Path Program full path of Sorce program Ex. $path="C:\users\jony\autoit test\teste.au3" ; $Errorline Ex. $Errorline = 6551 ; Executable reported error Line ; $Debug Debug level, Defulat 0 No trce ; 1- Start and End File Lines, ; 2- File #include line Format:>(ident space)(FileName):(File Line) (Line text) ; 3- #include-once List ; ; Requirement(s): Source code used to create the executable ; $includePath Path of Include files with "\" Ex. $includePath="C:\Program Files (x86)\AutoIt3\Include\" ; ; Return Value(s): ConsoleWrite with de Program ou Mudule name and da file line of the error And MsgBox ; ; Author(s): Elias Assad Neto ; Date Created: June 6 2012 ; ;=============================================================================== ; Parameters Input $ProgramPath = "GetFileLineError.au3" $Errorline = 12452; Executable error Line $Debug = 2 ; Debug Level ; Includ Path ended with "\" $includePath="C:\Program Files (x86)\AutoIt3\Include\" If Not FileExists($includePath) Then $includePath="C:\Program Files\AutoIt3\Include\" If Not FileExists($includePath) Then MsgBox(0x10,"GetFileLineError"," Include File Directory Not Found") Exit EndIf ; Var initialization ======================================== $i = StringInStr($ProgramPath,"\",0,-1) ; Last "\" position $dir = StringLeft($ProgramPath,$i) ; Path Dir with "\" $file = StringMid($ProgramPath,$i+1) ; Program name $includeOnce = "" ; Include-Once File List $line = 0 $RecursionLevel = 0 ; Recursion Level used to ident debug lines ; Program Start ============================================= #include <INet.au3> ; Para enviar e-Mail em caso de *ERRO #include <IE.au3> #include <File.au3> #include <Array.au3> #include <GuiStatusBar.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ProgressConstants.au3> ;3.3.0.0 #include <WindowsConstants.au3> ;3.3.0.0 #include <StaticConstants.au3> #include <Timers.au3> $S = ProcessFile($file,$Debug) ConsoleWrite(@CRLF & @CRLF & $S & @CRLF) If $S <> "" Then MsgBox(0x40,"GetFileLineError",$S) Else MsgBox(0x40,"GetFileLineError","Executable Line " & $Errorline & " Not Found in: " & $file) EndIf ; Program End =============================================== ; Function Decalration ====================================== Func ProcessFile($FileName, $Trace=0) ; Recursive fuction to find Line, Debug Level 0,1,2,3 $ph = $dir; $s = FileRead($ph & $FileName) ; Search File in the source directory If $s = "" Then $ph = $includePath $s = FileRead($ph & $FileName) ; Search File in the Include directory EndIf $phf = $ph & $FileName If $s = "" Then Return "ERROR File " & $FileName & " NOT Found Search for Error line Aborted" $t = "" For $i=1 To $RecursionLevel ; Ident formating $t &= @TAB Next If StringInStr(StringLeft($s,16),"#include-once")=1 Then ; File #include-once detectaed If StringInStr($includeOnce,$FileName) Then Return ; Return file already processed $includeOnce &= $FileName & ";"; Adds the name of the File in the includeOnce list If $Trace >=3 Then ConsoleWrite($t & '$includeOnce="' & $includeOnce & '"' & @CRLF) ; Debug level 3 EndIf If $RecursionLevel = 0 Then If $Trace Then ConsoleWrite("+" & $t & "Programa Start( " & $FileName & " ) line " & $line+1 & @CRLF) ; Debug level >=1 Else If $Trace Then ConsoleWrite("+" & $t & "Include Start( " & $FileName & " ) line " & $line+1 & @CRLF) ; Debug level >=1 EndIf $RecursionLevel +=1 $s1 = "" Do ; ExitLoop Block $as = StringSplit($s,@CRLF,1) ; String to Array If @Compiled And $as[UBound($as)] = "" Then $i=$i ; PopUp ERROR wen compiled For $i=1 to UBound($as)-1 ; $i File Line $line+=1 ; Incrementa a linha Global If $line = $Errorline Then ; Achou a Linha terminou $s1 = "ERROR Line Found in " & $phf & " at File Line: " & $i ; Nome do Modulo mais linha local Return $s1 ; Retorna com o dado e termina a recursividade EndIf If StringInStr(StringStripWS($as[$i],3),'#include ')=1 then $as1 = StringRegExp($as[$i],"(?i)\#include (<(.*)>|""(.*?)""|''(.*?)'')",3) ; pega o nome do modulo <xxx>, "xxx" ou 'xxx' If UBound($as1)>1 Then ; Ok $s1 = $as1[UBound($as1)-1] ; takes the last item that is the file name If $Trace >=2 And StringInStr($includeOnce,$s1)=0 Then ConsoleWrite(">" & $t & $FileName & ":" & $i & " " & $as[$i] & @CRLF) ; Debug level >=2 $s1 = ProcessFile($s1,$Trace) ; Here comes recursion If $s1 <> "" Then ExitLoop ; Get out of the recursion cascading exiting all levels EndIf EndIf Next Until 1 $RecursionLevel -=1 If $s1 = "" Then If $RecursionLevel = 0 Then If $Trace Then ConsoleWrite("-" & $t & "Programa End( " & $FileName & " ) line " & $line & " Program File Lines: " & UBound($as)-1 & @CRLF) ; Debug level >=1 Else If $Trace Then ConsoleWrite("-" & $t & "Include End( " & $FileName & " ) line " & $line & " Include File Lines: " & UBound($as)-1 & @CRLF) ; Debug level >=1 EndIf EndIf Return $s1 ; Return "" if Includ end, or is $s1 <> "" is da result exiting all recursion levels EndFunc Tks. GetFileLineError.au3
- 16 replies
-
- Executable Error
- Executabele line error
-
(and 1 more)
Tagged with:
-
In _sql.au3 is no Function _SQL_ConnectionTimeout() And _SQL_CommandTimeout Below is the coding that can be added to _sql.au3 The Sintax is: _SQL_CommandTimeout(-1,60) ; For 60 seconds or $CommandTimeout = _SQL_CommandTimeout() ; Returns the actual timeout , normally 30 seconds or $CommandTimeout = _SQL_CommandTimeout(-1,60) Set timeout to 60 seconds e returns las timeout (normally 15 seconds) _SQL_ConnectionTimeout(-1,60) ; For 60 seconds ;#Reference Informations ======================================================== ; ; MSDN ADO http://msdn.microsoft.com/en-us/library/ms807027.aspx ; ;Method Description ;Open Opens a connection to a data store. ;Close Closes a connection and any dependent objects. ;Execute Executes the specified query, SQL statement, stored procedure, or provider-specific text. ;BeginTrans Begins a new transaction. ;CommitTrans Saves any changes and ends the current transaction. It may also start a new transaction. ;RollbackTrans Cancels any changes made during the current transaction and ends the transaction. It may also start a new transaction. ; ;The following table lists some of the more commonly used properties of the Connection object. ;Property Description ;ConnectionString Contains the information used to establish a connection to a data store. ;ConnectionTimeout Indicates how long to wait while establishing a connection before terminating the attempt and generating an error. (seconds) ;CommandTimeout Indicates how long to wait while executing a command before terminating the attempt and generating an error. (seconds) ;State Indicates whether a connection is currently open, closed, or connecting. (Open = 1 Closed = 0) ;Provider Indicates the name of the provider used by the connection. ;Version Indicates the ADO version number. ; ;================================================================================= ; #FUNCTION# =================================================================== ; Name ..........: _SQL_CommandTimeout() ; Description ...: Indicates how long to wait while executing a command before terminating the attempt and generating an error. ; Syntax.........: _SQL_CommandTimeout([ $hConHandle = -1[, $iTimeOut = -1 ]]) ; Parameters ....: $hConHandle - An Open Database, Use -1 To use Last Opened Database ; $TimeOut - TimeOut in seconds ; Return values .: On Success - TimeOut in seconds (if $iTimeOut >= 0 Then Set New TimeOut and Returns the Last TimeOut) ; On Failure - Returns $SQL_ERROR and $SQLErr is set. ; .Use _SQL_GetErrMsg() to get text error information ; Author ........: Elias Assad Neto ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; no ; ============================================================================== Func _SQL_CommandTimeout($ADODBHandle = -1,$iTimeOut = -1) $SQLErr = "" If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection If Not IsObj($ADODBHandle) Then $SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()" Return SetError($SQL_ERROR, 0, $SQL_ERROR) EndIf $lTimeOut = $ADODBHandle.CommandTimeout If @error Then $SQLErr = "Unable to retrive data" Return SetError($SQL_ERROR, 0, $SQL_ERROR) EndIf If $iTimeOut >= 0 Then $ADODBHandle.CommandTimeout = $iTimeOut EndIf If Not @error Then Return SetError($SQL_OK, 0, $lTimeOut) Else $SQLErr = "Unable to set data" Return SetError($SQL_ERROR, 0, $SQL_ERROR) EndIf EndFunc ;==>_SQL_CommandTimeout ; #FUNCTION# =================================================================== ; Name ..........: _SQL_ConnectionTimeout() ; Description ...: Indicates how long to wait while establishing a connection before terminating the attempt and generating an error. ; Syntax.........: _SQL_ConnectionTimeout([ $hConHandle = -1[, $iTimeOut = -1 ]]) ; Parameters ....: $hConHandle - An Open Database, Use -1 To use Last Opened Database ; $TimeOut - TimeOut in seconds ; Return values .: On Success - TimeOut in seconds (if $iTimeOut >= 0 Then Set New TimeOut and Returns the Last TimeOut) ; On Failure - Returns $SQL_ERROR and $SQLErr is set. ; .Use _SQL_GetErrMsg() to get text error information ; Author ........: Elias Assad Neto ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; no ; ============================================================================== Func _SQL_ConnectionTimeout($ADODBHandle = -1,$iTimeOut = -1) $SQLErr = "" If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection If Not IsObj($ADODBHandle) Then $SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()" Return SetError($SQL_ERROR, 0, $SQL_ERROR) EndIf $lTimeOut = $ADODBHandle.ConnectionTimeout If @error Then $SQLErr = "Unable to retrive data" Return SetError($SQL_ERROR, 0, $SQL_ERROR) EndIf If $iTimeOut >= 0 Then $ADODBHandle.ConnectionTimeout = $iTimeOut EndIf If Not @error Then Return SetError($SQL_OK, 0, $lTimeOut) Else $SQLErr = "Unable to set data" Return SetError($SQL_ERROR, 0, $SQL_ERROR) EndIf EndFunc ;==>_SQL_ConnectionTimeout
-
Thanks for the _sql.au3 here gos my contribution for the _sql.au3 Getting TABLE NAME From the Data BASE New Function _SQL_GetTableName() for SQL ; #FUNCTION# =================================================================== ; Name ..........: _SQL_GetTableName() ; Description ...: Get Table List Of Open Data Base ; Syntax.........: _SQL_GetTableName([ $hConHandle = -1[,$Type = "TABLE" ]]) ; Parameters ....: $hConHandle - An Open Database, Use -1 To use Last Opened Database ; $Type - Table Type "TABLE" (Default), "VIEW", "SYSTEM TABLE", "ACCESS TABLE" ; $Type = "*" - Return All Tables in a Array2D $aTable[n][2] $aTable[n][0] = Table Name $aTable[n][1] = Table Type ; ; Return values .: On Success - Returns a 1D Array Of Table Names / 2D Array is $Type = "*" ; On Failure - Returns $SQL_ERROR and $SQLErr is set. ; .Use _SQL_GetErrMsg() to get text error information ; Author ........: Elias Assad Neto ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; no ; ============================================================================== Func _SQL_GetTableName($hConHandle = -1, $Type = "TABLE") $SQLErr = "" If $hConHandle = -1 Then $hConHandle = $SQL_LastConnection Local $rs = $hConHandle.OpenSchema(20) ; adSchemaTables = 20 If Not IsObj($rs) Then Return SetError($SQL_ERROR, 0, $SQL_ERROR); The Data Base is Not Open Local $oField = $rs.Fields("TABLE_NAME") local $aTable If $Type = "*" Then ; All Table Do ;Check for a user table object If UBound($aTable) = 0 Then Dim $aTable[1][2] Else ReDim $aTable[UBound($aTable)+1][2] EndIf $aTable[UBound($aTable)-1][0] = $oField.Value $aTable[UBound($aTable)-1][1] = $rs.Fields("TABLE_TYPE" ).Value $rs.MoveNext Until $rs.EOF Else ; Selected Table Do ;Check for a user table object If $rs.Fields("TABLE_TYPE" ).Value = $Type Then If UBound($aTable) = 0 Then Dim $aTable[1] Else ReDim $aTable[UBound($aTable)+1] EndIf $aTable[UBound($aTable)-1] = $oField.Value EndIf $rs.MoveNext Until $rs.EOF EndIf If UBound($aTable) = 0 Then $SQLErr = "Table Not Found" Return SetError($SQL_ERROR, 0, $SQL_ERROR) ; Table Not Found EndIf Return $aTable EndFunc ;==>GetTableName SQL GUI using "_sql.au3" Requires : _sql.au3 Code can Be Download at the beginning of the topic AdispEX.au3 Code is in the next code pane ;=============================================================================== ; Program Name: SQL AutoIT ; Description: Graphical User Interfaze using _sql.au3 ; ; Requirement(s): AutoIt 3.3.x.x, AdispEX.au3 ; Return Value(s): None ; Author(s): Elias Assad Neto ; Version: 1.0 ; Date Crated: 2010/12/17 ; Modified: ;=============================================================================== #include <GuiEdit.au3> #include <GuiComboBox.au3> #include "_sql.au3" #include "AdispEX.au3" ; Adisp com recuros de receber o cabeçario por uma Matriz em $saTitle Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close ; Mouse cursor Constants ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ;Global Enum $crDefault, $crNone, $crArrow, $crCross, $crIBeam, $crSize, $crSizeNESW, $crSizeNS, $crSizeNWSE, $crSizeWE, $crUpArrow, $crHourGlass, $crDrag, $crNoDrop, $crHSplit, $crVSplit, $crMultiDrag, $crSQLWait, $crNo, $crAppStart, $crHelp, $crHandPoint, $crSizeAll Global $crAppStart = 1, $crArrow = 2, $crCross = 3, $crDrag = 2, $crHandPoit = 0, $crHelp = 4, $crHouerGlass = 15, $crHSplit = 2, $crIBeam = 5, $crMultiDrag = 2, $crNo = 7, $crNoDrop = 7, $crSizeAll = 9, $crSizeNESW = 10, $crSizeNS = 11, $crSizeNWSE = 12, $crSizeWE = 13, $crSQLWait = 2, $crUpArrow = 14, $crVSplit = 2 Global Const $crCustom = 99 ;Custom icon specified by the MouseIcon property Global $Delim = "¬&~" Global $Title = "SQL UDF GUI" Global $Connction, $Server, $Db, $Username, $Password, $sFileINI ; INI Variabels Global $lastProfile = "", $ActualProfile = "" Global $oQuery, $aResults ; Query variables Global $OpenFilter Global $dgb_t, $dgb_s #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $_h = 70 ; Para aumentar e diminuir tamanho das janelas entre $eSQL e $eResult #region ### START Koda GUI section ### Form=C:\Drive_D\Elias\My Documents\Elias\Projects\AutoIT3_3.3.0.0\HSUD_IncVazios\SQL_Form.kxf $SQL_Form = GUICreate($Title, 670, 582, 192, 124, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS)) $MenuView = GUICtrlCreateMenu("&View") $mTablesALL = GUICtrlCreateMenuItem("&ALL Tables", $MenuView) $mTable = GUICtrlCreateMenuItem("&Tables", $MenuView) $mTableViews = GUICtrlCreateMenuItem("&Views Tables", $MenuView) $mTableSystem = GUICtrlCreateMenuItem("&System Tables", $MenuView) $mTabelsOthers = GUICtrlCreateMenuItem("&Other Tables", $MenuView) $MenuHelp = GUICtrlCreateMenu("&Help") $mSQLTutorial = GUICtrlCreateMenuItem("S&QL Tutorial F1", $MenuHelp) $mAbout = GUICtrlCreateMenuItem("&About", $MenuHelp) $lConection = GUICtrlCreateLabel("Connection", 8, 9, 58, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $cSQL = GUICtrlCreateCombo("", 65, 6, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "SQL Connection|SQL JetConnect (file)|SQL AccessConnect (file)", "SQL Connection") GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $lServer = GUICtrlCreateLabel("Server", 8, 32, 35, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, "Server / IP") $iServer = GUICtrlCreateInput("", 65, 30, 594, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKHEIGHT) $bFile = GUICtrlCreateButton("&File", 7, 28, 51, 25, $WS_GROUP) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetState(-1, $GUI_HIDE) $lDB = GUICtrlCreateLabel("Db", 8, 56, 18, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, "Data Base Optional") $iDb = GUICtrlCreateInput("", 65, 54, 594, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKHEIGHT) $lUserName = GUICtrlCreateLabel("UserName", 8, 80, 54, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $iUserName = GUICtrlCreateInput("", 65, 78, 218, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $lPassword = GUICtrlCreateLabel("Password", 8, 104, 50, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $iPassword = GUICtrlCreateInput("", 65, 102, 218, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $lProfile = GUICtrlCreateLabel("Profile", 240, 10, 33, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $cProfile = GUICtrlCreateCombo("", 280, 7, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $CBS_SORT)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $bSaveDeleteProfile = GUICtrlCreateButton("&Save Profile", 437, 4, 75, 25, $WS_GROUP) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $bOpenCloseSQL = GUICtrlCreateButton("&Open SQL", 295, 100, 67, 25, $WS_GROUP) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $lDouble = GUICtrlCreateLabel("DoubleClick Execute SQL at cursor", 496, 112, 171, 17) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $bSQLExecute = GUICtrlCreateButton("SQL&Execute", 592, 132, 75, 25, $WS_GROUP) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, "Executa a linha do cursor ou a parte selecionada Atalho:Ctrl+Enter") $bTables = GUICtrlCreateButton("&Tables", 592, 160, 75, 25, $WS_GROUP) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, "Mostra as Tabelas da Base de Dados") $bView = GUICtrlCreateButton("&Views", 592, 188, 75, 25, $WS_GROUP) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetTip(-1, "Mostra as Views da Base de Dados") $eSQL = GUICtrlCreateEdit("", 0, 132, 589, 89 + $_h, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_NOHIDESEL, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKHEIGHT) $eResult = GUICtrlCreateEdit("", 0, 224 + $_h, 669, 337 - $_h) GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### Dim $SQL_Form_AccelTable[2][2] = [["{F1}", $mSQLTutorial],["^{ENTER}", $bSQLExecute]] GUISetAccelerators($SQL_Form_AccelTable) $Font = "Consolas" $FSize = 10 GUICtrlSetFont($eSQL, $FSize, 400, 0, $Font) GUICtrlSetFont($eResult, $FSize, 400, 0, $Font) ;GUICtrlSetColor(-1, 0x0000FF) ;If Not @Compiled Then GUISetIcon("SQL48x48.ico") OnAutoItExitRegister("Saida") _SQL_RegisterErrorHandler() _SQL_Startup() $GuiSize = WinGetPos($SQL_Form) GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO") ;GUIRegisterMsg($WM_GETMINMAXINFO, "") ;Unregister ATENÇÃO Chamar essa Função ao Fechar a Janela $SQLDebugTime = 0 $SQLTraceFlg = 0 $SQLTraceDisp = 0 $LDclickt = 0 $SQLTrace = "" LeIni() While 1 $aMsg = GUIGetMsg(1) If $SQLTraceDisp And $SQLTrace <> "" Then _GUICtrlEdit_AppendText($eResult, $SQLTrace) $SQLTrace = "" EndIf $nMsg = $aMsg[0] If 0 And $nMsg <> 0 And $nMsg <> -11 Then ConsoleWrite("Control ID: " & $aMsg[0] & @CRLF) ;ConsoleWrite("W hWand : " & $aMsg[1] & @CRLF) ;ConsoleWrite("C hWand : " & $aMsg[2] & @CRLF) ;ConsoleWrite("X : " & $aMsg[3] & @CRLF) ;ConsoleWrite("Y : " & $aMsg[4] & @CRLF) EndIf Switch $nMsg Case 0 ; Nada Case -11 ; Mouse Move Case -8 ; Botão Esquerdo levantou If TimerDiff($LDclickt) < 500 Then ; Duble Click Esquerdo no Form $aMouse = GUIGetCursorInfo() ; 0-X 1-Y 2-Primary down (1 if pressed, 0 if not pressed) 4-ID of the control that the mouse cursor is hovering over (or 0 if none) If $aMouse[4] = $eSQL Then SQLExecute() ; Se DuploClick Sobre o Controle EndIf $LDclickt = TimerInit() Case $GUI_EVENT_CLOSE Exit Case $mTablesALL GUICtrlSetData($eResult, "") ; Limpa $eResult GetTableNames("") ; Mostra só as Todas as Tabelas Case $mTable GUICtrlSetData($eResult, "") ; Limpa $eResults GetTableNames("TABLE") ; Mostra só as Tabelas com Type = "TABLE" Case $mTableViews GUICtrlSetData($eResult, "") ; Limpa $eResults GetTableNames("VIEW") ; Mostra só as Tabelas com Type = "VIEW" Case $mTableSystem GUICtrlSetData($eResult, "") ; Limpa $eResults GetTableNames("SYSTEM TABLE") ; Mostra só as Tabelas com Type = "SYSTEM TABLE" Case $mTabelsOthers GUICtrlSetData($eResult, "") ; Limpa $eResults GetTableNames("TABLE;VIEW;SYSTEM TABLE", 1) ; Mostra só as Tabelas com Type <> "TABLE;VIEW;SYSTEM TABLE" Case $mSQLTutorial ShellExecute("http://www.w3schools.com/sql/default.asp") ; em protugues Case $cSQL GUIShowHideOpen() ; Atualiza dados e GUI para cada Tipo de conexão CkProfile() Case $mAbout About() Case $bFile $Server = FileOpenDialog($Title & " Escolha uma Base de Dados", "", $OpenFilter, 1 + 2) GUICtrlSetData($iServer, $Server) CkProfile() Case $iServer CkProfile() Case $bFile CkProfile() Case $iDb CkProfile() Case $iUserName CkProfile() Case $iPassword CkProfile() Case $cProfile SaveReadProfile() ; Le o Profile Case $bSaveDeleteProfile SaveDeleteProfile() Case $bOpenCloseSQL OpenCloseSQL() Case $bSQLExecute ;$st = GUICtrlGetState ($bSQLExecute) ;ConsoleWrite("$bSQLExecute: " & $bSQLExecute & " $eSQL: " & $eSQL & " State: " & Hex($st) & @CRLF) SQLExecute(1) Case $bTables GUICtrlSetData($eResult, "") ; Limpa $eResults GetTableNames("TABLE") ; Mostra só as Tabelas com Type = "TABLE" Case $bView GUICtrlSetData($eResult, "") ; Limpa $eResults GetTableNames("VIEW") ; Mostra só as Tabelas com Type = "VIEW" Case Else ; EndSwitch WEnd Func Saida() ; Cahmada quando se exeuta um Exit ou o programa é terminado por algum motivo, iniciada por OnAutoItExitRegister("Saida") GUIRegisterMsg($WM_GETMINMAXINFO, "") ; Unregister ATENÇÃO Chamar essa Função ao Fechar a Janela $oQuery = 0 $aResults = 0 _SQL_Close() EndFunc ;==>Saida Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) ; Limita o tamanho minimo e maximo da janela $GuiSize = WinGetPos(GUI) tamanho inicial Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $GuiSize[2] - 132) ; min X DllStructSetData($minmaxinfo, 8, $GuiSize[3] - 200) ; min Y If 0 Then ; se quiser limitar tamanho maximo da janela DllStructSetData($minmaxinfo, 9, $GuiSize[2] + 300) ; max X DllStructSetData($minmaxinfo, 10, $GuiSize[3] + 300) ; max Y EndIf Return 0 EndFunc ;==>MY_WM_GETMINMAXINFO Func GUIShowHideOpen($Open = False) $Connction = GUICtrlRead($cSQL) If $Open Then $Server = GUICtrlRead($iServer) If $Server <> "" Then GUICtrlSetData($eResult, StringFormat("Opening SQL : %s\r\n", $Server)) Else Return $SQL_ERROR EndIf EndIf $lProf = GUICtrlRead($cSQL) Select Case $Connction = "SQL Connection" If $Open Then $Db = GUICtrlRead($iDb) $Username = GUICtrlRead($iUserName) $Password = GUICtrlRead($iPassword) Return _SQL_Connect(-1, $Server, $Db, $Username, $Password) EndIf GUICtrlSetState($bFile, $GUI_HIDE) GUICtrlSetState($lServer, $GUI_SHOW) GUICtrlSetState($iDb, $GUI_ENABLE) GUICtrlSetState($iUserName, $GUI_ENABLE) GUICtrlSetState($iPassword, $GUI_ENABLE) Case $Connction = "SQL JetConnect (file)" Or $Connction = "SQL AccessConnect (file)" If $Connction = "SQL JetConnect (file)" Then If $Open Then Return _SQL_JetConnect(-1, $Server) $OpenFilter = "JetConnect (*.*)" Else If $Open Then Return _SQL_AccessConnect(-1, $Server) $OpenFilter = "Access (*.mdb)" EndIf GUICtrlSetState($lServer, $GUI_HIDE) GUICtrlSetState($bFile, $GUI_SHOW) GUICtrlSetState($iDb, $GUI_DISABLE) GUICtrlSetData($iDb, "") GUICtrlSetState($iUserName, $GUI_DISABLE) GUICtrlSetData($iUserName, "") GUICtrlSetState($iPassword, $GUI_DISABLE) GUICtrlSetData($iPassword, "") EndSelect GUICtrlSetData($eResult, "") SaveReadQuery() EndFunc ;==>GUIShowHideOpen Func GetSQLLine($fsel = 0) ; Seleciona a linha de $eSQL onde esta o cursor e retorna a mesma $eSQLSel = _GUICtrlEdit_GetSel($eSQL) ; Pega Seleção em Arrar[2] $S = GUICtrlRead($eSQL) If _GUICtrlEdit_CanUndo($eSQL) Then SaveReadQuery(True) ; Atualiza Query If $fsel And $eSQLSel[0] < $eSQLSel[1] Then ; Se $fsel e algo selecionado, retorna a seleção $S = StringMid($S, $eSQLSel[0] + 1, $eSQLSel[1] - $eSQLSel[0]) Return $S EndIf $aS = StringSplit($S, "", 2) ; monta a Matriz de $eSQL em $aS If $eSQLSel[0] >= UBound($aS) Then $eSQLSel[0] = UBound($aS) - 1 EndIf If $eSQLSel[0] < 0 Then Return "" ; Nada Selecionado If $eSQLSel[0] < UBound($aS) Then $i = $eSQLSel[0] If $i > 0 Then For $i = $eSQLSel[0] - 1 To 1 Step -1 ; Acha o Inicio Da linha If $aS[$i] = @LF Or $aS[$i] = @CR Then $i += 1 ExitLoop EndIf Next EndIf For $j = $eSQLSel[0] To UBound($aS) - 1 ; Acha o Fim da Linha If $aS[$j] = @LF Or $aS[$j] = @CR Then ExitLoop EndIf Next Else $i = 0 $j = 0 EndIf _GUICtrlEdit_SetSel($eSQL, $i, $j) $S = StringMid($S, $i + 1, $j - $i + 1) ;$S = StringStripWS($S,3) Return $S EndFunc ;==>GetSQLLine Func OpenCloseSQL() If GUICtrlRead($bOpenCloseSQL) = "&Open SQL" Then GUICtrlSetData($eResult, "") ; Limpa janela de resultados If GUIShowHideOpen(True) = $SQL_OK Then GUICtrlSetData($bOpenCloseSQL, "&Close SQL") _GUICtrlEdit_AppendText($eResult, "OK Base Aberta" & @CRLF) For $i = $lConection To $bOpenCloseSQL - 1 $R = GUICtrlSetState($i, $GUI_DISABLE) Next GetTableNames("TABLE") Else _GUICtrlEdit_AppendText($eResult, "ERRO ao tentar Abrir a Base de Dados" & @CRLF) EndIf Else $oQuery = 0 $aResults = 0 If _SQL_Close() = $SQL_OK Then ; fecha Conexão ADO GUICtrlSetData($bOpenCloseSQL, "&Open SQL") For $i = $lConection To $bOpenCloseSQL - 1 $R = GUICtrlSetState($i, $GUI_ENABLE) Next GUIShowHideOpen() _SQL_Startup() ; Inicia novo Objeto ADO EndIf EndIf EndFunc ;==>OpenCloseSQL Func GetTableNames($Type = "", $neq = 0) ; Pega todas as tabelas da base de dados e lista em $eResult $rs = $SQL_LastConnection.OpenSchema(20) ; adSchemaTables = 20 If not IsObj($rs) Then If IsObj($MSSQLObjErr) Then $SQLErrDesc = $MSSQLObjErr.description _GUICtrlEdit_AppendText($eResult, @CRLF & "ERRO: ao Ler Tabelas " & $SQLErrDesc & @CRLF) Return ; Evita que oprograma termine caso a base não esteja aberta. EndIf $oField = $rs.Fields("TABLE_NAME") $S = "" Dim $aTables[10000][2] $aTables[0][0] = "Table List" $aTables[0][1] = "TYPE" $i = 1 $MinSizeTb = 0 $MinSizeTy = 0 $All = $Type == "" $Type = ";" & $Type & ";" Do ;Check for a user table object If $All Or BitXOR(StringInStr($Type, ";" & $rs.Fields("TABLE_TYPE" ).Value & ";") > 0, $neq) Then $aTables[$i][0] = $oField.Value $aTables[$i][1] = $rs.Fields("TABLE_TYPE" ).Value If StringLen($aTables[$i][0]) > $MinSizeTb Then $MinSizeTb = StringLen($aTables[$i][0]) If StringLen($aTables[$i][1]) > $MinSizeTy Then $MinSizeTy = StringLen($aTables[$i][1]) $i += 1 EndIf $rs.MoveNext Until $rs.EOF Or $i >= 10000 $fM = GUICtrlRead($eSQL) == "" Local $T = "" Local $Q = "" If $fM Then $T = "Tables: " For $j = 0 To $i - 1 If $fM And $j > 0 Then $T &= $aTables[$j][0] & ", " $Q &= "SELECT Count(*) FROM " & $aTables[$j][0] & @CRLF & "SELECT * FROM " & $aTables[$j][0] & @CRLF & @CRLF EndIf $S &= StringFormat("%-" & $MinSizeTy & "s %-" & $MinSizeTb & "s\r\n", $aTables[$j][1], $aTables[$j][0]) Next _GUICtrlEdit_AppendText($eResult, $S & @CRLF) If $fM Then $S = StringMid($T, 1, StringLen($T) - 2) & @CRLF & @CRLF & $Q _GUICtrlEdit_AppendText($eSQL, $S) EndIf EndFunc ;==>GetTableNames Func SQLExecute($fsel = 0) $sSQL = GetSQLLine($fsel) ;GUICtrlSetData($eResult,$sSQL) ;Return $oQuery = 0 $aResults = 0 GUICtrlSetData($eResult, "") ; Limpa janela de resultados If IsObj($SQL_LastConnection) Then GUISetCursor(15, 1) ; HourGlas _GUICtrlEdit_AppendText($eResult, "Execute: [" & $sSQL & "]" & @CRLF) ti("SQL_Execute (Delay):") $oQuery = _SQL_Execute(-1, $sSQL) $err = @error td() If $err Then Local $SQLErrDesc = "" If IsObj($MSSQLObjErr) Then $SQLErrDesc = $MSSQLObjErr.description _GUICtrlEdit_AppendText($eResult, @CRLF & "ERRO: ao Executar: " & $SQLErrDesc & @CRLF) Else Local $aNames ti("SQL_FetchNames (Delay):") If _SQL_FetchNames($oQuery, $aNames) = $SQL_OK Then td() Local $S = "Colunas: " ;& $aNames[0] For $i = 0 To UBound($aNames) - 1 $S &= "|" & $aNames[$i] Next $S &= "|" _GUICtrlEdit_AppendText($eResult, @CRLF & $S & @CRLF & @CRLF) ti("Monta Matriz 2D (Delay):") $aResults = $oQuery.GetRows() td() If UBound($aResults) = 1 And UBound($aResults, 2) = 1 Then _GUICtrlEdit_AppendText($eResult, StringFormat("\r\nResult: [%s]\r\n\r\n", $aResults[0][0])) Else _GUICtrlEdit_AppendText($eResult, StringFormat("Matriz2D[%d][%d]\r\n", UBound($aResults), UBound($aResults, 2))) Local $aTitulo[2] $aTitulo[0] = "Resultado de: " & $sSQL $aTitulo[1] = $aNames ; Cabeçalho GUISetCursor() ; Normal GUISetState(@SW_DISABLE) Opt("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close _ADisplay($aResults, $aTitulo) Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close GUISetState(@SW_ENABLE) WinActivate($SQL_Form) EndIf Else _GUICtrlEdit_AppendText($eResult, "ERRO: ao executar: _SQL_FetchNames($oQuery, $aNames)" & @CRLF) EndIf EndIf Else _GUICtrlEdit_AppendText($eResult, "ERRO: Base SQL não inicializado" & @CRLF) EndIf GUISetCursor() ; Normal EndFunc ;==>SQLExecute #region INI ;Estrutura do INI #cs [Init] lastProfile=xxxxxx [Profiles] ProfileName=Server\tDb\tUser\tPassword [Querys] ProfileName=Query\tQuery\t.....\tQuery #ce Func CkProfile($flg = False) ; Analisa se Profile alterado $ActualProfile = GUICtrlRead($cSQL) & $Delim & GUICtrlRead($iServer) & $Delim & GUICtrlRead($iDb) & $Delim & GUICtrlRead($iUserName) & $Delim & GUICtrlRead($iPassword) If $flg Then $lastProfile = $ActualProfile GUICtrlSetData($bSaveDeleteProfile, "&Delete Profile") Else If $ActualProfile = $lastProfile Then GUICtrlSetData($bSaveDeleteProfile, "&Delete Profile") Return True Else If GUICtrlRead($bSaveDeleteProfile) = "&Delete Profile" Then _GUICtrlComboBox_SetCurSel($cProfile) GUICtrlSetData($bSaveDeleteProfile, "&Save Profile") Return False EndIf EndIf EndFunc ;==>CkProfile Func SaveDeleteProfile() If GUICtrlRead($bSaveDeleteProfile) <> "&Save Profile" Then $Profile = GUICtrlRead($cProfile) If $Profile <> "" Then ; Delete Profile $FileINI = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 4) & ".ini" IniDelete($FileINI, "Profiles", $Profile) IniDelete($FileINI, "Querys", $Profile) GUICtrlSetData($eSQL, "") GUICtrlSetData($eResult, "") SaveReadProfile(-1) ; Limpa os dados da tela LeIni() EndIf Else SaveReadProfile(True) ; Salva Profile EndIf EndFunc ;==>SaveDeleteProfile Func SaveReadProfile($fSave = 0) CkProfile() ; Atualiza $lastProfile $FileINI = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 4) & ".ini" If $fSave = 1 Then $Server = GUICtrlRead($iServer) $aServer = PathSplit($Server) ; Split FilePtah 0-ScriptFullPath 1-Drive 2-Path 3-Name 4-.ext $sProfileName = InputBox($Title, "Entre com o Nome do Perfil Max 20 Char", StringMid($aServer[3] & $aServer[4], 1, 20), " 20") If @error = 0 And $sProfileName <> "" And $ActualProfile <> $lastProfile And $ActualProfile <> "" Then IniWrite($FileINI, "Init", "LastProfile", $sProfileName) $lastProfile = $ActualProfile IniWrite($FileINI, "Profiles", $sProfileName, $ActualProfile) _GUICtrlComboBox_ResetContent($cProfile) LeIni() Else MsgBox(0, $Title, "Profile não foi salvo") EndIf Return EndIf $selProfile = GUICtrlRead($cProfile) If $fSave = -1 Then $selProfile = "=Limpa" If $selProfile <> "" Then If $selProfile = "=Limpa" Then GUICtrlSetData($cProfile, "") $sProfile = GUICtrlRead($cSQL) & $Delim & $Delim & $Delim & $Delim GUICtrlSetData($bSaveDeleteProfile, "&Save Profile") $ActualProfile = "" $lastProfile = "" _GUICtrlComboBox_ResetContent($cProfile) GUICtrlSetData($eSQL, "") GUICtrlSetData($eResult, "") Else $sProfile = IniRead($FileINI, "Profiles", $selProfile, "") EndIf If $sProfile <> "" Then $aProfiles = StringSplit($sProfile, $Delim, 3) If UBound($aProfiles) = 5 Then If $selProfile = "=Limpa" Then IniWrite($FileINI, "Init", "LastProfile", "") Else IniWrite($FileINI, "Init", "LastProfile", $selProfile) EndIf ;ReDim $aProfiles[5] ; Pois o IniRead eliminas brancos a direita inclusive TAB's GUICtrlSetData($cSQL, $aProfiles[0]) GUICtrlSetData($iServer, $aProfiles[1]) GUICtrlSetData($iDb, $aProfiles[2]) GUICtrlSetData($iUserName, $aProfiles[3]) GUICtrlSetData($iPassword, $aProfiles[4]) If $selProfile <> "=Limpa" Then CkProfile(True) GUIShowHideOpen() EndIf EndIf EndIf EndFunc ;==>SaveReadProfile Func SaveReadQuery($fSave = False) ; Grava ou Le As Querys $FileINI = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 4) & ".ini" $p = GUICtrlRead($cProfile) If $fSave Then If $p <> "" Then IniWrite($FileINI, "Querys", $p, StringReplace(GUICtrlRead($eSQL), @CRLF, $Delim)) ; Atualiza Else If $p <> "" Then GUICtrlSetData($eSQL, StringReplace(IniRead($FileINI, "Querys", $p, ""), $Delim, @CRLF)) ; Remonta para EditControl EndIf EndFunc ;==>SaveReadQuery Func LeIni($flag = 0) ; Le todas as Inicializações GUICtrlSetData($eSQL, "") GUICtrlSetData($eResult, "") $FileINI = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 4) & ".ini" Local $Profiles = "" $aProfiles = IniReadSection($FileINI, "Profiles") If @error = 0 And $aProfiles[0][0] > 0 Then $Profiles = $aProfiles[1][0] ; Key For $i = 2 To $aProfiles[0][0] $Profiles &= "|" & $aProfiles[$i][0] ; Key Next EndIf $lProfile = IniRead($FileINI, "Init", "lastProfile", "") GUICtrlSetData($cProfile, $Profiles, $lProfile) SaveReadProfile() ; Le o Profile selecionado If GUICtrlRead($cProfile) = "" Then EndIf SaveReadQuery() ; Le a Query do profile Selecionado CkProfile() EndFunc ;==>LeIni Func WrtIni() ; Grava todas as Inicializações $FileINI = StringMid(@ScriptFullPath, 1, StringLen(@ScriptFullPath) - 4) & ".ini" EndFunc ;==>WrtIni Func PathSplit($szPath) ; Split FilePtah 0-ScriptFullPath 1-Drive 2-Path 3-Name 4-.ext ; Set local strings to null (We use local strings in case one of the arguments is the same variable) Local $drive = "" Local $Dir = "" Local $fname = "" Local $ext = "" Local $pos ; Create an array which will be filled and returned later Local $array[5] $array[0] = $szPath; $szPath can get destroyed, so it needs set now ; Get drive letter if present (Can be a UNC server) If StringMid($szPath, 2, 1) = ":" Then $drive = StringLeft($szPath, 2) $szPath = StringTrimLeft($szPath, 2) ElseIf StringLeft($szPath, 2) = "\\" Then $szPath = StringTrimLeft($szPath, 2) ; Trim the \\ $pos = StringInStr($szPath, "\") If $pos = 0 Then $pos = StringInStr($szPath, "/") If $pos = 0 Then $drive = "\\" & $szPath; Prepend the \\ we stripped earlier $szPath = ""; Set to null because the whole path was just the UNC server name Else $drive = "\\" & StringLeft($szPath, $pos - 1) ; Prepend the \\ we stripped earlier $szPath = StringTrimLeft($szPath, $pos - 1) EndIf EndIf ; Set the directory and file name if present Local $nPosForward = StringInStr($szPath, "/", 0, -1) Local $nPosBackward = StringInStr($szPath, "\", 0, -1) If $nPosForward >= $nPosBackward Then $pos = $nPosForward Else $pos = $nPosBackward EndIf $Dir = StringLeft($szPath, $pos) $fname = StringRight($szPath, StringLen($szPath) - $pos) ; If $szDir wasn't set, then the whole path must just be a file, so set the filename If StringLen($Dir) = 0 Then $fname = $szPath $pos = StringInStr($fname, ".", 0, -1) If $pos Then $ext = StringRight($fname, StringLen($fname) - ($pos - 1)) $fname = StringLeft($fname, $pos - 1) EndIf ; Set the strings and array to what we found $array[1] = $drive $array[2] = $Dir $array[3] = $fname $array[4] = $ext Return $array EndFunc ;==>PathSplit #endregion INI Func ti($S = "TimerInit Scriptline: ", $ScriptLineNumber = @ScriptLineNumber) ; Inicializa Timer If StringInStr($S, "TimerInit Scriptline:") = 1 Then $dgb_s = $S & $ScriptLineNumber Else $dgb_s = $S EndIf $dgb_t = TimerInit() EndFunc ;==>ti Func td($S = "TimerDiff Scriptline: ", $ScriptLineNumber = @ScriptLineNumber) ; Mostra Timer Local $tt = TimerDiff($dgb_t) If StringInStr($dgb_s, "TimerInit Scriptline:") = 1 And StringInStr($S, "TimerDiff Scriptline:") = 1 Then $S = $dgb_s & " to " & $S & $ScriptLineNumber ElseIf StringInStr($S, "TimerDiff Scriptline:") = 1 Then $S = $dgb_s EndIf If $tt < 1 Then $tt = Round($tt * 1000) & " µs" ElseIf $tt > 1000 Then ; segundos $tt = Round($tt / 1000, 2) & " seg" ElseIf $tt > 60000 Then ;minutos $seg = $tt / 1000 ; Segundos $min1 = $seg / 60 $min = Int($min1) $seg = Int(($min1 * 100) - (Int($min1) * 100)) * 60 / 100 $tt = StringFormat("%d:%05.2f min:seg", $min, $seg) Else ; ms $tt = Round($tt, 3) & " ms" EndIf _GUICtrlEdit_AppendText($eResult, $S & " " & $tt & @CRLF) EndFunc ;==>td Func About() #region ### START Koda GUI section ### Form=C:\Drive_D\Elias\My Documents\Elias\Projects\AutoIT3_3.3.0.0\SQL_UDF\About_Form.kxf $About_Form = GUICreate("About_Form", 326, 238, 302, 218) $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185, -1, $WS_EX_TRANSPARENT) $Label1 = GUICtrlCreateLabel("SQL AutoIt", 152, 24, 56, 17) $Label2 = GUICtrlCreateLabel("Version 1.0", 152, 48, 57, 17) $Label3 = GUICtrlCreateLabel("Copyright: Elias Assad Neto Informática ME", 16, 136, 217, 17) $Label4 = GUICtrlCreateLabel("e_mail: eliasan@ig.com.br", 16, 160, 127, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $bOk = GUICtrlCreateButton("&OK", 112, 208, 75, 25, $WS_GROUP) ;FileInstall("SQL256x256_btColor.gif", @ScriptDir & "\SQL256x256_btColor.tmp", 1) ;$Pic1 = GUICtrlCreatePic(@ScriptDir & "\SQL256x256_btColor.tmp", 24, 24, 100, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) ;FileDelete(@ScriptDir & "\SQL256x256_btColor.tmp") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $bOk GUIDelete($About_Form) Return EndSwitch WEnd EndFunc ;==>About AdispEX.au3 #include-once ; Todas as "_ARRAYCONSTANT_" substituidas por "_ADisp_" ;Variaves do indicador de prograsso chamado atraves dProgresso() Global $_ADisp_hGUI ;(Elias) Global $_ADisp_prog = 0 ;(Elias) Contador de progresso Global $_ADisp_MaxProg = 1 ;(Elias) Maximo progresso Global $_ADisp_hProg = "" ;(Elias) Global $_ADisp_Exit = False ;(Elias) Global $_ADisp_ck = False ;(Elias) Global $Debug ; (Elias) se não for definata em outros modulos fica como false serve para mostra na console informação de debug If @Compiled Then $Debug = False ; (Elias) ; #FUNCTION# ==================================================================================================================== ; Name...........: _ADisplay dirivado da _ArrayDisplay para Substituir a antiga _ADisplay que rodava em AutoIT 3.2.8.1 ; Description ...: Displays given 1D or 2D array array in a listview. ; Syntax.........: _ArrayDisplay(Const ByRef $avArray[, $saTitle = "Array: ListView Display"[, $iItemLimit = -1[, $iTranspose = 0[, $sSeparator = ""[, $sReplace = "|"]]]]]) ; Parameters ....: $avArray - Array to display ; $sTitle - [optional] Title to use for window Ou Array[2] onde Title = $saTitle[0] $aCab = $saTitle[1] (EX) ; $iItemLimit - [optional] Maximum number of listview items (rows) to show ; Adicionado <=-2, 2 ou 3 Indica Cabecario na primeira linha, (Elias) ; para maximo numero de itens é considerado ABS se valores maiores q 3 ou -3 (Elias) ; $iTranspose - [optional] If set differently than default, will transpose the array if 2D ; $sSeparator - [optional] Change Opt("GUIDataSeparatorChar") on-the-fly ; $sReplace - [optional] String to replace any occurrence of $sSeparator with in each array element ; Return values .: Success - 1 ; Failure - 0, sets @error: ; |1 - $avArray is not an array ; |2 - $avArray has too many dimensions (only up to 2D supported) ; Author ........: randallc, Ultima ; Modified.......: Gary Frost (gafrost) / Ultima: modified to be self-contained (no longer depends on "GUIListView.au3") ; Modified.......: Elias Assad / 15/03/2009 / Ultima: Modificado para ter scrollbars Cabeçario etc... ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _ADisplay(Const ByRef $avArray, $saTitle = "Array: ListView Display", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "", $sReplace = "|") If Not IsArray($avArray) Then Return SetError(1, 0, 0) $_ADisp_Exit = False ;(Elias) $_ADisp_ck = False ;(Elias) Local $cab = 0 ;(Elias) Se tem Cabeçario para manter compatibilidade com a antiga _ADiplay o Valor <=-2, 2 ou 3 em $iItemLimit informa q tem cabeçario Local $aCab = "" If UBound($saTitle) <> 0 Then ; Monta cabeçalho baseado em array passado por $saTaitle If UBound($saTitle) >= 2 Then $sTitle = $saTitle[0] Local $aCab = $saTitle[1] Else Local $sTitle = "Array: ListView Display" EndIf Else Local $sTitle = $saTitle EndIf ; Dimension checking Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1 If $iDimension > 2 Then Return SetError(2, 0, 0) ; Separator handling ;~ If $sSeparator = "" Then $sSeparator = Chr(1) If $sSeparator = "" Then $sSeparator = Chr(124) ; Declare variables " Local $i, $j, $vTmp, $aItem, $avArrayText, $CopySel = "Copy Selection", $sHeader = "Row", $iBuffer = 64, $WaitProc = "Wait Processing " Local $iColLimit = 250, $iWidth = 640, $iHeight = 480 ;Local $iLVIAddUDFThreshold = 4000 ; Removido na mais utilizado na versãp AutiIT 3.3.0.0 Local $iOnEventMode = Opt("GUIOnEventMode", 0), $sDataSeparatorChar = Opt("GUIDataSeparatorChar", $sSeparator) ; Swap dimensions if transposing If $iSubMax < 0 Then $iSubMax = 0 If $iTranspose Then $vTmp = $iUBound $iUBound = $iSubMax $iSubMax = $vTmp EndIf ; Set limits for dimensions If $iSubMax > $iColLimit Then $iSubMax = $iColLimit ; If $iItemLimit = 1 Then $iItemLimit = $iLVIAddUDFThreshold ; Removido na mais utilizado na versãp AutiIT 3.3.0.0 ; If $iItemLimit < 1 Then $iItemLimit = $iUBound ;If $iItemLimit >= 1 And $iItemLimit <= 3 Then $iItemLimit = $iLVIAddUDFThreshold ; Removido na mais utilizado na versãp AutiIT 3.3.0.0 If $iItemLimit = -2 Or $iItemLimit = 2 Or $iItemLimit = 3 Then $cab = 1 ;(Elias) If $iItemLimit <= -3 Then $iItemLimit = Abs($iItemLimit) ;(Elias) If $iItemLimit < 1 Then $iItemLimit = $iUBound If $iUBound > $iItemLimit Then $iUBound = $iItemLimit ;If $iLVIAddUDFThreshold > $iUBound Then $iLVIAddUDFThreshold = $iUBound ; Removido na mais utilizado na versãp AutiIT 3.3.0.0 ; Set header up For $i = 0 To $iSubMax If $cab Then ;(Elias) $sHeader &= $sSeparator & $avArray[0][$i] ;(Elias) Else If UBound($aCab) > 0 And $i < UBound($aCab) Then $sHeader &= $sSeparator & $aCab[$i] Else $sHeader &= $sSeparator & "Col " & $i EndIf EndIf ;(Elias) Next ; GUI Constants Local Const $_ADisp_GUI_DOCKBORDERS = 0x66 Local Const $_ADisp_GUI_DOCKBOTTOM = 0x40 Local Const $_ADisp_GUI_DOCKHEIGHT = 0x0200 Local Const $_ADisp_GUI_DOCKLEFT = 0x2 Local Const $_ADisp_GUI_DOCKRIGHT = 0x4 Local Const $_ADisp_GUI_EVENT_CLOSE = -3 Local Const $_ADisp_LVIF_PARAM = 0x4 Local Const $_ADisp_LVIF_TEXT = 0x1 Local Const $_ADisp_LVM_GETCOLUMNWIDTH = (0x1000 + 29) Local Const $_ADisp_LVM_GETITEMCOUNT = (0x1000 + 4) Local Const $_ADisp_LVM_GETITEMSTATE = (0x1000 + 44) Local Const $_ADisp_LVM_INSERTITEMA = (0x1000 + 7) Local Const $_ADisp_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54) Local Const $_ADisp_LVM_SETITEMA = (0x1000 + 6) Local Const $_ADisp_LVS_EX_FULLROWSELECT = 0x20 Local Const $_ADisp_LVS_EX_GRIDLINES = 0x1 Local Const $_ADisp_LVS_SHOWSELALWAYS = 0x8 Local Const $_ADisp_WS_EX_CLIENTEDGE = 0x0200 Local Const $_ADisp_WS_MAXIMIZEBOX = 0x00010000 Local Const $_ADisp_WS_MINIMIZEBOX = 0x00020000 Local Const $_ADisp_WS_SIZEBOX = 0x00040000 Local Const $_ADisp_tagLVITEM = "int Mask;int Item;int SubItem;int State;int StateMask;ptr Text;int TextMax;int Image;int Param;int Indent;int GroupID;int Columns;ptr pColumns" ;(Elias) Constantes acrecentadas Local Const $_ADisp_GUI_DOCKWIDTH = 0x00000100 ;(Elias) Local Const $_ADisp_WS_VSCROLL = 0x00200000 ;(Elias) Local Const $_ADisp_WS_HSCROLL = 0x00100000 ;(Elias) Local Const $_ADisp_WS_BORDER = 0x00800000 ;(Elias) Local Const $_ADisp_PBS_SMOOTH = 0x1 ;(Elias) Local Const $_ADisp_GUI_SHOW = 0x10 ;(Elias) Local Const $_ADisp_GUI_HIDE = 0x20 ;(Elias) ;(Elias) Events and messages Local Const $_ADisp_GUI_EVENT_MINIMIZE = -4 Local Const $_ADisp_GUI_EVENT_RESTORE = -5 Local Const $_ADisp_GUI_EVENT_MAXIMIZE = -6 Local Const $_ADisp_GUI_EVENT_PRIMARYDOWN = -7 Local Const $_ADisp_GUI_EVENT_PRIMARYUP = -8 Local Const $_ADisp_GUI_EVENT_SECONDARYDOWN = -9 Local Const $_ADisp_GUI_EVENT_SECONDARYUP = -10 Local Const $_ADisp_GUI_EVENT_MOUSEMOVE = -11 Local Const $_ADisp_GUI_EVENT_RESIZED = -12 Local Const $_ADisp_GUI_EVENT_DROPPED = -13 Local $iAddMask = BitOR($_ADisp_LVIF_TEXT, $_ADisp_LVIF_PARAM) Local $tBuffer = DllStructCreate("char Text[" & $iBuffer & "]"), $pBuffer = DllStructGetPtr($tBuffer) Local $tItem = DllStructCreate($_ADisp_tagLVITEM), $pItem = DllStructGetPtr($tItem) DllStructSetData($tItem, "Param", 0) DllStructSetData($tItem, "Text", $pBuffer) DllStructSetData($tItem, "TextMax", $iBuffer) ; Set interface up Local $_ADisp_hGUI = GUICreate($sTitle, $iWidth, $iHeight, Default, Default, BitOR($_ADisp_WS_SIZEBOX, $_ADisp_WS_MINIMIZEBOX, $_ADisp_WS_MAXIMIZEBOX)) Local $aiGUISize = WinGetClientSize($_ADisp_hGUI) ; Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 26, $_ADisp_LVS_SHOWSELALWAYS) Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 26, BitOR($_ADisp_WS_HSCROLL, $_ADisp_WS_VSCROLL, $_ADisp_WS_BORDER, $_ADisp_LVS_SHOWSELALWAYS)) ;(Elias) Scrooll Bars adicionadas ; Local $hCopy = GUICtrlCreateButton("Copy Selected", 3, $aiGUISize[1] - 23, $aiGUISize[0] - 6, 20) Local $hCopy = GUICtrlCreateButton($CopySel, 3, $aiGUISize[1] - 23, 100, 20) ;(Elias) Fixa tamanho do Botão GUICtrlSetResizing(-1, $_ADisp_GUI_DOCKLEFT+$_ADisp_GUI_DOCKWIDTH);(Elias) ;GUICtrlCreateButton ( "text" , left, top [, width [, height [, style [, exStyle]]]] ) GUICtrlSetResizing($hListView, $_ADisp_GUI_DOCKBORDERS) ; GUICtrlSetResizing($hCopy, $_ADisp_GUI_DOCKLEFT + $_ADisp_GUI_DOCKRIGHT + $_ADisp_GUI_DOCKBOTTOM + $_ADisp_GUI_DOCKHEIGHT) GUICtrlSendMsg($hListView, $_ADisp_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ADisp_LVS_EX_GRIDLINES, $_ADisp_LVS_EX_GRIDLINES) GUICtrlSendMsg($hListView, $_ADisp_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ADisp_LVS_EX_FULLROWSELECT, $_ADisp_LVS_EX_FULLROWSELECT) GUICtrlSendMsg($hListView, $_ADisp_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ADisp_WS_EX_CLIENTEDGE, $_ADisp_WS_EX_CLIENTEDGE) ;(Elias) Barra de progresso $_ADisp_hProg = GUICtrlCreateProgress(120, $aiGUISize[1] - 23 + 10/2, 100, 20 - 10, $_ADisp_PBS_SMOOTH) ;(Elias) GUICtrlSetResizing(-1, $_ADisp_GUI_DOCKLEFT+$_ADisp_GUI_DOCKWIDTH);(Elias) ;GUICtrlSetResizing($_ADisp_hProg, $_ADisp_GUI_DOCKLEFT + $_ADisp_GUI_DOCKBOTTOM) ;(Elias) ;GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) ;(Elias) Local $_ADisp_Itens, $_ADisp_Itens, $_ADisp_hAguarde If $iDimension = 2 Then $_ADisp_Itens = UBound($avArray, 1)*UBound($avArray, 2) $_ADisp_hAguarde = GUICtrlCreateLabel($WaitProc & UBound($avArray, 1)*UBound($avArray, 2) & " Itens....", 240, $aiGUISize[1] - 20, 200, 20) ;(Elias) Else $_ADisp_Itens = UBound($avArray, 1) $_ADisp_hAguarde = GUICtrlCreateLabel($WaitProc & $_ADisp_Itens & " Itens....", 240, $aiGUISize[1] - 20, 200, 20) ;(Elias) EndIf GUICtrlSetResizing(-1, $_ADisp_GUI_DOCKLEFT+$_ADisp_GUI_DOCKWIDTH);(Elias) ; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $_ADisp_Itens = ' & $_ADisp_Itens & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ; Show dialog (Elias) Mostra antes de iniciar preenchimento GUISetState(@SW_SHOW, $_ADisp_hGUI) ;(Elias) GUICtrlSetState($hListView, $_ADisp_GUI_HIDE) ;(Elias) $_ADisp_prog = 0 ;(Elias) $_ADisp_MaxProg = $iUBound ;(Elias) If $_ADisp_Itens > 8999 Then ;(Elias) Todo If _ADisp_SetTimer($_ADisp_hGUI,"_ADisp_ShowProgress",300) Else GUICtrlSetState($_ADisp_hProg,$_ADisp_GUI_HIDE) GUICtrlSetState($_ADisp_hAguarde,$_ADisp_GUI_HIDE) EndIf GUISetCursor(15,1) ; HourGlass ;(Elias) Local $td = TimerInit() ; Convert array into text for listview Local $avArrayText[$iUBound + 1] ; For $i = 0 To $iUBound For $i = $cab To $iUBound ;(Elias) Processa linhas ; $avArrayText[$i] = "[" & $i & "]" $avArrayText[$i] = "[" & $i & "]" ;(Elias) For $j = 0 To $iSubMax ; Processa colunas ; Get current item If $iDimension = 1 Then If $iTranspose Then $vTmp = $avArray[$j] Else $vTmp = $avArray[$i] EndIf Else If $iTranspose Then $vTmp = $avArray[$j][$i] Else $vTmp = $avArray[$i][$j] EndIf EndIf ; Add to text array $vTmp = StringReplace($vTmp, $sSeparator, $sReplace, 0, 1) ; $avArrayText[$i] &= $sSeparator & $vTmp $avArrayText[$i] &= $sSeparator & _ADisp_NormData($vTmp,1) ;(Elias) Se data AAAA/MM/DD --> DD/MM/AAAA ; Set max buffer size $vTmp = StringLen($vTmp) If $vTmp > $iBuffer Then $iBuffer = $vTmp Next $_ADisp_prog +=1 ;(elias) linhas processadas fase 1 If $_ADisp_ck Then If GUIGetMsg() = $_ADisp_GUI_EVENT_CLOSE Then ;{Elias) Sai no meio do loop $_ADisp_Exit = True $_ADisp_ck = False ExitLoop EndIf $_ADisp_ck = False EndIf Next $iBuffer += 1 If $Debug Then ConsoleWrite("Convert array into text for listview: " & TimerDiff($td) / 1000 & " seg" & " Prog =" & $_ADisp_prog & @CRLF) $td = TimerInit() ; Fill listview ; For $i = 0 To $iLVIAddUDFThreshold If Not $_ADisp_Exit Then For $i = $cab To $iUBound ;(Elias) GUICtrlCreateListViewItem($avArrayText[$i], $hListView) $_ADisp_prog +=1 ;(elias) linhas processadas fase 2 If $_ADisp_ck Then If GUIGetMsg() = $_ADisp_GUI_EVENT_CLOSE Then ;{Elias) Sai no meio do loop $_ADisp_Exit = True $_ADisp_ck = False ExitLoop EndIf $_ADisp_ck = False EndIf Next EndIf #cs ;(Elias) não precisa na versão 3.3.0.0 em diante For $i = ($iLVIAddUDFThreshold + 1) To $iUBound $aItem = StringSplit($avArrayText[$i], $sSeparator) DllStructSetData($tBuffer, "Text", $aItem[1]) ; Add listview item DllStructSetData($tItem, "Item", $i) DllStructSetData($tItem, "SubItem", 0) DllStructSetData($tItem, "Mask", $iAddMask) GUICtrlSendMsg($hListView, $_ADisp_LVM_INSERTITEMA, 0, $pItem) ; Set listview subitem text DllStructSetData($tItem, "Mask", $_ADisp_LVIF_TEXT) For $j = 2 To $aItem[0] DllStructSetData($tBuffer, "Text", $aItem[$j]) DllStructSetData($tItem, "SubItem", $j - 1) GUICtrlSendMsg($hListView, $_ADisp_LVM_SETITEMA, 0, $pItem) Next $_ADisp_prog +=1 ;(elias) linhas processadas fase 2a Next #ce If $Debug Then ConsoleWrite("Fill listview: " & TimerDiff($td) / 1000 & " seg" & " Prog =" & $_ADisp_prog & @CRLF) $td = TimerInit() ; ajust window width $iWidth = 0 Local $liWidth ;(Elias) Ultimo ajuste para reajustar para testar posteriormente se mudado o tamanho da celula For $i = 0 To $iSubMax + 1 $iWidth += GUICtrlSendMsg($hListView, $_ADisp_LVM_GETCOLUMNWIDTH, $i, 0) Next If $iWidth < 250 Then $iWidth = 230 WinMove($_ADisp_hGUI, "", Default, Default, $iWidth + 20 + 20) If $Debug Then ConsoleWrite("Ajust window width: " & TimerDiff($td) / 1000 & " seg" & @CRLF) GUICtrlDelete($_ADisp_hAguarde) GUICtrlSetState($hListView, $_ADisp_GUI_SHOW) ; Show dialog GUISetState(@SW_SHOW, $_ADisp_hGUI) _ADisp_KillTimer($_ADisp_hGUI) GUICtrlSetState($_ADisp_hProg , $_ADisp_GUI_HIDE) ;(Elias) Local $iwcount, $testWidth ;(Elias) GUISetCursor() ; Normal ;(Elias) While 1 If $testWidth Then ;(Elias) o If inteiro Reajusta janela se celula mudificada ; ajust window width $iWidth = 0 For $i = 0 To $iSubMax + 1 $iWidth += GUICtrlSendMsg($hListView, $_ADisp_LVM_GETCOLUMNWIDTH, $i, 0) Next If $iWidth < 250 Then $iWidth = 230 if $liWidth <> $iWidth Then If $Debug Then ConsoleWrite("$iwcount=" & $iwcount & @CRLF) WinMove($_ADisp_hGUI, "", Default, Default, $iWidth + 20 + 20) $liWidth = $iWidth $iwcount = 10000 EndIf $iwcount += 1 If $iwcount > 100 Then $testWidth = False EndIf Switch GUIGetMsg() Case 0 ;(Elias) ContinueLoop Case $_ADisp_GUI_EVENT_CLOSE ExitLoop Case $_ADisp_GUI_EVENT_PRIMARYUP ;(Elias) Pode ter havido um reajuste da tela verifica $testWidth = True $iwcount = 0 Case $hCopy Local $sClip = "" ; Get selected indices [ _GUICtrlListView_GetSelectedIndices($hListView, True) ] Local $aiCurItems[1] = [0] For $i = 0 To GUICtrlSendMsg($hListView, $_ADisp_LVM_GETITEMCOUNT, 0, 0) If GUICtrlSendMsg($hListView, $_ADisp_LVM_GETITEMSTATE, $i, 0x2) Then $aiCurItems[0] += 1 ReDim $aiCurItems[$aiCurItems[0] + 1] $aiCurItems[$aiCurItems[0]] = $i + $cab EndIf Next ; Generate clipboard text If Not $aiCurItems[0] Then For $sItem In $avArrayText $sClip &= $sItem & @CRLF Next Else For $i = 1 To UBound($aiCurItems) - 1 $sClip &= $avArrayText[$aiCurItems[$i]] & @CRLF Next EndIf ClipPut($sClip) EndSwitch WEnd _ADisp_KillTimer($_ADisp_hGUI) GUIDelete($_ADisp_hGUI) Opt("GUIOnEventMode", $iOnEventMode) Opt("GUIDataSeparatorChar", $sDataSeparatorChar) Return 1 EndFunc ;==>_ArrayDisplayCab Func _ADisp_ShowProgress() ;If $Debug Then ConsoleWrite($_ADisp_prog & @CRLF) $_ADisp_ck = True GUICtrlSetData($_ADisp_hProg, ($_ADisp_prog/$_ADisp_MaxProg)*100) EndFunc Func _ADisp_NormData($dd, $_f = 0) ; $_f = = rtorna $dd $_f = 1 Comverte data ANSI em DD/MM/AAAA $_f = 2 Converde DD/MM/AAAA em Data ANSI ; Normaliza a Data AAAA/MM/DD para DD/MM/AAAA Ou Vice Versa Se é Data ; tb ajusta o dia e mes para dois digitos AAAA/M/D para AAAA/0M/0D e D/M/AAAA para 0D/0M/AAAA Local $_i, $_a If ($_f =1 or $_f = 2) and (StringLen($dd) >= 8) and (StringLen($dd) <= 10) Then $_a = StringSplit($dd,"/") ; cria uma matriz com anos mes e dias separados If @error = 1 or $_a[0] <> 3 Then Return ($dd) ; não é data separada por "/" For $_i = 1 To 3 If StringLen($_a[$_i]) = 1 Then $_a[$_i] = "0" & $_a[$_i] ; ajusta dia e mes para 2 digitos Next If ($_f = 1 and StringLen($_a[3]) = 4) Or ($_f = 2 and StringLen($_a[1]) = 4) Then $dd = $_a[1] & "/" & $_a[2] & "/" & $_a[3] ; DD/MM/AAAA Else $dd = $_a[3] & "/" & $_a[2] & "/" & $_a[1] ; AAAA/MM/DD EndIf EndIf Return ($dd) EndFunc ;==>NormData Func _ADisp_SetTimer($hWnd, $sCallBack = "", $iElapse = 250, $iTimerID = -1) If Not IsHWnd($hWnd) Then SetError(-1, -1, 0) ; Não tem asociação com uma Janela Local Const $_WM_TIMER = 0x0113 If $iTimerID <= -1 Then $iTimerID = -1 $iTimerID += 1000 Local $retval = 1 ; Ok If $sCallBack <> "" Then $retval = GUIRegisterMsg($_WM_TIMER, $sCallBack) ; Seta a Chamada de retorno If $retval = 0 Then Return SetError(-2, -1, 0) ; Falhou ao Registar CallBack $retval = DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", $iTimerID, "int", $iElapse, "int", 0) If @error Then Return SetError(-3, -1, 0) ; Falhou ao Ativar/Alterar o Timer EndFunc Func _ADisp_KillTimer($hWnd, $iTimerID = -1) If $iTimerID <= -1 Then $iTimerID = -1 $iTimerID += 1000 Local $retval = DllCall("User32.dll", "int", "KillTimer", "hwnd", $hWnd, "int", $iTimerID) If @error Then Return SetError(-1, -1, 0) ; Falhou ao terminar o Timer EndFunc