-
Posts
3,024 -
Joined
-
Last visited
-
Days Won
12
junkew's Achievements
-
Global to Local Variable Issue
junkew replied to mr-es335's topic in AutoIt General Help and Support
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 -
Global to Local Variable Issue
junkew replied to mr-es335's topic in AutoIt General Help and Support
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. -
Global to Local Variable Issue
junkew replied to mr-es335's topic in AutoIt General Help and Support
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. -
Ways to click something on a website
junkew replied to hennenzac's topic in AutoIt General Help and Support
As its microsoft dynamics I assume you can also use MS powerapps. -
Loop over 1M numbers fails on 9964th iteration
junkew replied to Hashim's topic in AutoIt General Help and Support
Maybe someone will invent multithreading 😉 for this problem -
Loop over 1M numbers fails on 9964th iteration
junkew replied to Hashim's topic in AutoIt General Help and Support
Did you try to create the 1 million screenshots and then run 10 au3 exe files to analyse 100.000 bitmaps? In theory it can be ten times faster. -
ioa747 reacted to a post in a topic: Loop over 1M numbers fails on 9964th iteration
-
Hashim reacted to a post in a topic: Loop over 1M numbers fails on 9964th iteration
-
Loop over 1M numbers fails on 9964th iteration
junkew replied to Hashim's topic in AutoIt General Help and Support
Check the findbmp code func GetImage on lockbits _GDIPlus_BitmapLockBits and search the forum on bitblt and lockbits. Probably (much) faster then getting the color per pixel with _GDIPlus_BitmapGetPixel($hBitmap, $x, $y) And rotating can help: Function _GDIPlus_ImageRotateFlip as you then have directly the pixels as sequence instead of calculating x,y and iterating x, y Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle ; 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) 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=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) Else $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 -
Hashim reacted to a post in a topic: Loop over 1M numbers fails on 9964th iteration
-
Loop over 1M numbers fails on 9964th iteration
junkew replied to Hashim's topic in AutoIt General Help and Support
Wouldn't it be easier to see if it can be read by uiautomation or other accessibility tools. try inspect.exe or simplespy (see faq in signature) It seems to be a certain Delphi version that the tool.exe was build in (https://www.embarcadero.com/products/delphi/starter) This imagerecognition is probably much faster in Delphi or C# I remembered I build this 15 years ago 😉 for a similar purpose. And for fun some reference on analog digits on screen for having fun to recognize with pixel checking 😉 #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Dim $ws[12] = [0, 0, 10, -7, 50, -7, 60, 0, 50, 7, 10, 7] ;Koordinaten Polygonzug: von links nach rechts WAAGRECHTER Balken, von rechts nach links SENKRECHTER Balken Dim $ziffer[10] = [239, 10, 118, 94, 154, 220, 253, 14, 254, 222] ;alle gesetzten bits des Indexes in der 7-segmentanzeige ergeben die Ziffer Dim $balkenpos[8] = [0, "60.0", "0.0", "60.60", "0.60", "0.60", "0.120", "0.0"] ;position der Leuchtbalken der 7-Segmentanzeige innerhalb der Ziffer Dim $p[7][2] ;nimmt die polygonzug-koordinaten zum Zeichnen auf $p[0][0] = 6 ;6 Punkte im Polygonzug _GDIPlus_Startup() Global $hgui = GUICreate('Uhr', 620, 175, -1, -1, $WS_POPUP) ;GUI erstellen ohne Rahmen Global $hWnd = WinGetHandle($hgui) ;Handle holen Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) ;"Leinwand" erstellen, auf der gezeichnet werden kann GUICtrlCreateLabel("", 0, 0, 620, 175, Default, $GUI_WS_EX_PARENTDRAG) ;verschieben des Fensters möglich machen durch 2. Fenster GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ;das 2. Fenster transparent machen GUISetBkColor(0x000000) ;Hintergrund der GUI schwarz GUISetState() ;GUI anzeigen AdlibRegister("_time", 1000) ;jede Zehntelsekunde ein Refresh der Zeitanzeige Do ;Endlosschleife, solange bis.. Until GUIGetMsg() = -3 ;..ESC gedrückt wird _GDIPlus_GraphicsDispose($hGraphic) ;freigeben _GDIPlus_Shutdown() Func _time() ;Uhrzeit anzeigen :o) For $k = 1 To 6 ;die 6 Ziffern der Uhrzeit $setbits = $ziffer[StringMid(String(@HOUR & @MIN & @SEC), $k, 1)] ;gesetzte Bits in der siebensegmentanzeige anhand der Ziffer in der Uhrzeit holen For $bitnr = 7 To 1 Step -1 ;alle Bits durchlaufen _drawpolygon(BitAND($setbits, 128), $k * 100 - 80 + ($k = 1 Or $k = 3 Or $k = 5) * 20, $bitnr) ;parameter: bit gesetzt ja/nein, position der gesamten ziffer,nummer des bits(gerade=waagrechter balken, ungerade=senkrechter balken) $setbits = BitShift($setbits, -1) ;nächstes Bit holen Next Next $brush = _GDIPlus_BrushCreateSolid(0xFF440000 + (@SEC / 2 = Int(@SEC / 2)) * 0xBB0000) ;Pinsel erstellen, wenn Ziffer gerade, dann farbig, ansonsten schwarz _GDIPlus_GraphicsFillEllipse($hGraphic, 202, 55, 15, 15, $brush) ;Punkte zeichnen _GDIPlus_GraphicsFillEllipse($hGraphic, 402, 55, 15, 15, $brush) _GDIPlus_GraphicsFillEllipse($hGraphic, 202, 105, 15, 15, $brush) _GDIPlus_GraphicsFillEllipse($hGraphic, 402, 105, 15, 15, $brush) _GDIPlus_BrushDispose($brush) ;Pinsel auflösen EndFunc ;==>_time Func _drawpolygon($bit, $xpos, $bitnr) ;zeichnet einen polygonzug ("Balken") an die entsprechende Position $split = StringSplit($balkenpos[$bitnr], ".", 3) ;x- und y-koordinaten des Balkens innerhalb der Ziffer holen $b = (($bitnr / 2) = Int($bitnr / 2)) ;$bit gerade => $b = true => Balken waagrecht, ansonsten Balken senkrecht $step = -1 + 2 * $b ;schrittweite durch das $WS-Array For $i = 11 - 11 * $b To 11 * $b Step 2 * $step ;array mit waagrechten (bit=gerade) oder (Bit=ungerade) senkrechten Balken füllen $r = Int(Abs((11 * (Not ($b))) - $i) / 2) + 1 ;abhängig von der Reihenfolge, egal ob $i von 0 bis 11 oder von 11 bis 0, $r muss immer 1,2,3,4,5,6 $p[$r][0] = $ws[$i] + $split[0] + $xpos ;x- und $p[$r][1] = $ws[$i + $step] + $split[1] + 30 ;y-position in das polygonarray schreiben Next $brush = _GDIPlus_BrushCreateSolid(0xFF440000 + ($bit <> 0) * 0xBB0000) ;wenn bit gesetzt, dann farbig, ansonsten schwarz _GDIPlus_GraphicsFillPolygon($hGraphic, $p, $brush) ;Balken zeichnen _GDIPlus_BrushDispose($brush) EndFunc ;==>_drawpolygon -
Get data from an object without knowing it's structure?
junkew replied to VAN0's topic in AutoIt General Help and Support
Not sure if typelibinspector still works for ole objects. And there was a debugger in the past that partially could do that but real reflection on all variables is not possible. -
Get data from an object without knowing it's structure?
junkew replied to VAN0's topic in AutoIt General Help and Support
Would eval function help? In which circumstance you wouldnt know the objectstructure or subfields. What you refer as "cheating" looks to me reuse what you know from the query. In general there is no reflection mechanism on objects. -
Help for a simple script needed
junkew replied to AlphaUMi's topic in AutoIt General Help and Support
https://www.autoitscript.com/autoit3/docs/functions/RegDelete.htm https://www.autoitscript.com/autoit3/docs/functions/Run.htm https://www.autoitscript.com/autoit3/docs/functions.htm Just read the examples and try -
If you can determine your element with inspect, uiaspy or simplespy you can see which properties the element has. If you can see unique properties you can filter it. If not you have the fallback on tricks like find nth element after a unique element.
-
Netol reacted to a post in a topic: code to obtain the tip-url chrome like the attached image
-
code to obtain the tip-url chrome like the attached image
junkew replied to Netol's topic in AutoIt General Help and Support
Do you have more information on how you search and learn in the forum? -
Netol reacted to a post in a topic: code to obtain the tip-url chrome like the attached image
-
code to obtain the tip-url chrome like the attached image
junkew replied to Netol's topic in AutoIt General Help and Support
Did you try simplespy? -
junkew reacted to a post in a topic: Autoit & graphedit
-
code to obtain the tip-url chrome like the attached image
junkew replied to Netol's topic in AutoIt General Help and Support
You should basically try what is in faq 31 and 40