Leaderboard
Popular Content
Showing content with the highest reputation on 11/29/2021 in all areas
-
The F1 key in SciTE displays the documentation for the word on which the cursor is located. Up to now this was only available for AutoIt. But times change and we change with them With the "Simple Library Docs Generator" created by MrCreatoR and customized by me, any CHM help file (Compressed HTML Help) can be created (more about this later in a separate thread). The only prerequisite: All function names have to start with the same identifier (like _AD_, _OL_ etc.). We have already created CHM help files for the following UDFs: Active Directory AD-CHM.zip Outlook OutlookEX-CHM.zip TaskScheduler TaskScheduler-CHM.zip WebDriver Webdriver-CHM.zip Preliminary release of the WebDriver help file. This release is for you to play with. Please tell us what you like, what is missing or just what you think about it. For download please see the top of this post. Other CHM help files come with existing UDFs: WinHTTP The integration of these help files in SciTE is now done with the tool presented here. Advanced.Help This tool, created by BugFix from the german forum, allows custom CHM help files to be included in SciTE. The existing help key is used to call either the AutoIt help or the corresponding custom help. Depending on which keyword the cursor is currently on. For unknown keywords the AutoIt help is called. For AutoIt a separate window is opened and for the user-defined UDFs another window is opened, so you can work with both helps at the same time. The ZIP file contains an installation guide in German (Install_Deutsch.txt) and English (Install_English.txt) in which the installation and configuration is described in detail. For download please check the download forum.3 points
-
I made my own tab-control! OwnTab-Gallery Example #include "OwnTab.au3" #cs Known Bugs: --> Bug mit $OwnTab_Style, da diese Variable zur Laufzeit abgefragt wird beim Verstecken und erneuten Anzeigen der Register. --> "Zittern" der alarmierten Register, wenn diese bereits angewählt wurden --> durch blinken mit der selben Farbe #ce Local $hGui = GUICreate("Funkey's OwnTab-UDF Example", 500, 350) GUISetBkColor(0xbbbbbb) $OwnTab_Style = Random(0, 1, 1) ;random style (only 2 styles available!!) Local $aTabText[5] = ["Settings", "Register without icon", "Pic", "Status", "Tab in Tab"] ;Declare the regions for the OwnTab-control Local $aTabIcons[5][2] = [["shell32.dll", 130],[""],["shell32.dll", 139],["shell32.dll", 90], ["shell32.dll", 43]] Global $aCtrlTab = _OwnTab_Create($hGui, $aTabText, 10, 10, 480, 300, 30, 0xD5D5D5, 0xCFE0E7, 0xCFE0E7, $aTabIcons) Local $aTabTip[5] = ["Tip Item 1", "Tip Item 2", "Tip Item 3", "Alarm-Register"] _OwnTab_SetTip($aCtrlTab, $aTabTip) ;set the tooltips for the OwnTab-control #Region Tab1 _OwnTab_Add($aCtrlTab) ;Start controls tab1 Global $Edit1 = GUICtrlCreateEdit("Edit in Tab1", 20, 55, 300, 50, 0) Global $Button1 = GUICtrlCreateButton("Simulate an alarm", 20, 120, 300, 20) Global $Box1 = GUICtrlCreateCheckbox("Switch on hover - set time -->", 20, 180) GUICtrlSetBkColor(-1, 0xCFE0E7) Global $Input1 = GUICtrlCreateInput("1", 200, 180, 50, 20) GUICtrlCreateUpdown($Input1) GUICtrlSetLimit(-1, 15, 1) #EndRegion Tab1 #Region Tab2 _OwnTab_Add($aCtrlTab) ;Start controls tab2 Global $Edit2 = GUICtrlCreateEdit("Edit in Tab2", 20, 150, 300, 50, 0) Global $Label2 = GUICtrlCreateLabel("Label in Tab2", 20, 220, 300, 20, 0x201) GUICtrlSetBkColor(-1, -2) ;$GUI_BKCOLOR_TRANSPARENT #EndRegion Tab2 #Region Tab3 _OwnTab_Add($aCtrlTab) ;Start controls tab3 Global $Labe3 = GUICtrlCreateLabel("If you see this label, you can change the picture-path in scriptline " &@ScriptLineNumber + 1 & "!!", 40, 150, 400, 30, 0x201) Global $Edit3 = GUICtrlCreatePic(@DocumentsCommonDir & '\Eigene Bilder\Beispielbilder\Winter.jpg', 20, 55, 460, 280) #EndRegion Tab3 #Region Tab4 _OwnTab_Add($aCtrlTab) ;Start controls tab4 Global $Button4 = GUICtrlCreateButton("Acknowledge the alarm", 20, 120, 300, 20) Global $Button5 = GUICtrlCreateButton("Enable tab 3", 20, 150, 300, 20) Global $Button6 = GUICtrlCreateButton("Disable tab 3", 20, 180, 300, 20) Global $Button7 = GUICtrlCreateButton("Hide tab 2", 20, 240, 300, 20) Global $Button8 = GUICtrlCreateButton("Show tab 2", 20, 210, 300, 20) #EndRegion Tab4 #Region Tab5 and "Tab in Tab" _OwnTab_Add($aCtrlTab) ;Start controls tab5 GUICtrlCreateLabel("Style Black", 30, 50, 200, 20, 0x201) $OwnTab_Style = 0 Local $aTabText[2] = ["Tab1", "New Info"] ;Declare the regions for the OwnTab-control Local $aTabIcons[2][2] = [["shell32.dll", 20],["shell32.dll", 40]] Global $aCtrlTab2 = _OwnTab_Create($hGui, $aTabText, 30, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons) _OwnTab_Add($aCtrlTab2) ;Start controls tab1 Global $BtnSet = GUICtrlCreateButton("Simulate", 80, 150, 100, 20) _OwnTab_Add($aCtrlTab2) ;Start controls tab2 Global $BtnReset = GUICtrlCreateButton("Acknowledge", 80, 170, 100, 20) _OwnTab_End($aCtrlTab2) GUICtrlCreateLabel("Style White", 270, 50, 200, 20, 0x201) $OwnTab_Style = 1 Local $aTabText[2] = ["Tab1", "Tab2"] ;Declare the regions for the OwnTab-control Local $aTabIcons[2][2] = [["shell32.dll", 10],["shell32.dll", 60]] Global $aCtrlTab3 = _OwnTab_Create($hGui, $aTabText, 270, 80, 200, 200, 30, 0xD5D5D5, 0x00ff00, 0x00ff00, $aTabIcons) _OwnTab_Add($aCtrlTab3) ;Start controls tab1 GUICtrlCreateLabel("Just testing...", 280, 150, 100, 20) GUICtrlSetBkColor(-1, -2) _OwnTab_Add($aCtrlTab3) ;Start controls tab2 GUICtrlCreateLabel("Hello from tab2", 280, 150, 100, 20) GUICtrlSetBkColor(-1, -2) _OwnTab_End($aCtrlTab3) #EndRegion Tab5 _OwnTab_End($aCtrlTab) ;new: end control-definition AND inizialize the OwnTab _OwnTab_Disable($aCtrlTab, 3) ;new: disable tabitems _OwnTab_SetFontCol($aCtrlTab, 0xFF) ;new: set font-color GUISetState() _OwnTab_Hover($aCtrlTab, 0xFFFF88) ;start hover-function if you want _OwnTab_AlarmInit() Local $msg While 1 $msg = GUIGetMsg() For $a = 1 To UBound($aCtrlTab, 1) - 1 If $msg = $aCtrlTab[$a][0] Then _OwnTab_Switch($aCtrlTab, $a) If $a = 5 Then _OwnTab_Switch($aCtrlTab2, $aCtrlTab2[0][0], 1) _OwnTab_Switch($aCtrlTab3, $aCtrlTab3[0][0], 1) EndIf EndIf Next For $a = 1 To UBound($aCtrlTab2, 1) - 1 If $msg = $aCtrlTab2[$a][0] Then _OwnTab_Switch($aCtrlTab2, $a) EndIf Next For $a = 1 To UBound($aCtrlTab3, 1) - 1 If $msg = $aCtrlTab3[$a][0] Then _OwnTab_Switch($aCtrlTab3, $a) EndIf Next Switch $msg Case $Button1 _OwnTab_SetAlarm($aCtrlTab, 4, 0xFF0000) Case $Button4 _OwnTab_ResetAlarm($aCtrlTab, 4) Case $BtnSet _OwnTab_SetAlarm($aCtrlTab2, 2, 0x5050FF) Case $BtnReset _OwnTab_ResetAlarm($aCtrlTab2, 2) Case $Button5 _OwnTab_Enable($aCtrlTab, 3) Case $Button6 _OwnTab_Disable($aCtrlTab, 3) Case $Button7 _OwnTab_Hide($aCtrlTab, 2) Case $Button8 _OwnTab_Show($aCtrlTab, 2) Case $Box1 If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1)) Else _OwnTab_Hover($aCtrlTab, 0xFFFF88, 0) EndIf Case $Input1 If GUICtrlRead($Box1) = 1 Then _OwnTab_Hover($aCtrlTab, 0xFFFF88, GUICtrlRead($Input1)) Case -3 Exit EndSwitch Sleep(10) WEnd OwnTab-UDF #include-once #include <GDIPlus.au3> #include <Array.au3> #include <Constants.au3> #include <WindowsConstants.au3> #Include <Timers.au3> #cs Copyrights to funkey from Autoit.de #ce Local $HoverArray[1], $ControlID, $Global_I = 0, $__ControlID, $HoverActive = 0, $Temp_Found = 0, $szTemp_Array[2] Local $OwnTabHoverCol[2], $OwnTabHoverHelp[1], $OwnTabHoverSwitch, $aOwnTabHoverCount, $OwnTabHoverCtrl Local $aOwnTabAlarm[1][3], $iOwnTabAlarm, $hOwnTabGui, $hTimerAlarm, $hTimerHover Local $OwnTab_Style = 0 ; only 0 or 1 ! _GDIPlus_Startup() OnAutoItExitRegister("_OwnTab_OnExit") Func _OwnTab_Create($hWnd, $aTabText, $xPos, $yPos, $iWidth, $iHeight, $iItemHeight = -1, $nColNoSel = -1, $nColSel = -1, $nColBg = -1, $aIcons = "") Local $aSize, $aSize2[UBound($aTabText)][2], $xLast = 0, $aCtrl[UBound($aTabText) + 1][11], $iOffset = 0 If Not IsArray($aIcons) Then Local $Icons[UBound($aTabText)][2] Else Local $Icons = $aIcons EndIf If Not IsArray($aTabText) Then Return SetError(1, 0, "") For $i = 0 To UBound($aTabText) - 1 If $aTabText[$i] = "" Then Return SetError(2, $i + 1, "") $aSize = _GetTextSize($aTabText[$i]) $aSize[0] += Ceiling($aSize[0] / 10) ;make it 10% longer for bold text $aSize2[$i][0] = $aSize[0] $aSize2[$i][1] = $aSize[1] If $iItemHeight = -1 Then $iItemHeight = $aSize[1] If $Icons[$i][0] <> "" Then $iOffset = $iItemHeight $aTabText[$i] &= " " Else $iOffset = 0 EndIf $aCtrl[$i + 1][7] = $Icons[$i][0] ;filename for icon $aCtrl[$i + 1][8] = $Icons[$i][1] ;index for icon $aCtrl[$i + 1][9] = $aSize[0] + 5 + $iOffset ;labelwidth $aCtrl[$i + 1][0] = GUICtrlCreateLabel($aTabText[$i], $xPos + $xLast + 5, $yPos + 2, $aCtrl[$i + 1][9], $iItemHeight, 0x411201 + ($Icons[$i][0] <> ""), $OwnTab_Style) _HoverAddCtrl($aCtrl[$i + 1][0]) If $Icons[$i][0] <> "" Then $aCtrl[$i + 1][6] = GUICtrlCreateIcon("", 0, $xPos + $xLast + 8, $yPos + 5, $iItemHeight - 6, $iItemHeight - 6) Else $aCtrl[$i + 1][6] = GUICtrlCreateDummy() EndIf ;~ If $Icons[$i][0] <> "" Then _SetBkIcon($aCtrl[$i + 1][6], $nColNoSel, $aCtrl[$i + 1][7], $aCtrl[$i + 1][8], $iItemHeight - 6, $iItemHeight - 6) GUICtrlCreateLabel($aCtrl[$i + 1][7], -200, -200) ;For information GUICtrlCreateLabel($aCtrl[$i + 1][8], -200, -200) ;For information GUICtrlCreateLabel($iItemHeight - 6, -200, -200) ;For information $aCtrl[$i + 1][2] = $nColNoSel $aCtrl[$i + 1][3] = $nColSel $xLast += $aCtrl[$i + 1][9] Next GUICtrlCreateLabel("", $xPos, $yPos + $iItemHeight, $iWidth, $iHeight, 0x411000, $OwnTab_Style) GUICtrlSetState(-1, 128) ;$GUI_DISABLE GUICtrlSetBkColor(-1, $nColBg) $xLast = 0 For $i = 0 To UBound($aTabText) - 1 If $Icons[$i][0] <> "" Then $iOffset = $iItemHeight Else $iOffset = 0 EndIf $aCtrl[$i + 1][1] = GUICtrlCreateLabel("", $xPos + $xLast + 6, $yPos + $iItemHeight - $OwnTab_Style, $aSize2[$i][0] + 3 + $iOffset, 2+2*$OwnTab_Style) GUICtrlSetBkColor(-1, $nColSel) $xLast += $aSize2[$i][0] + 5 + $iOffset Next $aCtrl[0][1] = $iItemHeight $aCtrl[0][2] = $nColNoSel $aCtrl[0][3] = $nColSel $aCtrl[0][9] = $yPos + 2 $hOwnTabGui = $hWnd Return $aCtrl EndFunc ;==>_OwnTab_Create Func _OwnTab_Switch(ByRef $aOwnTab, $iIndex, $fForce = 0) _OwnTab_UnRegisterHover($aOwnTab, $iIndex) If _OwnTab_IsAlarmed($aOwnTab[$iIndex][0]) Then $aOwnTabAlarm[@extended][2] = $aOwnTabAlarm[@extended][1] $HoverActive = 0 If $aOwnTab[0][0] = $iIndex And $fForce = 0 Then Return For $s = 1 To UBound($aOwnTab, 1) - 1 If $iIndex <> $s Then GUICtrlSetState($aOwnTab[$s][1], 32) ;$GUI_HIDE GUICtrlSetFont($aOwnTab[$s][0], -1, 400) If Not _OwnTab_IsAlarmed($aOwnTab[$s][0]) Then GUICtrlSetBkColor($aOwnTab[$s][0], $aOwnTab[$s][2]) If $aOwnTab[$s][7] <> "" Then _SetBkIcon($aOwnTab[$s][6], $aOwnTab[$s][2], $aOwnTab[$s][7], $aOwnTab[$s][8], GUICtrlRead($aOwnTab[$s][0] + 4), GUICtrlRead($aOwnTab[$s][0] + 4)) EndIf If _ArraySearch($OwnTabHoverHelp, $aOwnTab[$s][0]) = -1 Then _OwnTab_RegisterHover($aOwnTab, $s) EndIf Else GUICtrlSetFont($aOwnTab[$iIndex][0], -1, 1000) If Not _OwnTab_IsAlarmed($aOwnTab[$s][0]) Then GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[$iIndex][3]) If $aOwnTab[$s][7] <> "" Then _SetBkIcon($aOwnTab[$iIndex][6], $aOwnTab[$iIndex][3], $aOwnTab[$s][7], $aOwnTab[$s][8], GUICtrlRead($aOwnTab[$s][0] + 4), GUICtrlRead($aOwnTab[$s][0] + 4)) EndIf GUICtrlSetState($aOwnTab[$iIndex][1], 16) ;$GUI_SHOW EndIf Next If $aOwnTab[0][0] = "" Or $fForce Then For $t = $aOwnTab[0][4] To $aOwnTab[UBound($aOwnTab, 1) - 1][4] GUICtrlSetState($t, 32) ;$GUI_HIDE If $t > $aOwnTab[$iIndex - 1][4] And $t < $aOwnTab[$iIndex][4] Then GUICtrlSetState($t, 16) ;$GUI_SHOW Next Else For $t = $aOwnTab[$aOwnTab[0][0] - 1][4] To $aOwnTab[$aOwnTab[0][0]][4] GUICtrlSetState($t, 32) ;$GUI_HIDE Next For $t = $aOwnTab[$iIndex - 1][4] To $aOwnTab[$iIndex][4] GUICtrlSetState($t, 16) ;$GUI_SHOW Next EndIf $aOwnTab[0][0] = $iIndex EndFunc ;==>_OwnTab_Switch Func _OwnTab_SetTip(ByRef $aOwnTab, $ToolTips = "", $iIndex = "") If IsArray($ToolTips) Then For $i = 1 To UBound($aOwnTab, 1) - 1 $aOwnTab[$i][5] = $ToolTips[$i - 1] GUICtrlSetTip($aOwnTab[$i][0], $ToolTips[$i - 1]) Next Else If $iIndex = "" Then Return SetError(1) $aOwnTab[$iIndex][5] = $ToolTips GUICtrlSetTip($aOwnTab[$iIndex][0], $ToolTips) EndIf EndFunc ;==>_OwnTab_SetTip Func _OwnTab_AlarmInit($iTime = 555) If Not $hTimerAlarm Then $hTimerAlarm = _Timer_SetTimer($hOwnTabGui, $iTime, "_OwnTab_AlarmBlink") Else $hTimerAlarm = _Timer_SetTimer($hOwnTabGui, $iTime, "", $hTimerAlarm) EndIf EndFunc ;==>_OwnTab_AlarmInit Func _OwnTab_AlarmBlink($hWnd, $Msg, $iIDTimer, $dwTime) Local $AlarmColAct $iOwnTabAlarm = Not $iOwnTabAlarm For $i = 1 To UBound($aOwnTabAlarm, 1) - 1 If $iOwnTabAlarm Then $AlarmColAct = $aOwnTabAlarm[$i][2] Else $AlarmColAct = $aOwnTabAlarm[$i][1] EndIf GUICtrlSetBkColor($aOwnTabAlarm[$i][0], $AlarmColAct) _SetBkIcon($aOwnTabAlarm[$i][0] + 1, $AlarmColAct, GUICtrlRead($aOwnTabAlarm[$i][0] + 2), GUICtrlRead($aOwnTabAlarm[$i][0] + 3), GUICtrlRead($aOwnTabAlarm[$i][0] + 4), GUICtrlRead($aOwnTabAlarm[$i][0] + 4)) Next EndFunc ;==>_OwnTab_AlarmBlink Func _OwnTab_SetAlarm(ByRef $aOwnTab, $iIndex, $nAlarmSel = 0xFF0000) Local $hCtrl = $aOwnTab[$iIndex][0] Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl) If $iSearch <> -1 Then Return ReDim $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) + 1][3] $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][0] = $hCtrl $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][1] = $nAlarmSel $aOwnTabAlarm[UBound($aOwnTabAlarm, 1) - 1][2] = $aOwnTab[$iIndex][2] ;~ GUICtrlSetBkColor($aOwnTab[$iIndex][1], $nAlarmSel) EndFunc ;==>_OwnTab_SetAlarm Func _OwnTab_ResetAlarm(ByRef $aOwnTab, $iIndex) Local $hCtrl = $aOwnTab[$iIndex][0] Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl) If $iSearch = -1 Then Return _ArrayDelete($aOwnTabAlarm, $iSearch) $aOwnTab[$iIndex][2] = $aOwnTab[0][2] $aOwnTab[$iIndex][3] = $aOwnTab[0][3] ;~ GUICtrlSetBkColor($aOwnTab[$iIndex][1], $aOwnTab[0][3]) If $aOwnTab[0][0] <> $iIndex Then GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[0][2]) Else _SetBkIcon($aOwnTab[$iIndex][0] + 1, $aOwnTab[$iIndex][3], $aOwnTab[$iIndex][7], $aOwnTab[$iIndex][8], GUICtrlRead($aOwnTab[$iIndex][0] + 4), GUICtrlRead($aOwnTab[$iIndex][0] + 4)) GUICtrlSetBkColor($aOwnTab[$iIndex][0], $aOwnTab[0][3]) EndIf EndFunc ;==>_OwnTab_ResetAlarm Func _OwnTab_Add(ByRef $aOwnTab) Local $i = 0 While 1 If $aOwnTab[$i][4] = "" Then ExitLoop $i += 1 WEnd $aOwnTab[$i][4] = GUICtrlCreateDummy() EndFunc ;==>_OwnTab_Add Func _OwnTab_End(ByRef $aOwnTab, $iIndex = 1) $aOwnTab[UBound($aOwnTab, 1) - 1][4] = GUICtrlCreateDummy() _OwnTab_Switch($aOwnTab, $iIndex) EndFunc ;==>_OwnTab_End Func _OwnTab_Hover($aOwnTab, $nColHover, $fSwitch = 0, $iTime = 50) $OwnTabHoverCol[0] = $nColHover $OwnTabHoverCol[1] = $aOwnTab[0][2] $OwnTabHoverSwitch = $fSwitch If Not $hTimerHover Then $hTimerHover = _Timer_SetTimer($hOwnTabGui, $iTime, "_ProcessHover") Else $hTimerHover = _Timer_SetTimer($hOwnTabGui, $iTime, "", $hTimerHover) EndIf EndFunc ;==>_OwnTab_Hover Func _OwnTab_RegisterHover($aOwnTab, $iIndex) If _ArraySearch($HoverArray, $aOwnTab[$iIndex][0]) = -1 Then _HoverAddCtrl($aOwnTab[$iIndex][0]) EndFunc ;==>_OwnTab_RegisterHover Func _OwnTab_UnRegisterHover($aOwnTab, $iIndex) Local $iSearch = _ArraySearch($HoverArray, $aOwnTab[$iIndex][0]) If $iSearch <> -1 Then _ArrayDelete($HoverArray, $iSearch) EndFunc ;==>_OwnTab_UnRegisterHover #Region Disable and Enable Tab-Register Func _OwnTab_Disable($aOwnTab, $iIndex) GUICtrlSetState($aOwnTab[$iIndex][0], 128) _OwnTab_UnRegisterHover($aOwnTab, $iIndex) Local $iSearch = _ArraySearch($OwnTabHoverHelp, $aOwnTab[$iIndex][0]) If $iSearch = -1 Then _ArrayAdd($OwnTabHoverHelp, $aOwnTab[$iIndex][0]) EndFunc ;==>_OwnTab_Disable Func _OwnTab_Enable($aOwnTab, $iIndex) GUICtrlSetState($aOwnTab[$iIndex][0], 64) _OwnTab_RegisterHover($aOwnTab, $iIndex) Local $iSearch = _ArraySearch($OwnTabHoverHelp, $aOwnTab[$iIndex][0]) If $iSearch <> -1 Then _ArrayDelete($OwnTabHoverHelp, $iSearch) EndFunc ;==>_OwnTab_Enable #EndRegion Disable and Enable Tab-Register Func _OwnTab_Hide(ByRef $aOwnTab, $iIndex) If $iIndex = 0 Or $iIndex > UBound($aOwnTab, 1) - 1 Then Return SetError(1) If BitAND(GUICtrlGetState($aOwnTab[$iIndex][0]), 32) Then Return GUICtrlSetState($aOwnTab[$iIndex][0], 32) ;$GUI_HIDE GUICtrlSetState($aOwnTab[$iIndex][1], 32) ;$GUI_HIDE GUICtrlSetState($aOwnTab[$iIndex][6], 32) ;$GUI_HIDE Local $Offset = 3 For $o = 0 To $iIndex - 1 $Offset += $aOwnTab[$o][9] - 0 Next For $o = $iIndex + 1 To UBound($aOwnTab, 1) - 1 GUICtrlSetPos($aOwnTab[$o][0], $Offset, $aOwnTab[0][9]) GUICtrlSetPos($aOwnTab[$o][1], $Offset + 1, $aOwnTab[0][9] + $aOwnTab[0][1] - 2 - $OwnTab_Style) GUICtrlSetPos($aOwnTab[$o][6], $Offset + 3, $aOwnTab[0][9] + 3) $Offset += $aOwnTab[$o][9] Next If $iIndex = $aOwnTab[0][0] Then If $iIndex = 1 Then _OwnTab_Switch($aOwnTab, 2) Else _OwnTab_Switch($aOwnTab, $iIndex - 1) EndIf EndIf EndFunc ;==>_OwnTab_Hide Func _OwnTab_Show(ByRef $aOwnTab, $iIndex, $iActivate = 0) If $iIndex = 0 Or $iIndex > UBound($aOwnTab, 1) + 1 Then Return SetError(1) If BitAND(GUICtrlGetState($aOwnTab[$iIndex][0]), 16) Then Return Local $Offset = 3 For $o = 0 To UBound($aOwnTab, 1) - 2 $Offset += $aOwnTab[$o][9] - 0 Next For $o = UBound($aOwnTab, 1) - 1 To $iIndex + 1 Step -1 GUICtrlSetPos($aOwnTab[$o][0], $Offset, $aOwnTab[0][9]) GUICtrlSetPos($aOwnTab[$o][1], $Offset + 1, $aOwnTab[0][9] + $aOwnTab[0][1] - 2 - $OwnTab_Style) GUICtrlSetPos($aOwnTab[$o][6], $Offset + 3, $aOwnTab[0][9] + 3) $Offset -= $aOwnTab[$o - 1][9] Next GUICtrlSetState($aOwnTab[$iIndex][0], 16) ;$GUI_SHOW GUICtrlSetState($aOwnTab[$iIndex][6], 16) ;$GUI_SHOW If $iActivate Then _OwnTab_Switch($aOwnTab, $iIndex) EndIf EndFunc ;==>_OwnTab_Show Func _OwnTab_SetFontCol($aOwnTab, $nColor, $iIndex = "") If $iIndex = "" Then For $i = 1 To UBound($aOwnTab, 1) - 1 GUICtrlSetColor($aOwnTab[$i][0], $nColor) Next Else If $iIndex < 1 Or $iIndex >= UBound($aOwnTab, 1) Then Return SetError(1) GUICtrlSetColor($aOwnTab[$iIndex][0], $nColor) EndIf EndFunc ;==>_OwnTab_SetFontCol Func _OwnTab_SetOnEvent($aOwnTab, $sFunc = "", $iIndex = "") If $sFunc = "" Then $sFunc = "_OwnTab_OnEvent" If $iIndex = "" Then For $f = 1 To UBound($aOwnTab, 1) -1 GUICtrlSetOnEvent($aOwnTab[$f][0], $sFunc) Next Else If $iIndex < 1 Or $iIndex >= UBound($aOwnTab, 1) Then Return SetError(1) GUICtrlSetOnEvent($aOwnTab[$iIndex][0], $sFunc) EndIf EndFunc ;~ Func _OwnTab_OnEvent() ;for example ;~ For $a = 1 To UBound($aCtrlTab, 1) -1 ;~ If @GUI_CtrlId = $aCtrlTab[$a][0] Then ExitLoop ;~ Next ;~ If $a < UBound($aCtrlTab, 1) Then _OwnTab_Switch($aCtrlTab, $a) ;~ EndFunc Func _OwnTab_OnExit() _GDIPlus_Shutdown() If $hTimerAlarm Then _Timer_KillTimer($hOwnTabGui, $hTimerAlarm) If $hTimerHover Then _Timer_KillTimer($hOwnTabGui, $hTimerHover) EndFunc ;==>_OwnTab_Exit Func _GetTextSize($nText, $sFont = 'Microsoft Sans Serif', $iFontSize = 8.5, $iFontAttributes = 0) ;Author: Bugfix ;Modified: funkey If $nText = '' Then Return Local $hGui = GUICreate("Textmeter by Bugfix") ;~ _GDIPlus_Startup() Local $hFormat = _GDIPlus_StringFormatCreate(0) Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iFontAttributes, 3) Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat) Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height")) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hGraphic) ;~ _GDIPlus_Shutdown() GUIDelete($hGui) Local $aSize[2] = [$iWidth, $iHeight] Return $aSize EndFunc ;==>_GetTextSize Func _ProcessHover($hWnd, $Msg, $iIDTimer, $dwTime) If $OwnTabHoverSwitch > 1 And $OwnTabHoverCtrl <> "" Then If $aOwnTabHoverCount < $OwnTabHoverSwitch Then $aOwnTabHoverCount += 1 If $aOwnTabHoverCount >= $OwnTabHoverSwitch Then ControlClick($hOwnTabGui, "", $OwnTabHoverCtrl) $aOwnTabHoverCount = 0 $OwnTabHoverCtrl = "" EndIf EndIf $ControlID = _HoverCheck() If IsArray($ControlID) Then If $ControlID[0] = "AcquiredHover" Then $OwnTabHoverCtrl = $ControlID[1] $aOwnTabHoverCount = 0 If $OwnTabHoverSwitch = "1" Then Return ControlClick($hOwnTabGui, "", $OwnTabHoverCtrl) Else _HoverFound($ControlID[1]) EndIf Else If $ControlID[1] <> "" Then _HoverLost($ControlID[1]) $OwnTabHoverCtrl = "" EndIf EndIf EndIf EndFunc ;==>_ProcessHover Func _HoverLost($ControlID) If _OwnTab_IsAlarmed($ControlID) Then Return GUICtrlSetBkColor($ControlID, $OwnTabHoverCol[1]) If GUICtrlRead($ControlID + 2) <> "" Then _SetBkIcon($ControlID + 1, $OwnTabHoverCol[1], GUICtrlRead($ControlID + 2), GUICtrlRead($ControlID + 3), GUICtrlRead($ControlID + 4), GUICtrlRead($ControlID + 4)) EndFunc ;==>_HoverLost Func _HoverFound($ControlID) If _OwnTab_IsAlarmed($ControlID) Then Return GUICtrlSetBkColor($ControlID, $OwnTabHoverCol[0]) If GUICtrlRead($ControlID + 2) <> "" Then _SetBkIcon($ControlID + 1, $OwnTabHoverCol[0], GUICtrlRead($ControlID + 2), GUICtrlRead($ControlID + 3), GUICtrlRead($ControlID + 4), GUICtrlRead($ControlID + 4)) EndFunc ;==>_HoverFound Func _OwnTab_IsAlarmed($hCtrl) Local $iSearch = _ArraySearch($aOwnTabAlarm, $hCtrl) If $iSearch = -1 Then Return 0 Return SetExtended($iSearch, 1) EndFunc #Region _MouseHover.au3 ;==================================================================================================================================== ; UDF Name: _MouseHover.au3 ; ; Author: marfdaman (Marvin) ; ; Contributions: RazerM (adding SetText parameter to _HoverFound and _HoverUndo). ; ; email: marfdaman at gmail dot com ; ; Use: Enable hover events for controls ; ; Note(s): If you want to use this i.c.w. an AdlibEnable in your current script, make your Adlib call "_HoverCheck()" as well. ; In this case, _HoverOn must NOT be called. ;==================================================================================================================================== ;=============================================================================== ; Description: _HoverAddCtrl ; Parameter(s): $___ControlID -> Control ID of control to be hoverchecked ; ; Requirement: Array.au3 ; Return Value(s): None ;=============================================================================== Func _HoverAddCtrl($___ControlID) _ArrayAdd($HoverArray, $___ControlID) EndFunc ;==>_HoverAddCtrl ;=============================================================================== ; Description: Checks whether the mousecursor is hovering over any of the defined controls. ; Parameter(s): None ; Requirement: None ; Return Value(s): If a control has matched, an array will be returned, with $array[1] being either ; "AcquiredHover" or "LostHover". $array[2] will contain the control ID. ; It is recommended that you put this function in an AdlibEnable, since it's EXTREMELY ; resource friendly. ;=============================================================================== Func _HoverCheck() $HoverData = GUIGetCursorInfo() If Not IsArray($HoverData) Then Return $Temp_Found = 0 For $i = 1 To UBound($HoverArray) - 1 If $HoverData[4] = $HoverArray[$i] Or $HoverData[4] = $HoverArray[$i] + 1 Then $Temp_Found = $i EndIf Next Select Case $Temp_Found = 0 And $HoverActive = 1 Or $Temp_Found <> 0 And $Temp_Found <> $Global_I And $HoverActive = 1 $HoverActive = 0 $Temp_Found = 0 $szTemp_Array[0] = "LostHover" $szTemp_Array[1] = $HoverArray[$Global_I] Return $szTemp_Array Case $Temp_Found > 0 And $HoverActive = 0 $Global_I = $Temp_Found $HoverActive = 1 $Temp_Found = 0 $szTemp_Array[0] = "AcquiredHover" $szTemp_Array[1] = $HoverArray[$Global_I] Return $szTemp_Array EndSelect EndFunc ;==>_HoverCheck #EndRegion _MouseHover.au3 Func _SetBkIcon($ControlID, $iBackground, $sIcon, $iIndex, $iWidth, $iHeight) ;Yashied ;http://www.autoitscript.com/forum/index.php?showtopic=92207&view=findpost&p=662886 Const $STM_SETIMAGE = 0x0172 Local $tIcon, $tID, $hDC, $hBackDC, $hBackSv, $hBitmap, $hImage, $hIcon, $hBkIcon $tIcon = DllStructCreate('hwnd') $tID = DllStructCreate('hwnd') $hIcon = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) If (@error) Or ($hIcon[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) $tIcon = 0 $tID = 0 $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight) $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap) _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL) ;~ _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hBkIcon = DllCall($__g_hGDIPDll, 'int', 'GdipCreateHICONFromBitmap', 'hWnd', $hImage, 'int*', 0) $hBkIcon = $hBkIcon[2] _GDIPlus_ImageDispose($hImage) GUICtrlSendMsg($ControlID, $STM_SETIMAGE, $IMAGE_ICON, _WinAPI_CopyIcon($hBkIcon)) _WinAPI_RedrawWindow(GUICtrlGetHandle($ControlID)) ;~ _GDIPlus_Shutdown() _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_DeleteDC($hBackDC) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteObject($hBkIcon) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hIcon) Return SetError(0, 0, 1) EndFunc ;==>_SetBkIcon Have fun! Edit: Fixed a problem with the hover-function Edit2: New version with Icon-support and hover-switch Edit3: 2009 New improved version!! Edit4: 2021 Updated UDF to work with actual version of AutoIt. (Thanks for downloading and using this script over 1350 times) OwnTab.au3 OwnTab_Example.au32 points
-
The Microsoft Windows Task Scheduler offers a lot of features. The two existing UDFs are a bit "complex" to use and miss help files and examples for each function. Based on a discussion on the german forum we would like to create a new UDF based on the existing "template" UDFs. Which functions do you miss in the existing UDFs? Should there be more examples? Should there be a help file? Should there be a wiki entry explaining the concepts? Which functions should be made easier to use? What else? Basic conditions Only Task Scheduler 2.0 will be supported (>= Windows Vista, Windows Server 2008). The UDF will use COM; neither AT.exe nor SCHTASKS.exe will be used. It will support as many of the objects and parameters as sensible. The UDF should be useable for everyone (beginners and experts) to suit their needs. Completed functions (fully documented including examples) - last changed: 2019-12-03 Planned functions (functions we are working on) - last changed: 2019-10-25 Suggested functions (we need to discuss if they schould be implemented) - last changed: 2019-11-03 Postponed functions (we will discuss this functions when the need arises) - last changed: 2019-09-301 point
-
Version 1.6.0.1
2,264 downloads
Extensive library to control and manipulate Microsoft Task Scheduler Service. Please check this site for the implementation status! Please check the History.txt file in the archive for the changelog. Please check the WIKI for details about how to use the UDF. BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2021-02-03) None Things to come (last changed: 2021-02-03) None1 point -
Email custon alert - (Moved)
ETverde reacted to argumentum for a topic
..better than chrome. Is a starting point code wise.1 point -
So part of your include lusbapi.h has some struct constructs where the pointer reference is to the function extern "C" DWORD WINAPI GetDllVersion(void); extern "C" LPVOID WINAPI CreateLInstance(PCHAR const DeviceName); enum { USB11_LUSBAPI, USB20_LUSBAPI, INVALID_USB_SPEED_LUSBAPI }; enum { NO_MODULE_MODIFICATION_LUSBAPI = -1 }; const WORD MAX_VIRTUAL_SLOTS_QUANTITY_LUSBAPI = 127; // ========================================================================== // *************************** L-Card USB BASE ****************************** // ========================================================================== struct ILUSBBASE { virtual BOOL WINAPI OpenLDevice(WORD VirtualSlot) = 0; virtual BOOL WINAPI CloseLDevice(void) = 0; virtual BOOL WINAPI ReleaseLInstance(void) = 0; virtual HANDLE WINAPI GetModuleHandle(void) = 0; virtual BOOL WINAPI GetModuleName(PCHAR const ModuleName) = 0; virtual BOOL WINAPI GetUsbSpeed(BYTE* const UsbSpeed) = 0; virtual BOOL WINAPI LowPowerMode(BOOL LowPowerFlag) = 0; virtual BOOL WINAPI GetLastErrorInfo(LAST_ERROR_INFO_LUSBAPI* const LastErrorInfo) = 0; }; struct ILE140 : public ILUSBBASE { virtual BOOL WINAPI GET_ADC_PARS(ADC_PARS_E140* const AdcPars) = 0; virtual BOOL WINAPI SET_ADC_PARS(ADC_PARS_E140* const AdcPars) = 0; virtual BOOL WINAPI START_ADC(void) = 0; ... For that to work you probably need https://www.autoitscript.com/autoit3/docs/functions/DllCallAddress.htm maybe with objcreateinterface (but as it looks plain c probably not)1 point
-
Version 0.5.0 Added: rapid start option /Rapid Added: substitution of macros @ScriptFullPath, @ScriptName and @ScriptLineNumber Added: macros @PlysPath and @PlysVersion Added: Unicode support for stderr and stdout streams Added: process the error window message, the notification area tool tip and icon Changed: translation algorithm for better performance Changed: Plys options for each file Changed: /NoStdio command line switch instead “#plys nostdio” line in script Changed: lambda feature enabled by default Fixed: tab to spaces conversion is broken Fixed: dollar prefix is appended for “until” keyword Fixed: incorrect line enumeration Fixed: extra endif after single-line if..then and decreasing indent https://github.com/NSUSpray/Plys/releases/tag/v0.5.01 point
-
Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Moderation Team1 point
-
_GDIPlus_GraphicsGetDPIRatio() works correctly only if you compile it with #AutoIt3Wrapper_Res_HiDpi=Y. Obviously, the manifest must be present in the executable. #include <Array.au3> #include <GDIPlus.au3> #AutoIt3Wrapper_Res_HiDpi=Y _ArrayDisplay(_GDIPlus_GraphicsGetDPIRatio()) Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) Local $aResults[2] = [0, 0] _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, $aResults) #forcedef $__g_hGDIPDll, $ghGDIPDll $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, $aResults) Local $iDPI = $aResult[2] Local $aresults[2] = [$iDPIDef / $iDPI, $iDPI / $iDPIDef] _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Return $aresults EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio This way I get the correct array values which are not 1, 1!1 point
-
Struct ArrayIn Example03 above, many instances of a larger structure are copied from .NET to AutoIt. The total time spent both generating and copying data is measured. In order to measure the time used exclusively for copying data, it's necessary to split the code into two functions: A function to generate data and a function to copy data. This can be done by storing all instances of the structure in an array of structures. To copy instances of the structure from AutoIt back to .NET, it's convenient to store the structures in an array in the .NET code. Example03 below is a new version where it's possible to measure structure generation times and transfer times separately. Similarly, Example02 is a new version where it's possible to measure array generation times and transfer times separately. Note that code to generate duplicates is included in Rand2dArrayCreate() and RandStructsCreate() functions. Example02 #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <Array.au3> #include "Random2dArray.au3" Example( 100, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 50000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 100000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 250000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 750000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 2000000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Func Example( _ $iRows, _ ; Number of rows in the array $aColumns, _ ; Number of columns and data types in the array, see 1) in docu $sSource = "" ) ; Character source for string columns, random strings are created from these characters ; Load .NET code, create object Local Static $oNetCode = 0, $oRand2dArrayClass If Not $oNetCode Then $oNetCode = DotNet_LoadVBcode( FileRead( "Example02.vb" ), "System.dll" ) $oRand2dArrayClass = DotNet_CreateObject( $oNetCode, "Rand2dArrayClass" ) EndIf ; Check $aColumns array Local $iError = CheckColumnsArray( $aColumns ) If $iError Then Return SetError($iError,0,0) ; Define $aColTypes array Local $iColumns = UBound( $aColumns ) Local $aColTypes[6][$iColumns+1] ; Update $aColTypes and $aColumns For $i = 0 To $iColumns - 1 If CalcColTypes( $i, $aColumns, $aColTypes, $iRows, $sSource ) Then ContinueLoop $aColumns[$i][2] += 1 ; Because of .NET Random class ; Convert duplicates as a percentage to number of unique rows $aColumns[$i][3] = $iRows - Int( $iRows * $aColumns[$i][3] / 100 ) If $aColumns[$i][3] And $aColumns[$i][3] < $iRows Then $aColumns[$i][3] -= 1 Next ; Visual code verification If $iRows = 100 Then $oRand2dArrayClass.Rand2dArrayCreate( $iRows, $aColumns, $aColTypes, $sSource ) Local $aArray100 = $oRand2dArrayClass.Rand2dArrayToAutoIt() $oRand2dArrayClass.Rand2dArrayDelete() _ArrayDisplay( $aArray100 ) Return EndIf ; Number of rows ConsoleWrite( "Array rows = " & $iRows & @CRLF ) ; Create array Local $hTimer = TimerInit() $oRand2dArrayClass.Rand2dArrayCreate( $iRows, $aColumns, $aColTypes, $sSource ) ConsoleWrite( "Create array = " & TimerDiff( $hTimer ) & @CRLF ) ; Pass array to AutoIt $hTimer = TimerInit() Local $aArray = $oRand2dArrayClass.Rand2dArrayToAutoIt() ConsoleWrite( "Pass to AutoIt = " & TimerDiff( $hTimer ) & @CRLF ) ; Delete .NET array $oRand2dArrayClass.Rand2dArrayDelete() ; Pass array to .NET $hTimer = TimerInit() $oRand2dArrayClass.Rand2dArrayToDotNet( $aArray ) ConsoleWrite( "Pass to .NET = " & TimerDiff( $hTimer ) & @CRLF & @CRLF ) ; Delete .NET array $oRand2dArrayClass.Rand2dArrayDelete() EndFunc #cs Array rows = 50000 Create array = 161.3358744048 Pass to AutoIt = 53.1796500402687 Pass to .NET = 128.998994597868 Array rows = 100000 Create array = 276.623278397762 Pass to AutoIt = 108.432993923537 Pass to .NET = 258.063372194661 Array rows = 250000 Create array = 898.781576733183 Pass to AutoIt = 264.890631696736 Pass to .NET = 631.123803539603 Array rows = 750000 Create array = 2717.34763337093 Pass to AutoIt = 837.568960363219 Pass to .NET = 2094.36373615079 Array rows = 2000000 Create array = 7424.69637769875 Pass to AutoIt = 2081.94096635518 Pass to .NET = 5806.68962274841 #ce Imports System Class Rand2dArrayClass 'Global in class Dim aObjects(,) Public Sub Rand2dArrayCreate( iRows As Integer, aColumns As Object(,), aColTypes As Object(,), sSource As String ) Dim iColumns As Integer = aColumns.GetUpperBound(1) + 1 Dim aSource As Char() = sSource.ToCharArray() Dim iSourceLen As Integer = sSource.Length ReDim aObjects(iColumns-1,iRows-1) Dim oRnd As New Random() Dim sStr As String = "" Dim k, y, m, dMax As Integer For i As Integer = 0 To iRows - 1 'String columns For j As Integer = 1 To aColTypes(0,0) k = aColTypes(j,0) If i <= aColumns(3,k) Then For l As Integer = 1 To oRnd.Next( aColumns(1,k), aColumns(2,k) ) sStr &= aSource(oRnd.Next( iSourceLen )) Next aObjects(k,i) = sStr sStr = "" Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Integer columns For j As Integer = 1 To aColTypes(0,1) k = aColTypes(j,1) If i <= aColumns(3,k) Then aObjects(k,i) = oRnd.Next( aColumns(1,k), aColumns(2,k) ) Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Float columns For j As Integer = 1 To aColTypes(0,2) k = aColTypes(j,2) If i <= aColumns(3,k) Then aObjects(k,i) = aColumns(1,k) + ( aColumns(2,k) - aColumns(1,k) ) * oRnd.NextDouble() Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Date columns For j As Integer = 1 To aColTypes(0,3) k = aColTypes(j,3) If i <= aColumns(3,k) Then y = oRnd.Next( aColumns(1,k), aColumns(2,k) ) m = oRnd.Next( 1, 13 ) Select m Case 1, 3, 5, 7, 8, 10, 12 dMax = 31 Case 4, 6, 9, 11 dMax = 30 Case Else '2 dMax = If( y Mod 4 <> 0, 28, If( y Mod 400 = 0, 29, If( y Mod 100 = 0, 28, 29 ) ) ) End Select aObjects(k,i) = y * 10000 + m * 100 + oRnd.Next( 1, dMax + 1 ) Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Time columns For j As Integer = 1 To aColTypes(0,4) k = aColTypes(j,4) If i <= aColumns(3,k) Then aObjects(k,i) = oRnd.Next( aColumns(1,k), aColumns(2,k) ) * 10000 + oRnd.Next( 0, 60 ) * 100 + oRnd.Next( 0, 60 ) Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Row/col columns For j As Integer = 1 To aColTypes(0,5) k = aColTypes(j,5) aObjects(k,i) = i & "/" & k Next Next End Sub Public Function Rand2dArrayToAutoIt() As Object(,) Return aObjects End Function Public Sub Rand2dArrayToDotNet( aArray As Object(,) ) aObjects = aArray End Sub Public Sub Rand2dArrayDelete() ReDim aObjects(0,0) End Sub End Class Example03 #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include "Random2dArray.au3" Example( 100, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 50000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 100000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 250000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 750000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 2000000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Func Example( _ $iRows, _ ; Number of rows in the array $aColumns, _ ; Number of columns and data types in the array, see 1) in docu $sSource = "" ) ; Character source for string columns, random strings are created from these characters ; Load .NET code, create object Local Static $oNetCode = 0, $oRandStructsClass If Not $oNetCode Then $oNetCode = DotNet_LoadVBcode( FileRead( "Example03.vb" ), "System.dll" ) $oRandStructsClass = DotNet_CreateObject( $oNetCode, "RandStructsClass" ) EndIf ; Check $aColumns array Local $iError = CheckColumnsArray( $aColumns ) If $iError Then Return SetError($iError,0,0) ; Define $aColTypes array Local $iColumns = UBound( $aColumns ) Local $aColTypes[6][$iColumns+1] ; Update $aColTypes and $aColumns For $i = 0 To $iColumns - 1 If CalcColTypes( $i, $aColumns, $aColTypes, $iRows, $sSource ) Then ContinueLoop $aColumns[$i][2] += 1 ; Because of .NET Random class ; Convert duplicates as a percentage to number of unique rows $aColumns[$i][3] = $iRows - Int( $iRows * $aColumns[$i][3] / 100 ) If $aColumns[$i][3] And $aColumns[$i][3] < $iRows Then $aColumns[$i][3] -= 1 Next ; Visual code verification If $iRows = 100 Then $oRandStructsClass.RandStructsCreate( $iRows, $aColumns, $aColTypes, $sSource ) Local $pPtr100 = $oRandStructsClass.RandStructsToAutoIt( $iRows ), $tStruct, $tString, $iSize = @AutoItX64 ? 56 : 40 ConsoleWrite( "$pPtr100 = " & Ptr( $pPtr100 ) & @CRLF & @CRLF ) ; Display first structure ConsoleWrite( "First structure:" & @CRLF ) $tStruct = DllStructCreate( "int iString;ptr pString;int iInteger;double dDouble;int iDate;int iTime;int iRowCol;ptr pRowCol", $pPtr100 ) ConsoleWrite( "$tStruct.iString = " & $tStruct.iString & @CRLF ) ConsoleWrite( "$tStruct.pString = " & Ptr( $tStruct.pString ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iString & "]", $tStruct.pString ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF ) ConsoleWrite( "$tStruct.iInteger = " & $tStruct.iInteger & @CRLF ) ConsoleWrite( "$tStruct.dDouble = " & $tStruct.dDouble & @CRLF ) ConsoleWrite( "$tStruct.iDate = " & $tStruct.iDate & @CRLF ) ConsoleWrite( "$tStruct.iTime = " & $tStruct.iTime & @CRLF ) ConsoleWrite( "$tStruct.iRowCol = " & $tStruct.iRowCol & @CRLF ) ConsoleWrite( "$tStruct.pRowCol = " & Ptr( $tStruct.pRowCol ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iRowCol & "]", $tStruct.pRowCol ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF & @CRLF ) ; Display last structure ConsoleWrite( "Last structure:" & @CRLF ) $tStruct = DllStructCreate( "int iString;ptr pString;int iInteger;double dDouble;int iDate;int iTime;int iRowCol;ptr pRowCol", $pPtr100 + $iSize * ( $iRows - 1 ) ) ConsoleWrite( "$tStruct.iString = " & $tStruct.iString & @CRLF ) ConsoleWrite( "$tStruct.pString = " & Ptr( $tStruct.pString ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iString & "]", $tStruct.pString ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF ) ConsoleWrite( "$tStruct.iInteger = " & $tStruct.iInteger & @CRLF ) ConsoleWrite( "$tStruct.dDouble = " & $tStruct.dDouble & @CRLF ) ConsoleWrite( "$tStruct.iDate = " & $tStruct.iDate & @CRLF ) ConsoleWrite( "$tStruct.iTime = " & $tStruct.iTime & @CRLF ) ConsoleWrite( "$tStruct.iRowCol = " & $tStruct.iRowCol & @CRLF ) ConsoleWrite( "$tStruct.pRowCol = " & Ptr( $tStruct.pRowCol ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iRowCol & "]", $tStruct.pRowCol ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF & @CRLF ) ; Delete .NET structs $oRandStructsClass.RandStructsDelete() ; Free structure memory $oRandStructsClass.FreeStructure() Return EndIf ; Number of rows ConsoleWrite( "Struct rows = " & $iRows & @CRLF ) ; Create structs Local $hTimer = TimerInit() $oRandStructsClass.RandStructsCreate( $iRows, $aColumns, $aColTypes, $sSource ) ConsoleWrite( "Create structs = " & TimerDiff( $hTimer ) & @CRLF ) ; Copy structs to AutoIt $hTimer = TimerInit() Local $pPtr = $oRandStructsClass.RandStructsToAutoIt( $iRows ) ConsoleWrite( "Copy to AutoIt = " & TimerDiff( $hTimer ) & @CRLF ) ; Delete .NET structs $oRandStructsClass.RandStructsDelete() ; Copy structs to .NET $hTimer = TimerInit() $oRandStructsClass.RandStructsToDotNet( $iRows ) ConsoleWrite( "Copy to .NET = " & TimerDiff( $hTimer ) & @CRLF & @CRLF ) ; Delete .NET structs $oRandStructsClass.RandStructsDelete() ; Free structure memory $oRandStructsClass.FreeStructure() #forceref $pPtr EndFunc #cs Struct rows = 50000 Create structs = 118.687319937022 Copy to AutoIt = 14.4374527116075 Copy to .NET = 27.3954765492515 Struct rows = 100000 Create structs = 270.28500615459 Copy to AutoIt = 30.5258261460518 Copy to .NET = 71.3821661221316 Struct rows = 250000 Create structs = 654.394887271121 Copy to AutoIt = 70.4205373540553 Copy to .NET = 144.230739927763 Struct rows = 750000 Create structs = 1731.17973924928 Copy to AutoIt = 203.711537966051 Copy to .NET = 437.325547215529 Struct rows = 2000000 Create structs = 4556.50490192412 Copy to AutoIt = 547.36291803216 Copy to .NET = 1646.96449730863 #ce Imports System Imports System.Runtime.InteropServices Public Structure Test Public iString As Integer 'String length Public sString As String Public iInteger As Integer Public dDouble As Double Public iDate As Integer Public iTime As Integer Public iRowCol As Integer 'String length Public sRowCol As String End Structure Class RandStructsClass 'Globals in class Dim tTest As Test, iSize As Integer = Marshal.SizeOf( tTest ) Dim aTest() As Test Dim pnt As IntPtr Public Sub RandStructsCreate( iRows As Integer, aColumns As Object(,), aColTypes As Object(,), sSource As String ) Dim iColumns As Integer = aColumns.GetUpperBound(1) + 1 Dim aSource As Char() = sSource.ToCharArray() Dim iSourceLen As Integer = sSource.Length Dim oRnd As New Random() ReDim aTest(iRows-1) Dim tTest As Test Dim sStr As String = "" Dim k, y, m, dMax As Integer For i As Integer = 0 To iRows - 1 'String columns For j As Integer = 1 To aColTypes(0,0) k = aColTypes(j,0) If i <= aColumns(3,k) Then For l As Integer = 1 To oRnd.Next( aColumns(1,k), aColumns(2,k) ) sStr &= aSource(oRnd.Next( iSourceLen )) Next tTest.iString = sStr.Length + 1 tTest.sString = sStr sStr = "" Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Integer columns For j As Integer = 1 To aColTypes(0,1) k = aColTypes(j,1) If i <= aColumns(3,k) Then tTest.iInteger = oRnd.Next( aColumns(1,k), aColumns(2,k) ) Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Float columns For j As Integer = 1 To aColTypes(0,2) k = aColTypes(j,2) If i <= aColumns(3,k) Then tTest.dDouble = aColumns(1,k) + ( aColumns(2,k) - aColumns(1,k) ) * oRnd.NextDouble() Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Date columns For j As Integer = 1 To aColTypes(0,3) k = aColTypes(j,3) If i <= aColumns(3,k) Then y = oRnd.Next( aColumns(1,k), aColumns(2,k) ) m = oRnd.Next( 1, 13 ) Select m Case 1, 3, 5, 7, 8, 10, 12 dMax = 31 Case 4, 6, 9, 11 dMax = 30 Case Else '2 dMax = If( y Mod 4 <> 0, 28, If( y Mod 400 = 0, 29, If( y Mod 100 = 0, 28, 29 ) ) ) End Select tTest.iDate = y * 10000 + m * 100 + oRnd.Next( 1, dMax + 1 ) Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Time columns For j As Integer = 1 To aColTypes(0,4) k = aColTypes(j,4) If i <= aColumns(3,k) Then tTest.iTime = oRnd.Next( aColumns(1,k), aColumns(2,k) ) * 10000 + oRnd.Next( 0, 60 ) * 100 + oRnd.Next( 0, 60 ) Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Row/col columns For j As Integer = 1 To aColTypes(0,5) k = aColTypes(j,5) tTest.sRowCol = i & "/" & k tTest.iRowCol = tTest.sRowCol.Length + 1 Next aTest(i) = tTest Next End Sub Public Function RandStructsToAutoIt( iRows As Integer ) As String pnt = Marshal.AllocHGlobal( iRows * iSize ) 'Console.WriteLine( "Marshal.SizeOf( tTest ) = {0}", iSize ) 'Copy structures to unmanaged memory For i As Integer = 0 To iRows - 1 Marshal.StructureToPtr( aTest(i), pnt + i * iSize, False ) Next Return pnt.ToString() End Function Public Sub RandStructsToDotNet( iRows As Integer ) ReDim aTest(iRows-1) For i As Integer = 0 To iRows - 1 aTest(i) = CType( Marshal.PtrToStructure( pnt + i * iSize, GetType( Test ) ), Test ) Next End Sub Public Sub RandStructsDelete() ReDim aTest(0) End Sub Public Sub FreeStructure() Marshal.FreeHGlobal( pnt ) End Sub End Class Performance Example02 Example03 --------------------------------- --------------------------------- Array rows = 50000 Struct rows = 50000 Create array = 161.3358744048 Create structs = 118.687319937022 Pass to AutoIt = 53.1796500402687 Copy to AutoIt = 14.4374527116075 Pass to .NET = 128.998994597868 Copy to .NET = 27.3954765492515 Array rows = 100000 Struct rows = 100000 Create array = 276.623278397762 Create structs = 270.28500615459 Pass to AutoIt = 108.432993923537 Copy to AutoIt = 30.5258261460518 Pass to .NET = 258.063372194661 Copy to .NET = 71.3821661221316 Array rows = 250000 Struct rows = 250000 Create array = 898.781576733183 Create structs = 654.394887271121 Pass to AutoIt = 264.890631696736 Copy to AutoIt = 70.4205373540553 Pass to .NET = 631.123803539603 Copy to .NET = 144.230739927763 Array rows = 750000 Struct rows = 750000 Create array = 2717.34763337093 Create structs = 1731.17973924928 Pass to AutoIt = 837.568960363219 Copy to AutoIt = 203.711537966051 Pass to .NET = 2094.36373615079 Copy to .NET = 437.325547215529 Array rows = 2000000 Struct rows = 2000000 Create array = 7424.69637769875 Create structs = 4556.50490192412 Pass to AutoIt = 2081.94096635518 Copy to AutoIt = 547.36291803216 Pass to .NET = 5806.68962274841 Copy to .NET = 1646.96449730863 Data creation rates are higher for structures than for arrays. It takes about 30 - 100 percent longer to create arrays than structures. This is probably due to the fact that the 2d arrays are arrays of objects, where the more computationally heavy objects are needed to handle data of different types (strings, integers and doubles). While the 1d array of structures consists only of one data type (structures). The code to create random data is the same for both arrays and structures. Therefore, it can almost only be the difference between arrays and structures that results in a higher speed for structures. Data transfer rates are significantly higher for structures than for arrays. The speeds are about 3-4 times higher for structures. And this applies to transfers in both directions from .NET to AutoIt and from AutoIt to .NET. Transfers from .NET to AutoIt are 2-3 times faster than the other direction. With the Marshal Class used in this thread, it's apparently not possible to transfer a 1d array of structures as a single data block. But it cannot be ruled out that it's possible through custom marshalling. And that, of course, would be very interesting. 7z-fileNew 7z-file at bottom of first post.1 point
-
Hi @Dexter1993. First of all, you seem to use AutoItSharedData. It is dependent on this library, but it seems a little off-topic in this thread maybe? But anyhow, here is an example for you: Script 1: #include <AutoItObject_Internal.au3> #include <AutoItObject_Internal_ROT.au3> Global $oShare = IDispatch() ; AutoIt3 does not currently support "inline"/anonymous array creation, so we need to assign it to a variable before use. Global $aArray = [[1,2,3,4],[5,6,7,8]] $oShare.array = $aArray _AOI_ROT_register($oShare, "mouseData") While 1 Sleep(10) WEnd Script 2: #include <Array.au3> #include <AutoItObject_Internal.au3> #include <AutoItObject_Internal_ROT.au3> Global $oShare = ObjGet("mouseData") Global $aArray = $oShare.array _ArrayDisplay($aArray) ; To access array inline from object, the property must be wrapped in parentheses MsgBox(0, "", ($oShare.array)[0][0]) While 1 Sleep(10) WEnd1 point
-
Aquarium
Skeletor reacted to coffeeturtle for a topic
@Chimp - NICELY DONE! If you are ever so inclined, would like, please, options to control which monitors to have the aquarium or all of them at once while fishes swim between them.1 point