Jump to content

junkew

MVPs
  • Posts

    3,034
  • Joined

  • Last visited

  • Days Won

    13

junkew last won the day on January 23

junkew had the most liked content!

About junkew

Profile Information

  • Location
    Netherlands, Oostzaan

Recent Profile Visitors

4,487 profile views

junkew's Achievements

  1. Maybe invalidating the region? Win32 api example // Move the region OffsetRgn(hRegion, x - (x - 10), y - (y - 10)); InvalidateRect(hwnd, NULL, TRUE); // Request a redraw
  2. ChatGPT nows how to crunch this😀 Upload the pictures Question: In each picture there are 4 numbers can you recognize them? Answer: Here are the numbers I recognize from the images: Image 1 (pic1.png): The number is 2409. Image 2 (pic2.png): The number is 0257. Image 3 (pic3.png): The number is 8035. Image 4 (pic4.png): The number is 4691.
  3. So here some partial recognition based on the png files. As its italic it will be more complicated to properly first cut the characters nicely. I hope the script gives you some insights on how to do the analysis. When thats done you could directly bitblit line11 and 27 and 41 from the screen as that seems to be a proper discriminator to identify the number. From the screen you can probably directly bitblt with black/white pixels directly which should speed up even more. Due to italic it seems a little harder to calculate the exact position for each digit calculated (maybe even easier to just hardcode them as it seems to be off by 1 or 2 bytes for each digit. #Region includes Opt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #include <string.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #EndRegion _GDIPlus_Startup() Dim $BitmapFilename Dim $BMPData="", $BMPWidth=0, $BMPHeight=0, $BMPLineWidth=0, $imgBytes=2 dim $binaryLine, $startColumn ;~ for each picture file for $i=1 to 4 $BitmapFilename = @TempDir & "\" & "pic" & string($i) & ".png" $BMPData="" $BMPWidth=0 $BMPHeight=0 $BMPLineWidth=0 $imgBytes=1 consolewrite($bitmapFileName) ; Load the bitmap to find getImage($BitmapFilename, $BMPData, $BMPWidth, $BMPHeight, $BMPLineWidth, $imgBytes) ;~ See the height and width and dump the data on screen consolewrite($BMPHeight & " ; ") consolewrite($BMPWidth &@CRLF ) consolewrite(" 0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite(" 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 ;~ From the screenshots we can ignore the first 16 bytes (remember in text its 2 characters ;~ $binaryLine=BinaryMid($bmp1Data,($i*$BMP1LineWidth)+16,$BMP1LineWidth) ;~ and we only need 4 digits which takes about 28 characters and 1 character separator = $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16,60) ;~ $binaryLine=$bmpData ;~ Lets make it readable $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ lets recognise for $iNumber=1 to 4 consolewrite(@crlf) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) ;~ Its hard to determine the column for each digit in a formula if $iNumber=1 then $startColumn=16 if $iNumber=2 then $startColumn=30 if $iNumber=3 then $startColumn=45 if $iNumber=4 then $startColumn=59 ;~ Only a few lines in the png are of interest For $iLine = 11 To $BMPHeight-12 ;~ $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16+(($iNumber-1)*14),15) $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+$startColumn,15) $binaryLine=StringReplace($binaryLine,"0"," ") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ if on line 11 at position 28 I have a B it can be a 4 ;~ It seems to be easier to revert back to a string when we have the data local $lineData11=stringstripws(StringRegExpReplace(binaryMid($bmpData,(11*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) local $lineData27=stringstripws(StringRegExpReplace(binaryMid($bmpData,(27*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) local $lineData41=stringstripws(StringRegExpReplace(binaryMid($bmpData,(41*$BMPLineWidth)+$startColumn,15),"[x0]"," "),3) consolewrite(string($lineData11) & " - ") consolewrite(string($lineData27) & " - ") consolewrite(string($lineData41) & @crlf) ;~ And here determine the magic lines if (($lineData11="BBB") and ($lineData27="B222B B222B")) then consolewrite("Ita a 4" & @CRLF) if (($lineData11="BBB BBB") and ($lineData27="B222BB222BB222BB222B")) then consolewrite("Ita a 6" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222BB222BB222B")) then consolewrite("Ita a 9" & @CRLF) if (($lineData11="BBB") and ($lineData27="B222B")) then consolewrite("Ita a 1" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222BB222B")) then consolewrite("Ita a 8" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222B B222B B222B")) then consolewrite("Ita a 0" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222B") and ($lineData41="BBB BBB BBB")) then consolewrite("Ita a 3" & @CRLF) if (($lineData11="BBB BBB BBB") and ($lineData27="B222BB222B") and ($lineData41="BBB BBB BBB BBB BBB")) then consolewrite("Ita a 2" & @CRLF) if (($lineData11="BBB BBB BBB BBB BBB") and ($lineData27="B222B") and ($lineData41="BBB")) then consolewrite("Ita a 7" & @CRLF) if (($lineData11="BBB BBB BBB BBB BBB") and ($lineData27="B222B") and ($lineData41="BBB BBB BBB")) then consolewrite("Ita a 5" & @CRLF) Next Next _GDIPlus_Shutdown() Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;Get $tagGDIPBITMAPDATA structure ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison if ($imgBytes=1) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF04INDEXED) Endif if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) EndIf if ($imgBytes=3) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) endIf If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect #EndRegion
  4. I enhanced the script of my first answer. Based on that you can see the patterns and identify the differences between the numbers 0-9 It depends if your are "reading" bitblt from the screen you should basically iterate per character. If you save them all as png files its like the given script needs to be enhanced and add the pattern later onwards.
  5. You should get some output like below, copy pasted to a texteditor (replaced 0 with a dot) you can find out the width of the numbers somewhere around 28 (depending on your colordepth) .x................................................................................................................................................................................ .x....................................................BBB.....................BBB..BBB................BBB..BBB..BBB.....................BBB....................................... .x...................................................B222B...................B222BB222B..............B222BB222BB222B...................B222B...................................... .x...................................................B222B...................B222BB222B..............B222BB222BB222B...................B222B...................................... .x....................................................BBB.....................BBB..BBB................BBB..BBB..BBB.....................BBB....................................... .x................................................................................................................................................................................ .x..............................................BBB..BBB................BBB.....................BBB.................BBB...........BBB..BBB........................................ .x.............................................B222BB222B..............B222B...................B222B...............B222B.........B222BB222B....................................... .x.............................................B222BB222B..............B222B...................B222B...............B222B.........B222BB222B....................................... .x..............................................BBB..BBB................BBB.....................BBB.................BBB...........BBB..BBB........................................ .x................................................................................................................................................................................ .x.........................................BBB.......BBB...........BBB..........................BBB.................BBB................BBB........................................ .x........................................B222B.....B222B.........B222B........................B222B...............B222B..............B222B....................................... .x........................................B222B.....B222B.........B222B........................B222B...............B222B..............B222B....................................... .x.........................................BBB.......BBB...........BBB..........................BBB.................BBB................BBB........................................ .x................................................................................................................................................................................ .x...................................BBB............BBB...........BBB..BBB..BBB..BBB................BBB..BBB..BBB..BBB................BBB......................................... .x..................................B222B..........B222B.........B222BB222BB222BB222B..............B222BB222BB222BB222B..............B222B........................................ .x..................................B222B..........B222B.........B222BB222BB222BB222B..............B222BB222BB222BB222B..............B222B........................................ .x...................................BBB............BBB...........BBB..BBB..BBB..BBB................BBB..BBB..BBB..BBB................BBB......................................... .x................................................................................................................................................................................ .x..................................BBB..BBB..BBB..BBB..BBB......BBB.................BBB..........................BBB................BBB.......................................... .x.................................B222BB222BB222BB222BB222B....B222B...............B222B........................B222B..............B222B......................................... .x.................................B222BB222BB222BB222BB222B....B222B...............B222B........................B222B..............B222B......................................... .x..................................BBB..BBB..BBB..BBB..BBB......BBB.................BBB..........................BBB................BBB.......................................... .x................................................................................................................................................................................ .x................................................BBB...........BBB.................BBB.....................BBB.....................BBB........................................... .x...............................................B222B.........B222B...............B222B...................B222B...................B222B.......................................... .x...............................................B222B.........B222B...............B222B...................B222B...................B222B.......................................... .x................................................BBB...........BBB.................BBB.....................BBB.....................BBB........................................... .x................................................................................................................................................................................ .x................................................BBB................BBB..BBB..BBB................BBB..BBB.....................BBB..BBB..BBB...................................... .x...............................................B222B..............B222BB222BB222B..............B222BB222B...................B222BB222BB222B..................................... .x...............................................B222B..............B222BB222BB222B..............B222BB222B...................B222BB222BB222B..................................... .x................................................BBB................BBB..BBB..BBB................BBB..BBB.....................BBB..BBB..BBB......................................
  6. Maybe this helps a little in understanding. Its just manipulation of pixels in a certan layout (PNG). Look at the output and zoom in/out, you can see almost the numbers yourself #Region includes Opt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #include <string.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #EndRegion _GDIPlus_Startup() Dim $BitmapFilename Dim $BMPData="", $BMPWidth=0, $BMPHeight=0, $BMPLineWidth=0, $imgBytes=1 dim $binaryLine for $i=1 to 4 $BitmapFilename = @TempDir & "\" & "pic" & string($i) & ".png" $BMPData="" $BMPWidth=0 $BMPHeight=0 $BMPLineWidth=0 $imgBytes=1 consolewrite($bitmapFileName) ; Load the bitmap to find getImage($BitmapFilename, $BMPData, $BMPWidth, $BMPHeight, $BMPLineWidth, $imgBytes) ;~ See the height and width and dump the data on screen consolewrite($BMPHeight & " ; ") consolewrite($BMPWidth &@CRLF ) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 ;~ From the screenshots we can ignore the first 16 bytes (remember in text its 2 characters ;~ $binaryLine=BinaryMid($bmp1Data,($i*$BMP1LineWidth)+16,$BMP1LineWidth) ;~ and we only need 4 digits which takes about 28 characters and 1 character separator = $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16,60) ;~ Lets make it readable $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next ;~ lets recognise for $iNumber=1 to 4 consolewrite(@crlf) consolewrite("0 1 2 3 4 5 6 7 8 9 x x x x " & @CRLF) consolewrite("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" & @CRLF) For $iLine = 11 To $BMPHeight-12 $binaryLine=BinaryMid($bmpData,($iLine *$BMPLineWidth)+16+(($iNumber-1)*15),14) $binaryLine=StringReplace($binaryLine,"0",".") consolewrite($iLine & " : " & $binaryLine & @CRLF) next Next Next _GDIPlus_Shutdown() Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle, $bitMapdata, $pixelFormat ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ;~ $hBitmap = _GDIPlus_ImageLoadFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;Get $tagGDIPBITMAPDATA structure ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison if ($imgBytes=1) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF04INDEXED) Endif if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) EndIf if ($imgBytes=3) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ;~ $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF32ARGB) endIf If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage ; Draw rectangle on screen. Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = $tLeft $x2 = $tRight $y1 = $tTop $y2 = $tBottom $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_UIA_DrawRect #EndRegion I assume you refer to
  7. There are many ways to set a value. More or less I added some wrappers and alias functions like setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" so no specific reason that certain ways are not there.
  8. Thx. Interesting library. I was working on this https://pdfa.org/resource/pdf-cheat-sheets#basics and understanding more on the PDF 2.0 format. https://pdfa.org/sponsored-standards/ you can download for free latest standard on PDF
  9. The wrapper functions have index or indexrelative property. See examples on how to use. Its based on findall method that returns an array of elements. Just iterate the array and click focus when correct element is found.
  10. Automating a GUI is not easy certainly detecting if an element is not yet visible as its allways unclear how long to wait. Easiest is to make a loop for 10 times with a sleep(250) or something you tweak that test(s) for existence/visibility and if tried for n times then fail.
  11. Probably easier in a more OO style take a look at: * https://github.com/genius257/AutoItObject-Internal/blob/master/README.md * https://github.com/cosote/OOPEAu3/blob/master/README.md And as suggested earlier probably more readable with a main function like below, you only need to read main to understand what your intention is. Amount of errorhandling and how is more complex/clumsy reading in a procedural language or where you check for errors. You could get main more clean of errorhandling if you check for variable value -1 within the function ; ----------------------------------------------- #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- main() func main() local $sSrcFolder=_SelectSrcFolder() local $sDstFolder=_SelectDstFolder() if ($sSrcFolder <> -1) then local $sWavFileData = _CreateArray($sSrcFolder) local $sMasterEdlFile = _DeriveType($sSrcFolder) endif if (($sSrcFolder <> -1) and ($sDstFolder <> -1) and ($sWavFileData <> -1) and ($sMasterEdlFile <> -1)) then _RenameEdls($sSrcFolder, $sDstFolder, $sWavFileData, $sMasterEdlFile) MsgBox($MB_ICONINFORMATION, "Success", "All .edl files have been created successfully.") Else MsgBox($MB_TOPMOST, "Error:", "Something in parameters went wrong!") EndIf EndFunc func selectFolder($sMessage) Local $sFolder = FileSelectFolder($sMessage, "F:\Audio\") If @error Then MsgBox($MB_TOPMOST, "Error:", "No .wav file source folder selected...exiting!") Return -1 Else return $sFolder EndIf EndFunc Func _SelectSrcFolder() return SelectFolder("Select the source .wav data folder...") EndFunc ;==>_SelectSrcFolder Func _SelectDstFolder() return selectFolder("Select the destination folder for the copied-and-renamed .edl data...") EndFunc ;==>_SelectDstFolder Func _CreateArray($sSrcFolder) return _FileListToArray($sSrcFolder, "*.wav", $FLTA_FILES) EndFunc ;==>_CreateArray Func _DeriveType($sSrcFolder) Local $sDeriveType = StringMid($sSrcFolder, 10, 6) Local $sMasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $sDeriveType & ".edl" If Not FileExists($sMasterEdlFile) Then MsgBox($MB_TOPMOST, "Error", "The " & $sDeriveType & ".edl file was not found.") Return -1 Else return $sMasterEdlFile EndIf EndFunc ;==>_DeriveType Func _RenameEdls($sSrcFolder, $sDstFolder, $sWavFileData, $sMasterEdlFile) For $i = 1 To $sWavFileData[0] Local $sWavFileName = $sWavFileData[$i] Local $sWavBaseName = StringTrimRight($sWavFileName, 4) ; ----------------- Local $sNewEdlFile = $sDstFolder & "\" & $sWavBaseName & ".edl" ; ----------------- FileCopy($sMasterEdlFile, $sNewEdlFile, $FC_NOOVERWRITE) Next EndFunc ;==>_RenameEdls
  12. Your topdown approach in itself is fine. But if someone else needs to understand it that person needs to read all code. A short main function calling well named functions gives a quicker understanding for the outsider. Sidenote https://www.autoitscript.com/autoit3/docs/functions/Assign.htm as you solve it already just FYI.
  13. Not sure where you are looping for. You could pass along to functions like you are doing. Using globals is in this case not that bad. You could make a struct but still then it will be global struct. https://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm There are some object oriënted udfs around to make classes.
  14. As its microsoft dynamics I assume you can also use MS powerapps.
  15. Maybe someone will invent multithreading 😉 for this problem
×
×
  • Create New...