Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/27/2018 in all areas

  1. WHAT : is .NET Common Language Runtime (CLR) Framework The Common Language Runtime (CLR) is a an Execution Environment . Common Language Runtime (CLR)'s main tasks are to convert the .NET Managed Code to native code, manage running code like a Virtual Machine, and also controls the interaction with the Operating System. As part of Microsoft's .NET Framework, the Common Language Runtime (CLR) is managing the execution of programs written in any of several supported languages. Allowing them to share common object-oriented classes written in any of the languages. HOW : To access the CLR environment you need to create an Appdomain Object - _CLR_GetDefaultDomain() An AppDomain provides an isolated region in which code runs inside of an existing process. Application domains provide an isolation boundary for security, reliability, and versioning, and for unloading assemblies. Application domains are typically created by runtime hosts, which are responsible for bootstrapping the common language runtime before an application is run. WHEN : Would you use CLR Runtime Hosts 1. To access .NET Class Libraries : System System.Collections System.Data System.Drawing System.IO System.Text System.Threading System.Timers System.Web System.Web.Services System.Windows.Forms System.Xml 2. Accessing custom build .Net Assemblies : Some Examples (but there are a ton out there) AutoItX3 - The .NET Assembly for using AutoItX JSonToXML libr. XMLRPC Libr. .NETPDF libr. .NETOCR Libr WInSCP Libr. ... 3. To Compile .Net Code into an Assembly 4. To Run C# or VB.net Code 5. To Mix AU3 and .Net functionality in your Application WHERE : To find documentation about CLR First of all you can find a lot on MSDN and here : Post 4 & Post 6 EXAMPLES : Multiple examples included in Zip !! Example : “System.Text.UTF8Encoding” Example : “System.IO.FileInfo” Example : “System.Windows.Forms” Example : AutoItX3 Custom .NET Assembly AutoItX Example : Compile Code C# and Code VB Example : Compile Code C# at Runtime WHO : Created the CLR.au3 UDF All credits go to : Danyfirex / Larsj / Trancexx / Junkew TO DO : The library is still Work in Process … (Some of the GUI Controls are not yet working as expected...) Anyone is free to participate in contributing to get the bugs resolved and to expand the CLR.au3 functionality ... Enjoy !! DOWNLOADS : (Last updated) - added CLR Constants.au3 - Danyfirex - Global Constants added (Magic numbers) - added .NET CLR CreateObject vs ObjCreate Example.au3 - Junkew • 2 approaches give the same result (only valid for COM Visible Assembly) • Includes a function that shows you which Assembly Classes are COM Visible - added .Net Conventional COM Objects Examples - ptrex - added .NET CLR CreateComInstanceFrom Example - Danyfirex - You can use it for Regfree COM Assembly Access - System.Activator has 4 methods : • CreateComInstanceFrom : Used to create instances of COM objects. • CreateInstanceFrom : Used to create a reference to an object from a particular assembly and type name. • GetObject : Used when marshaling objects. • CreateInstance : Used to create local or remote instances of an object. - added .NET Access SafeArrays Using AccVarsUtilities Example - LarsJ - added SafeArray Utilities functions in Includes - LarsJ - added .NET Access Native MSCorLib Classes - System - ptrex Multiple System Class Examples : • System.Random • System.DateTime • System.Diagnostics.PerformanceCounter • System.IO.FileInfo • System.Int32 • System.Double • System.Speech • System.Web - added Third Party Assembly Access - ptrex • WinSCP : https://winscp.net/eng/download.php • IonicZip : http://dotnetzip.codeplex.com/ - added more Examples using PowerShell GUI Assembly Access - ptrex • GUI Ribbon .NET Assembly using  CLR Library • GUI Report Designer .NET Assembly using  CLR Library • GUI SSRS Reporting .NET Assembly using  CLR Library CLRv3a.zip .NET CLR Framework for AutoIT.pdf
    1 point
  2. Simpel

    Redim Errors

    Maybe this is a reproducer stripped down to the main problem: #include <WinAPISys.au3> #include <Array.au3> Global $aMDIWindows[0] For $i = 1 To 10000 ConsoleWrite($i & @CRLF) _GetICNetMDIWindows() ; first window grab Next Func _GetICNetMDIWindows() Local $hParentWindow = WinActivate("Unbenannt") ; Notepad Local $aData = _WinAPI_EnumChildWindows($hParentWindow) _ArrayDisplay($aData) If IsArray($aData) Then ReDim $aMDIWindows[$aData[0][0]][2] ;handle;title Local $iIndexBound = 0 For $i = 1 To $aData[0][0] If StringInStr($aData[$i][1], "#32770") Then $aMDIWindows[$iIndexBound][0] = $aData[$i][0] $aMDIWindows[$iIndexBound][1] = WinGetTitle($aData[$i][0]) $iIndexBound += 1 EndIf Next ReDim $aMDIWindows[$iIndexBound][2] _ArrayDisplay($aMDIWindows) If Not UBound($aMDIWindows) Then ConsoleWrite("Not Ubound" & @CRLF) $aMDIWindows = 0 EndIf EndIf EndFunc ;==>_GetICNetMDIWindows Simpel
    1 point
  3. Simpel

    Redim Errors

    Hi. It's not a runnable reproducer for me you gave us but maybe I got the point. Function _GetICNetMDIWindows() has the following line: If Not UBound($aMDIWindows) Then $aMDIWindows = 0 That destroys the array. Example: #include <Array.au3> Example() Example2() Func Example() Local $aArray[1] For $i = 0 To 100 ReDim $aArray[UBound($aArray) + 1] $aArray[$i] = $i Next _ArrayDisplay($aArray) EndFunc Func Example2() Local $aArray[1] $aArray = 0 ; ############################ That's the point For $i = 0 To 100 ReDim $aArray[UBound($aArray) + 1] $aArray[$i] = $i Next _ArrayDisplay($aArray) EndFunc You used _GetICNetMDIWindows() so many times (in which suddenly $aMDIWindows could be zero and destroyed) but you only test inside function PumpFix() IsArray($aMDIWindows). So probably you call _GetICNetMDIWindows() which at any time sets $aMDIWindows = 0 and then you call _GetICNetMDIWindows() again without checking IsArray($aMDIWindows) and chrashes. Simpel
    1 point
  4. Good point about the position and size. This should be better: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $hLV, $iLVx, $iLVy, $aHit[2] = [ -1, -1 ] ; $aHit contains row & col of marked cell Example() Func Example() $hGui = GUICreate( "Mark Cell in Listview", 350, 350, -1, -1, BitXOR( $WS_OVERLAPPEDWINDOW, $WS_MAXIMIZEBOX ) ) Local $idButton = GUICtrlCreateButton( "Text", 10, 10, 150, 25 ) GUICtrlSetResizing( $idButton, $GUI_DOCKALL ) $iLVx = 50 $iLVy = 50 Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", $iLVx, $iLVy, 250, 250 ) For $i = 0 To 99 GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV ) Next $hLV = GUICtrlGetHandle( $idLV ) _GUICtrlListView_SetColumnWidth( $hLV, 0, ( 250 - 20 ) * 0.30 ) _GUICtrlListView_SetColumnWidth( $hLV, 1, ( 250 - 20 ) * 0.30 ) _GUICtrlListView_SetColumnWidth( $hLV, 2, ( 250 - 20 ) * 0.30 ) GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUIRegisterMsg( $WM_SIZING, "WM_SIZING" ) GUISetState() While 1 Switch GUIGetMsg() Case $idButton Local $sTxt = $aHit[0] = -1 ? "No cell selected" : _ _GUICtrlListView_GetItemText( $hLV, $aHit[0], $aHit[1] ) MsgBox( 0, "", $sTxt ) Case $GUI_EVENT_RESIZED ; LV screen position Local $aPos = WinGetPos( $hLV ) Local $tPoint = DllStructCreate( "int X;int Y" ) DllStructSetData( $tPoint, "X", $aPos[0] ) DllStructSetData( $tPoint, "Y", $aPos[1] ) _WinAPI_ScreenToClient( $hGui, $tPoint ) $iLVx = DllStructGetData( $tPoint, "X" ) $iLVy = DllStructGetData( $tPoint, "Y" ) ; Column widths _GUICtrlListView_SetColumnWidth( $hLV, 0, ( $aPos[2] - 20 ) * 0.30 ) _GUICtrlListView_SetColumnWidth( $hLV, 1, ( $aPos[2] - 20 ) * 0.30 ) _GUICtrlListView_SetColumnWidth( $hLV, 2, ( $aPos[2] - 20 ) * 0.30 ) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam ) $iItem = DllStructGetData( $tNMLISTVIEW, "Item" ) _GUICtrlListView_SetItemSelected( $hLV, $iItem, False ) _GUICtrlListView_SetItemState( $hLV, $iItem, 0, $LVIS_FOCUSED ) Local $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0]-$iLVx, $aInfo[1]-$iLVy ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _ _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems( $hLV, $iItem, $iItem ) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem Local $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index Local $iSubItem = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem" ) ; Subitem index Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) ; Forecolor white DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func WM_SIZING( $hWnd, $Msg, $wParam, $lParam ) Local $aPos = WinGetPos( $hLV ) _GUICtrlListView_SetColumnWidth( $hLV, 0, ( $aPos[2] - 20 ) * 0.30 ) _GUICtrlListView_SetColumnWidth( $hLV, 1, ( $aPos[2] - 20 ) * 0.30 ) _GUICtrlListView_SetColumnWidth( $hLV, 2, ( $aPos[2] - 20 ) * 0.30 ) EndFunc
    1 point
  5. #include <Excel.au3> Local $oExcel = _ExcelBookNew(1) _ExcelWriteCell($oExcel, "Something Long Here", 1, 1) _ExcelWriteCell($oExcel, "And something even longer", 2, 1) $oExcel.ActiveSheet.Columns(1).AutoFit
    1 point
×
×
  • Create New...