Leaderboard
Popular Content
Showing content with the highest reputation on 12/15/2021 in all areas
-
Alternative way for your getdisklist Iterate once all drives No merging of array No redimming of array Probably no sorting needed Hopefully better understandable and readable as code is shortened You still have to split to make it an array And you have to build your layout of the string to your needs #NoTrayIcon #requireadmin #include <StringConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <ListBoxConstants.au3> #include <AutoItConstants.au3> #include <WinAPIFiles.au3> #include <Constants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> ; GUICtrlSetData($c_DiskList, "") ; clear previous list info MsgBox($MB_SYSTEMMODAL, "",getdisklist2()) func getDiskList2() Local $aArray = DriveGetDrive($DT_ALL) local $strLine If @error Then ; An error occurred when retrieving the drives. MsgBox($MB_SYSTEMMODAL, "", "It appears an error occurred.") Else For $i = 1 To $aArray[0] ; Show all the drives found and convert the drive letter to uppercase. $sInfo = DriveGetType($aArray[$i], $DT_DRIVETYPE) ;"Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk" if (stringinstr(stringupper("Removable,Fixed"),stringupper($sInfo))>0) Then $strLine=StringUpper($aArray[$i]) & ";" $strLine&=$sInfo & ";" $aDriveInfo = _WinAPI_GetDriveNumber($aArray[$i]) If Not @error Then $strLine&=$aDriveInfo[0]&";" ;[0] - The type of device ($FILE_DEVICE_*). see apifileconstants $strLine&="Disk " & $aDriveInfo[1] &";" ;[1] - The device number. $strLine&=$aDriveInfo[2] &";" ; [2] - The partition number, or (-1) if device cannot be partitioned. $strLine&=Disk_GetName($aDriveInfo[1])& ";" $strLine&=DriveGetLabel($aArray[$i])& ";" & @CRLF Else $strLine&="Error" & ";" $strLine&="Error" & ";" $strLine&="Error" & ";" $strLine&="Error" & ";" & @CRLF EndIf endif Next EndIf return $strLine EndFunc Func Disk_GetName($i_DiskNumber) Local $s_DiskKey = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\disk\Enum", String($i_DiskNumber)) If @error Then Return SetError(1, 0, 0) Local $s_DiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $s_DiskKey, "FriendlyName") If $s_DiskName = "" Then $s_DiskName = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $s_DiskKey, "DeviceDesc") Return $s_DiskName EndFunc ;==>Disk_GetName2 points
-
I guess how it is now is correct? You would never search a singular item because you wouldn't need to search it. You wouldn't search among the rock. You'd just check to see if the rock was what you was looking for? #include <Array.au3> Global $topPoints = [["Jos", 1000], ["jchd", 900], ["TommyDDR", 800]] Global $playerToFind = "TommyDDR" For $i = 3 To 1 Step -1 Local $top = isTopPoints($playerToFind, $i-1) ? " is in TOP " : " is not in TOP " ConsoleWrite($playerToFind & $top & $i & @CRLF) Next Func isTopPoints($player, $nbMax) If $nbMax = 0 Then Return ($topPoints[0][0] = $player) Else Return _ArraySearch($topPoints, $player, 0, $nbMax) >= 0 EndIf EndFunc1 point
-
GDI+ animated loading screens build 2014-06-20 (32 examples)
DyadyaGenya reacted to UEZ for a topic
The issue in your case is that the functions are not running in a separate thread. That means _FileSearch and FileCopy will return when finished and thus will not get any information about the progress. What you can do is to use a generic animation without any display of the progress which must be called before the function. You can do something like this here: #include <Array.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Timers.au3> #include <WinAPIHObj.au3> ;#include-once <_GDIPlus_GearsAnim.au3> ;#include-once <_GDIPlus_CogWheels.au3> ;#include-once <_GDIPlus_CloudySpiral.au3> _GDIPlus_Startup() Global $hGUI = GUICreate("Search box", 300, 300) Local $Button_1, $Button_2, $Button_3 GUISetState(@SW_SHOW, $hGUI) Global $hHBmp_BG, $hB, $iSleep, $File1 Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0 Global $hGUI_Anim, $iW, $iH, $hPic, $fFontSize = 18, $aData $Button_1 = GUICtrlCreateButton("Find file №1", 20, 20, 100, 100) $Button_2 = GUICtrlCreateButton("Find file №2", 20, 140, 100, 100) $Button_3 = GUICtrlCreateButton("Copy file", 140, 20, 100, 100) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_Shutdown() ExitLoop Case $Button_1 $iW = 500 $iH = 250 $iSleep = 40 $hGUI_Anim = GUICreate("Gears Animation", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOWNA, $hGUI_Anim) _Timer_SetTimer($hGUI_Anim, $iSleep, "PlayAnim_Gears") Sleep(10000) ;~ $sPath1 = "D:" ;~ $sFileMask1 = "Test1.txt" ;~ $aReturn = _FileSearch($sPath1, $sFileMask1) ;~ $File1 = $aReturn[1] ;~ ConsoleWrite($File1 & @CR) ;~ ShellExecute($aReturn[1]) _Timer_KillAllTimers($hGUI_Anim) _WinAPI_DeleteObject($hHBmp_BG) GUIDelete($hGUI_Anim) ; While looking for a file, I would like this (_GDIPlus_GearsAnim.au3) loading screen to work. But I don’t know how to do it. Case $Button_2 $sPath2 = "H:" $sFileMask2 = "Test2.txt" $aReturn = _FileSearch($sPath2, $sFileMask2) $File2 = $aReturn[1] ConsoleWrite($File2 & @CR) ShellExecute($File2) ; While looking for a file №2, I would like this (_GDIPlus_CogWheels.au3) loading screen to work. But I don’t know how to do it. Case $Button_3 $iW = 500 $iH = 200 $iSleep = 20 $aData = InitTextBitmaps("Please wait", "Times New Roman", $fFontSize) $hGUI_Anim = GUICreate("Simple Loading Text Anim", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOWNA, $hGUI_Anim) GUIRegisterMsg($WM_TIMER, "PlayAnim_LoadingTextAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI_Anim, "int", 0, "int", $iSleep, "int", 0) Sleep(10000) $sPath2 = "H:" ;~ FileCopy($File1, $sPath2) GUIRegisterMsg($WM_TIMER, "") _Timer_KillAllTimers($hGUI_Anim) For $i = 0 To UBound($aData) - 1 _GDIPlus_BitmapDispose($aData[$i][0]) Next _WinAPI_DeleteObject($hHBmp_BG) GUIDelete($hGUI_Anim) ; While the file is being copied, I would like this (_GDIPlus_CloudySpiral.au3) loading screens to work. But I don’t know how to do it. EndSwitch WEnd Func _FileSearch($sPath, $sFileMask) Local $sOut = StringToBinary("0" & @CRLF, 2), $aOut Local $hDir = Run(@ComSpec & ' /U/C DIR "' & $sPath & '\' & $sFileMask & '" /S/B/A-D', @SystemDir, @SW_HIDE, 6) While 1 $sOut &= StdoutRead($hDir, False, True) If @error Then ExitLoop WEnd $aOut = StringRegExp(BinaryToString($sOut, 2), "[^\r\n]+", 3) If @error Then Return SetError(1) $aOut[0] = UBound($aOut) - 1 Global $IsOrNowFile = $aOut[0] Return $aOut EndFunc ;==>_FileSearch ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Func PlayAnim_Gears($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime $hHBmp_BG = GearsAnim($iW, $iH) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndFunc ;==>PlayAnim Func GearsAnim($iW, $iH, $sText = "Loading...", $fSpeed = 2, $bBgGradient = True, $bHBitmap = True) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 + (@OSBuild > 5999)) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, $GDIP_TEXTRENDERINGHINT_ANTIALIAS) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) If $bBgGradient Then Local Const $hBrush_Bg = _GDIPlus_LineBrushCreate(0, 0, $iW / 2, $iH / 2, 0xFF080808, 0xFF606060, 1) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hBrush_Bg) EndIf Local Const $iW2 = $iW / 2, $iH2 = $iH / 2 Local Const $hBrush = _GDIPlus_BrushCreateSolid(0) Local Static $f1 = 0, $f2 = 0, $f3 = 0, $f4 = 0, $c = 0, $iTeeth = 12 Local $aGears[4], $i, $iW_Gear = 220, $iH_Gear = 150, $iW2_Gear = $iW_Gear / 2, $iH2_Gear = $iH_Gear / 2 Local Const $hBitmap_Gear = _GDIPlus_BitmapCreateFromScan0($iW_Gear, $iH_Gear) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Gear) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 + (@OSBuild > 5999)) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hCtxt, 0xFF121212) $aGears[0] = _GDIPlus_BitmapCreateGear($f1, $iTeeth / 2) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[0], 0, 1) $aGears[1] = _GDIPlus_BitmapCreateGear($f2, $iTeeth / 2) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[1], 51, 51) $aGears[2] = _GDIPlus_BitmapCreateGear($f3, $iTeeth / 2) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[2], 0, 101) $aGears[3] = _GDIPlus_BitmapCreateGear($f4, $iTeeth, 60, 48) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[3], 120, 4) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Gear, $iW2 - $iW2_Gear, $iH2 - $iH2_Gear, $iW_Gear, $iH_Gear) $f1 -= $fSpeed $f2 += $fSpeed $f3 -= $fSpeed $f4 -= $fSpeed / 2 Local $iC = Hex(Int(0x80 - Sin($c) * 0x7F), 2) $c += 0.025 Local $hPath = _GDIPlus_PathCreate() If $sText Then _GDIPlus_BrushSetSolidColor($hBrush, "0x9F" & $iC & $iC & $iC) Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial Black"), $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) ;~ _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) $tLayout.Y = $iH2 + $iH2_Gear + 4 _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $iH / 10, $hFormat) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush) _GDIPlus_PathReset($hPath) EndIf Local Const $iPenSize = 2 Local $tRect = DllStructCreate("float X; float Y; float W; float H;") $tRect.W = $iW_Gear * 1.5 $tRect.H = $iH_Gear Local $hBrush_outline = _GDIPlus_LineBrushCreateFromRectWithAngle($tRect, 0xFF202020, 0xFFA0A0A0, -210, True, 1) _GDIPlus_LineBrushSetSigmaBlend($hBrush_outline, 0, 1) Local Const $hPen = _GDIPlus_PenCreate2($hBrush_outline, $iPenSize) $iW2_Gear += $iPenSize / 2 $iH2_Gear += $iPenSize / 2 Local $aPoints[9][2] = [[8]], $iCorner = 5 $aPoints[1][0] = $iW2 - $iW2_Gear + $iCorner $aPoints[1][1] = $iH2 - $iH2_Gear $aPoints[2][0] = $iW2 + $iW2_Gear - $iCorner $aPoints[2][1] = $iH2 - $iH2_Gear $aPoints[3][0] = $iW2 + $iW2_Gear $aPoints[3][1] = $iH2 - $iH2_Gear + $iCorner $aPoints[4][0] = $iW2 + $iW2_Gear $aPoints[4][1] = $iH2 + $iH2_Gear - $iCorner $aPoints[5][0] = $iW2 + $iW2_Gear - $iCorner $aPoints[5][1] = $iH2 + $iH2_Gear $aPoints[6][0] = $iW2 - $iW2_Gear + $iCorner $aPoints[6][1] = $iH2 + $iH2_Gear $aPoints[7][0] = $iW2 - $iW2_Gear $aPoints[7][1] = $iH2 + $iH2_Gear - $iCorner $aPoints[8][0] = $iW2 - $iW2_Gear $aPoints[8][1] = $iH2 - $iH2_Gear + $iCorner _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.025) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_PathDispose($hPath) _GDIPlus_BrushDispose($hBrush) If $bBgGradient Then _GDIPlus_BrushDispose($hBrush_Bg) _GDIPlus_BrushDispose($hBrush_outline) If $sText Then _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) EndIf For $i = 0 To 3 _GDIPlus_BitmapDispose($aGears[$i]) Next _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hBitmap_Gear) _GDIPlus_GraphicsDispose($hGfx) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc ;==>GearsAnim Func _GDIPlus_BitmapCreateGear($fAngle = 0, $iTeeth = 6, $fRadius_outer = 30, $fRadius_inner = 18, $fTeethHeight = 10.5, $iColor1 = 0xFF606060, $iColor2 = 0xFF404040) Local Const $iW = 2 * $fRadius_outer + $fTeethHeight * 2, $iH = $iW, $iW2 = $iW / 2, $iH2 = $iW2, $fDeltaAngle = 360 / $iTeeth, $fDeg = 3.14159265358979 / 180 Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 + (@OSBuild > 5999)) Local $tRect = DllStructCreate("float X; float Y; float W; float H;") $tRect.W = $iW $tRect.H = $iH / 2 Local $hBrush_outline = _GDIPlus_LineBrushCreateFromRectWithAngle($tRect, 0x44000000 + BitAND(0x00FFFFFF, $iColor2), 0, -90, True, 1) _GDIPlus_LineBrushSetSigmaBlend($hBrush_outline, 1, 0.95) _GDIPlus_LineBrushSetColors($hBrush_outline, 0, 0xAA989898) Local Const $hPen = _GDIPlus_PenCreate2($hBrush_outline, 2) Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor1) Local Const $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath, $iW2 - $fRadius_outer, $iH2 - $fRadius_outer, $fRadius_outer * 2, $fRadius_outer * 2) Local $aPoints[5][2] = [[4]], $iX, $iY, $i, $j For $i = 1 To $iTeeth $iX = $iW2 + Cos(($fAngle + 0) * $fDeg) * $fRadius_outer $iY = $iH2 + Sin(($fAngle + 0) * $fDeg) * $fRadius_outer For $j = 0 To $aPoints[0][0] $aPoints[1][0] = $iX + Cos(($fAngle + 45) * $fDeg) * $fTeethHeight $aPoints[1][1] = $iY + Sin(($fAngle + 45) * $fDeg) * $fTeethHeight $aPoints[2][0] = $iX + Cos(($fAngle + 135) * $fDeg) * $fTeethHeight $aPoints[2][1] = $iY + Sin(($fAngle + 135) * $fDeg) * $fTeethHeight $aPoints[3][0] = $iX + Cos(($fAngle + 225) * $fDeg) * $fTeethHeight $aPoints[3][1] = $iY + Sin(($fAngle + 225) * $fDeg) * $fTeethHeight $aPoints[4][0] = $iX + Cos(($fAngle + 315) * $fDeg) * $fTeethHeight $aPoints[4][1] = $iY + Sin(($fAngle + 315) * $fDeg) * $fTeethHeight Next _GDIPlus_PathAddPolygon($hPath, $aPoints) $fAngle += $fDeltaAngle Next _GDIPlus_PathWindingModeOutline($hPath) _GDIPlus_PathAddEllipse($hPath, $iW2 - $fRadius_inner, $iH2 - $fRadius_inner, $fRadius_inner * 2, $fRadius_inner * 2) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush_outline) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) Return $hBitmap EndFunc ;==>_GDIPlus_BitmapCreateGear ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Func PlayAnim_LoadingTextAnim() $hHBmp_BG = _GDIPlus_LoadingTextAnim($iW, $iH, $aData, $fFontSize) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndFunc ;==>PlayAnim Func _GDIPlus_LoadingTextAnim($iW, $iH, ByRef $aCoords, $fFontSize, $sText = "LOADING", $bHBitmap = True) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999)) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $iBGColor = 0x303030 _GDIPlus_GraphicsClear($hGfx, 0xFF000000 + $iBGColor) Local Const $iStartX = 0, $iEndX = $iW, $fLength = ($iEndX - $iStartX), $fLength2 = $fLength / 2, _ $iW2 = $iW / 2, $iH2 = $iH / 2, $fLeft = $iW2 - 70, $fRight = $iW2 + 30, $iSpeed = 6, _ $fRL = 180 / ($fLeft / $iSpeed), $fRR = 180 / (($iW - $fRight) / $iSpeed), _ $fAL = 0xFF / (($fLeft + $fFontSize) / $iSpeed), $fAR = 0xFF / (($iW - $fRight - $fFontSize) / $iSpeed) Local Const $hBrush_Alpha = _GDIPlus_BrushCreateSolid(0xFF000000 + $iBGColor) Local Static $x = 0, $i = 0 Local $j, $iW_Char, $iH_Char, $hBmp, $hCtxt, $hMatrix, $iDX = 3 For $j = 0 To UBound($aCoords) - 1 $iW_Char = _GDIPlus_ImageGetWidth($aCoords[$j][0]) $iH_Char = _GDIPlus_ImageGetHeight($aCoords[$j][0]) $hBmp = _GDIPlus_BitmapCloneArea($aCoords[$j][0], 0, 0, $iW_Char, $iH_Char, $GDIP_PXF32ARGB) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsClear($hCtxt, 0x00000000) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $iW_Char / 2, $iH_Char / 2) _GDIPlus_MatrixRotate($hMatrix, -180 + $aCoords[$j][2]) _GDIPlus_GraphicsSetTransform($hCtxt, $hMatrix) _GDIPlus_GraphicsDrawImageRect($hCtxt, $aCoords[$j][0], -$iW_Char / 2, -$iH_Char / 2, $iW_Char, $iH_Char) _GDIPlus_BrushSetSolidColor($hBrush_Alpha, Int($aCoords[$j][3]) * 0x1000000 + $iBGColor) _GDIPlus_GraphicsFillRect($hCtxt, -$iW_Char / 2, -$iH_Char / 2, $iW_Char, $iH_Char, $hBrush_Alpha) _GDIPlus_GraphicsDrawImage($hGfx, $hBmp, $aCoords[$j][1], $iH2 - $iH_Char / 2) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hBmp) If $aCoords[$j][1] > $fLeft And $aCoords[$j][1] < $fRight Then $aCoords[$j][1] += $iSpeed / 2 $aCoords[$j][2] = -180 $aCoords[$j][3] = 0x00 Else If $aCoords[$j][1] < $fLeft And $aCoords[$j][1] > 0 Then $aCoords[$j][2] -= $fRL If $aCoords[$j][3] > $fAL Then $aCoords[$j][3] -= $fAL ElseIf $aCoords[$j][1] > $fRight Then $aCoords[$j][2] -= $fRR If ($aCoords[$j][3] - $fAR) < 0xFF Then $aCoords[$j][3] += $fAR EndIf $aCoords[$j][1] += $iSpeed EndIf Next If $aCoords[0][1] > $iW + $fFontSize * 4 Then For $j = 0 To UBound($aCoords) - 1 $aCoords[$j][1] = -($fFontSize * ($iDX + 1) * UBound($aCoords) - 1) + $fFontSize * $iDX * ($j + 1) $aCoords[$j][2] = 0 $aCoords[$j][3] = 0xFF Next EndIf _GDIPlus_BrushDispose($hBrush_Alpha) _GDIPlus_GraphicsDispose($hGfx) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc Func InitTextBitmaps($sText, $sFont, $fFontSize) Local Const $aText = StringSplit($sText, "", 2) Local $aCoords[UBound($aText)][4] Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local $tLayout = _GDIPlus_RectFCreate() Local Const $hDC = _WinAPI_GetWindowDC(0) Local Const $hDummy = _GDIPlus_GraphicsCreateFromHDC($hDC) Local Const $hBrush_Text = _GDIPlus_BrushCreateSolid(0xFF35C4F0) Local $i, $aInfo, $iW, $iH, $hCtxt, $hMatrix, $iDX = 3 For $i = 0 To UBound($aCoords) - 1 $aInfo = _GDIPlus_GraphicsMeasureString($hDummy, $aText[$i], $hFont, $tLayout, $hFormat) $iW = $aInfo[0].Width * 2 $iH = $aInfo[0].Height * 2 $aCoords[$i][0] = _GDIPlus_BitmapCreateFromScan0($iW, $iH) $hCtxt = _GDIPlus_ImageGetGraphicsContext($aCoords[$i][0]) ;~ _GDIPlus_GraphicsClear($hCtxt, 0xFF0000FF) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 4 + (@OSBuild > 5999)) _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, 4) $aCoords[$i][1] = -($fFontSize * ($iDX + 1) * UBound($aCoords) - 1) + $fFontSize * $iDX * ($i + 1) $aCoords[$i][2] = 0 $tLayout.X = $aInfo[0].Width / 2 $tLayout.Y = $aInfo[0].Height / 8 _GDIPlus_GraphicsDrawStringEx($hCtxt, $aText[$i], $hFont, $tLayout, $hFormat, $hBrush_Text) _GDIPlus_GraphicsDispose($hCtxt) $aCoords[$i][3] = 0xFF Next _GDIPlus_BrushDispose($hBrush_Text) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _WinAPI_DeleteObject($hDC) _GDIPlus_GraphicsDispose($hDummy) Return $aCoords EndFunc I hope it helps you a little bit...1 point -
Not necessarily. One can manage scripts (.a3x), that need a certain interpreter version, together with the matching interpreter in separate folders. The interpreters AutoIt3.exe / AutoIt3_64.exe do not have to be installed or associated with the extension .a3x. They are called (stand-alone) from the respective folder. This way one can run e.g. scripts of version 3.3.12.0 and 3.3.14.5. separately, no matter which AutoIt version is installed.1 point
-
_ArraySearch "bug" ? - (Moved)
Earthshine reacted to jchd for a topic
I'm afraid it's too late to fix due to the number of real-world scripts already relying on this convention, admitedly weird. OTOH, "searching" a given single row in an array amounts to directly comparing "searched" column(s) of row index N with search value(s). That's true whatever the searched row index is, 0 or not. So this point is rather moot.1 point -
That is what I would do when running in an corporate environment to avoid a tsunami of virus issues on all computers when the AV company messes up. The added benefit is that the "compiled" a3x files are much smaller to distribute and you only need to distribute the exe one time. Disadvantage obviously is that all scripts need to be able to run on the same version interpreter.1 point
-
We are distributing tools created with AutoIt (.a3x, but .au3 would work just the same) since years to various customers. The launch is done via the interpreter AutoIt3.exe or AutoIt3_x64.exe and, with very very few exceptions, have never observed any problems with AV scanners.1 point
-
This was exactly what I thought and then I made Au3toCmd. See the link in my Signature.1 point
-
@mLipok I slightly improved the UI by adding check marks for selection: #include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> _Example() Func _Example() Local $a_Test[100][10] For $ROW = 0 To 99 For $COL = 0 To 9 $a_Test[$ROW][$COL] = 'Test #' & $COL Next Next Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', False) _ArrayDisplay($a_Selected, '$a_Selected') EndFunc ;==>_Example Func _Array_Select(ByRef $a_Source, $s_title, $s_Information, $b_ArrayHasHeader = True, $hWnd_Parent = 0) If Not IsArray($a_Source) Then Return SetError(1, 0, "is not array") Local $i_Source_Rows_Count = UBound($a_Source, $UBOUND_ROWS), $i_Source_Cols_Count = UBound($a_Source, $UBOUND_COLUMNS) Local $i_Temp_Cols_Count If $i_Source_Cols_Count < 0 Then $i_Source_Cols_Count = 0 If $i_Source_Cols_Count = 0 Then ; If 1D Array $i_Temp_Cols_Count = $i_Source_Cols_Count + 1 Else $i_Temp_Cols_Count = $i_Source_Cols_Count EndIf Local $a_Temp_2[$i_Source_Rows_Count][$i_Temp_Cols_Count] If $b_ArrayHasHeader Then For $icols = 0 To $i_Temp_Cols_Count - 1 For $irows = 0 To $i_Source_Rows_Count - 1 If $i_Source_Cols_Count > 0 Then $a_Temp_2[$irows][$icols] = $a_Source[$irows][$icols] Else $a_Temp_2[$irows][$icols] = $a_Source[$irows] EndIf Next Next EndIf Local $hGuiForm_1 = GUICreate($s_title, 900, 680, 100, -1, -1, -1, $hWnd_Parent) GUISetFont(8.5) GUICtrlCreateLabel($s_Information, 8, 8, 900, 50) Local $id_ListView_1 = GUICtrlCreateListView("", 0, 52, 900, 600, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) Local $h_ListView_Wybierz = ControlGetHandle($hGuiForm_1, "", $id_ListView_1) Local $id_Button_Select = GUICtrlCreateButton("&Wybierz zaznaczone", 0, 655, 900 - 200, 25, 0) GUICtrlSetBkColor($id_Button_Select, 0xA6CAF0) GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE) Local $id_Button_Cancel = GUICtrlCreateButton("&Anuluj", 900 - 200, 655, 200, 25, 0) GUICtrlSetBkColor($id_Button_Cancel, 0xFFFFE1) GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE) GUISetState(@SW_SHOW) #Region - FillUp ListView _GUICtrlListView_BeginUpdate($h_ListView_Wybierz) Local $a_Processing If $b_ArrayHasHeader Then $a_Processing = $a_Temp_2 If $i_Source_Cols_Count > 0 Then For $a = 0 To $i_Temp_Cols_Count - 1 _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][$a]) Next Else _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][0]) EndIf Else $a_Processing = $a_Source If $i_Source_Cols_Count > 0 Then For $a = 0 To $i_Temp_Cols_Count - 1 _GUICtrlListView_AddColumn($h_ListView_Wybierz, '') Next Else _GUICtrlListView_AddColumn($h_ListView_Wybierz, '') EndIf EndIf For $id_X_Row = 0 To $i_Source_Rows_Count - 1 _GUICtrlListView_AddItem($h_ListView_Wybierz, $a_Processing[$id_X_Row][0]) For $id_X_Col = 0 To $i_Temp_Cols_Count - 1 _GUICtrlListView_AddSubItem($h_ListView_Wybierz, $id_X_Row, $a_Processing[$id_X_Row][$id_X_Col], $id_X_Col) Next Next _GUICtrlListView_ClickItem($h_ListView_Wybierz, 1, "left", True, 2) Send("{CTRLDOWN}{SHIFTDOWN}") ControlSend($hGuiForm_1, "", $id_ListView_1, "{NUMPADADD}") Send("{SHIFTUP}{CTRLUP}") If $b_ArrayHasHeader Then _GUICtrlListView_DeleteItem($h_ListView_Wybierz, 0) _GUICtrlListView_EndUpdate($h_ListView_Wybierz) #EndRegion - FillUp ListView Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $id_Button_Select Local $a_Result = StringSplit(_GUICtrlListView_GetCheckedIndices($h_ListView_Wybierz), "|") ; Returns pipe "|" delimited string, "|") GUIDelete($hGuiForm_1) If $a_Result[0] = 0 Then Return SetError(1, 0, "Nie dokonano wyboru") If $b_ArrayHasHeader Then For $IDX_Choosen = 1 To $a_Result[0] ; zwiększam wartosc o jeden bo wyniki z listview sa mniejsze o jeden w stosunku tablicy poczatkowej $a_Result[$IDX_Choosen] += 1 Next EndIf Return $a_Result Case $id_Button_Cancel, $GUI_EVENT_CLOSE GUIDelete($hGuiForm_1) Return SetError(1, 0, "Nie dokonano wyboru") EndSwitch WEnd EndFunc ;==>_Array_Select ; #FUNCTION# ==================================================================================================================== ; Author ........: Gary Frost (gafrost) ; Modified.......: Damon Harris (TheDcoder) (forked from GetSelectedIndices) ; =============================================================================================================================== Func _GUICtrlListView_GetCheckedIndices($hWnd, $bArray = False) Local $tLVITEM = DllStructCreate($tagLVITEM) DllStructSetData($tLVITEM, "Mask", $LVIF_STATE) DllStructSetData($tLVITEM, "StateMask", 0xffff) Local $sIndices, $aIndices[1] = [0] Local $iRet, $iCount = _GUICtrlListView_GetItemCount($hWnd) For $iItem = 0 To $iCount DllStructSetData($tLVITEM, "Item", $iItem) If IsHWnd($hWnd) Then $iRet = _SendMessage($hWnd, $LVM_GETITEMW, 0, $tLVITEM, 0, "wparam", "struct*") <> 0 Else $iRet = GUICtrlSendMsg($hWnd, $LVM_GETITEMSTATE, 0, $tLVITEM) EndIf Local $bChecked = BitAND(DllStructGetData($tLVITEM, "State"), 0x2000) <> 0 If $bChecked Then If (Not $bArray) Then If StringLen($sIndices) Then $sIndices &= "|" & $iItem Else $sIndices = $iItem EndIf Else ReDim $aIndices[UBound($aIndices) + 1] $aIndices[0] = UBound($aIndices) - 1 $aIndices[UBound($aIndices) - 1] = $iItem EndIf EndIf Next If (Not $bArray) Then Return String($sIndices) Else Return $aIndices EndIf EndFunc ;==>_GUICtrlListView_GetCheckedIndices I added a new function called _GUICtrlListView_GetCheckedIndices which returns the indexes which are checked from a list view. Credit goes to Gary Frost as I just mashed up two of his functions (_GUICtrlListView_GetSelectedIndices and _GUICtrlListView_GetItemChecked) to create the function1 point
-
Isnt it this? If $aPIDs[$iLoop][1] = @AutoItPID Then for process #?1 point
-
How would I go about converting the output of this into an array? #NoTrayIcon #RequireAdmin #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Constants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> $wmicdata = Run('cmd /c wmic diskdrive get index,model', @WorkingDir, @SW_HIDE, 2) ProcessWaitClose($wmicdata) $line = StdoutRead($wmicdata) MsgBox($MB_SYSTEMMODAL, "", $line) Any line that starts with a number contains a disk, on those lines the 1st char is always the disk# (or 1st AND 2nd 10 or more disks) the 8th char is always the start of the label even if there is a 2 digit disk #.. I can manually make an array by hardcoding it but idk how to parse stdout output into one... EDIT* --> I made this function to get the friendly name based on the disk number through WMIC and I dont need to create a temp file because I can use the STDout i was shown #NoTrayIcon #RequireAdmin #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Constants.au3> #include <File.au3> #include <Array.au3> #include <String.au3> $ForThisDiskNumber = 0 MsgBox($MB_SYSTEMMODAL, "", Disk_GetName($ForThisDiskNumber)) Func Disk_GetName($Disk) Local $pre_name = "" $wmicdata = Run('cmd /c wmic diskdrive ' & $Disk & ' get model', @WorkingDir, @SW_HIDE, 2) ProcessWaitClose($wmicdata) $pre_name = _StringExplode(StdoutRead($wmicdata), @LF) $d_name = StringStripWS($pre_name[1], $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES) Return $d_name EndFunc ;==>Disk_GetName You send it the disk # and it sends you back the name of the disk.. 😜 awesome..1 point
-
Line 177 needs changing to: Local $datawb = _Excel_BookOpen($oExcel, @ScriptDir & '\SBMO Store setting input.xlsx') You we're passing '\SBMO Store setting input.xlsx' into the $bReadOnly parameter.1 point
-
As I said this is my old code.... so.... Here is my "some way refactored" code: #include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> _Example() Func _Example() Local $a_Test[100][10] For $ROW = 0 To 99 For $COL = 0 To 9 $a_Test[$ROW][$COL] = 'Test #' & $COL Next Next Local $a_Selected = _Array_Select($a_Test, 'Testing', 'Choose few rows', False) _ArrayDisplay($a_Selected, '$a_Selected') EndFunc ;==>_Example Func _Array_Select(ByRef $a_Source, $s_title, $s_Information, $b_ArrayHasHeader = True, $hWnd_Parent = 0) If Not IsArray($a_Source) Then Return SetError(1, 0, "is not array") Local $i_Source_Rows_Count = UBound($a_Source, $UBOUND_ROWS), $i_Source_Cols_Count = UBound($a_Source, $UBOUND_COLUMNS) Local $i_Temp_Cols_Count If $i_Source_Cols_Count < 0 Then $i_Source_Cols_Count = 0 If $i_Source_Cols_Count = 0 Then ; If 1D Array $i_Temp_Cols_Count = $i_Source_Cols_Count + 1 Else $i_Temp_Cols_Count = $i_Source_Cols_Count EndIf Local $a_Temp_2[$i_Source_Rows_Count][$i_Temp_Cols_Count] If $b_ArrayHasHeader Then For $icols = 0 To $i_Temp_Cols_Count - 1 For $irows = 0 To $i_Source_Rows_Count - 1 If $i_Source_Cols_Count > 0 Then $a_Temp_2[$irows][$icols] = $a_Source[$irows][$icols] Else $a_Temp_2[$irows][$icols] = $a_Source[$irows] EndIf Next Next EndIf Local $hGuiForm_1 = GUICreate($s_title, 900, 680, 100, -1, -1, -1, $hWnd_Parent) GUISetFont(8.5) GUICtrlCreateLabel($s_Information, 8, 8, 900, 50) Local $id_ListView_1 = GUICtrlCreateListView("", 0, 52, 900, 600, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) Local $h_ListView_Wybierz = ControlGetHandle($hGuiForm_1, "", $id_ListView_1) Local $id_Button_Select = GUICtrlCreateButton("&Wybierz zaznaczone", 0, 655, 900 - 200, 25, 0) GUICtrlSetBkColor($id_Button_Select, 0xA6CAF0) GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE) Local $id_Button_Cancel = GUICtrlCreateButton("&Anuluj", 900 - 200, 655, 200, 25, 0) GUICtrlSetBkColor($id_Button_Cancel, 0xFFFFE1) GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE) GUISetState(@SW_SHOW) #Region - FillUp ListView _GUICtrlListView_BeginUpdate($h_ListView_Wybierz) Local $a_Processing If $b_ArrayHasHeader Then $a_Processing = $a_Temp_2 If $i_Source_Cols_Count > 0 Then For $a = 0 To $i_Temp_Cols_Count - 1 _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][$a]) Next Else _GUICtrlListView_AddColumn($h_ListView_Wybierz, $a_Processing[0][0]) EndIf Else $a_Processing = $a_Source If $i_Source_Cols_Count > 0 Then For $a = 0 To $i_Temp_Cols_Count - 1 _GUICtrlListView_AddColumn($h_ListView_Wybierz, '') Next Else _GUICtrlListView_AddColumn($h_ListView_Wybierz, '') EndIf EndIf For $id_X_Row = 0 To $i_Source_Rows_Count - 1 _GUICtrlListView_AddItem($h_ListView_Wybierz, $a_Processing[$id_X_Row][0]) For $id_X_Col = 0 To $i_Temp_Cols_Count - 1 _GUICtrlListView_AddSubItem($h_ListView_Wybierz, $id_X_Row, $a_Processing[$id_X_Row][$id_X_Col], $id_X_Col) Next Next _GUICtrlListView_ClickItem($h_ListView_Wybierz, 1, "left", True, 2) Send("{CTRLDOWN}{SHIFTDOWN}") ControlSend($hGuiForm_1, "", $id_ListView_1, "{NUMPADADD}") Send("{SHIFTUP}{CTRLUP}") If $b_ArrayHasHeader Then _GUICtrlListView_DeleteItem($h_ListView_Wybierz, 0) _GUICtrlListView_EndUpdate($h_ListView_Wybierz) #EndRegion - FillUp ListView Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $id_Button_Select If _GUICtrlListView_GetSelectionMark($h_ListView_Wybierz) = -1 Then GUIDelete($hGuiForm_1) Return SetError(1, 0, "Nie dokonano wyboru") EndIf Local $a_Result = StringSplit(_GUICtrlListView_GetSelectedIndices($h_ListView_Wybierz), "|") ; Returns pipe "|" delimited string, "|") GUIDelete($hGuiForm_1) If $b_ArrayHasHeader Then For $IDX_Choosen = 1 To $a_Result[0] ; zwiększam wartosc o jeden bo wyniki z listview sa mniejsze o jeden w stosunku tablicy poczatkowej $a_Result[$IDX_Choosen] += 1 Next EndIf Return $a_Result Case $id_Button_Cancel, $GUI_EVENT_CLOSE GUIDelete($hGuiForm_1) Return SetError(1, 0, "Nie dokonano wyboru") EndSwitch WEnd EndFunc ;==>_Array_Select Any ideas for improvement would be appreciated.1 point
-
What happens when you run the following script ? Run('"C:\Program Files (x86)\Notepad++\notepad++.exe"') Sleep (1000) ; wait for 1 seconds to display the Notepad++ window Local $hWnd = WinGetHandle("[active]") Local $sTitle = WinGetTitle("[active]") MsgBox(BitOR(4096, 64), "Info Notepad++ :", _ "Handle : " & @CRLF & $hWnd & @CRLF & _ "Titel : " & @CRLF & $sTitle & @CRLF) WinSetState($hWnd, "", @SW_MINIMIZE) Sleep(2000) WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(2000) WinClose($hWnd)0 points