Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/20/2021 in Posts

  1. Melba23

    About the arrays

    Just a quiet word in those ears that need to hear - keep it polite please. M23
    3 points
  2. Hiya - and apologies in advance for the thread drift. That brings back a lot of memories. I wrote loads of these in ASM back in the day to "improve" my DOS experience: different error sounds; all sorts of editable keyboard shortcuts; a new editable command console with scrolling of previous commands; intercepting and amending printer commands to get better effects from the limited repertoire available; and even a batch utility suite with expanding message boxes, interactive menus, text in various colours, sounds, etc. It was a lot of fun! M23
    2 points
  3. @JockoDundee Good stuff, GOTO is definitely a bonus that's worth having around even in high-level programming. And I definitely agree that While True is the most redundant thing, I'll definitely be adding a Loop...EndLoop statement with no explicit exit condition @argumentum It is possible to be a good coder even with GOTO, just don't start substituting it with If and you should be fine, GOTO is something which should be used sparingly and only when it makes things better compared to the traditional nested If...Else logic. Some people try to avoid it all cost only because there is a taboo against it. To me it is just another tool in the toolkit which has its uses
    2 points
  4. I'd second junkew's suggestion to get the data from JSON. This UDF is used for the Danp2's WebDriver UDF, so I think it's pretty stable: Here's a brief example: (Note: your JSON file is huge, it may take a long time to load into AutoIT. I gave up after 20 seconds, but I use a relic) #include <json.au3> Func Main() ; ... Local $sFileContents = FileRead("export-2021-01-10T07_51_53.836Z.json") ; Load the JSON into AutoIt Local $oJson = Json_Decode($sFileContents) If @error Then Exit ConsoleWrite("Json_Decode Error: " & @error & @CRLF) Local $sValue For $i=0 To 5 ; Get the value of the ID at item $i $sValue = Json_Get($oJson, "[" & $i & "][ID]") If @error Then Exit ConsoleWrite("Json_Get[" & $i & "] Error: " & @error & @CRLF) ConsoleWrite("ID: " & $sValue & @CRLF) Next ; ... EndFunc
    1 point
  5. #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #include <Misc.au3> #include <WinAPIHObj.au3> #include <File.au3> #include "AutoYOLO3.au3" #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $nPic = 1 Global $nWin = "" Global $aFacesDB[100][142] $nWin = win_select($nWin) $hWnd = WinGetHandle($nWin) WinActivate($hWnd) WinSetState($hWnd, "", @SW_SHOWNA) Global $aPos = WinGetPos($hWnd) Global $hHBmp = _ScreenCapture_CaptureWnd("", $hWnd, $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3]) Global $g_hGUI = GUICreate("YOLO - CAPTURE SCREEN LIVE", $aPos[2], $aPos[3], -1, -1) GUISetState(@SW_SHOWNA, $g_hGUI) ;@SW_SHOWNA _GDIPlus_Startup() Global $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) Global $dir = @ScriptDir & "\ImageCrop_" & @MDAY & "_" & @MON & "_" & @YEAR If Not FileExists($dir) Then MsgBox(0, "Folder creation ","ImageCrop folder does not exist, creating ...", 3) ; El mensaje está 3 segundos. DirCreate($dir) EndIf Global $dir_train = @ScriptDir & "\Train_dataset_" & @MDAY & "_" & @MON & "_" & @YEAR If Not FileExists($dir_train) Then MsgBox(0, "Folder creation ","The train_dataset folder does not exist, creating ...", 3) ; El mensaje está 3 segundos. DirCreate($dir_train) EndIf general_refresh() _GDIPlus_Shutdown() ;~ ============================================================================================================================================ Func general_refresh() Local $tDelta = TimerInit() Do If TimerDiff($tDelta) >= 67 Then ; => 67=30 FPS; 32=60 FPS $tDelta = TimerInit() RefreshImage() ConsoleWrite(TimerDiff($tDelta) & @CRLF) ;~ OnAutoItExitRegister("CleanupResources") EndIf Until GUIGetMsg() == $GUI_EVENT_CLOSE EndFunc Func RefreshImage() $hWnd = WinGetHandle($nWin) WinSetState($hWnd, "", @SW_SHOWNA) Local $aPos = WinGetPos($hWnd) Local $sFilePath Local $sDestination = @ScriptDir & "\face_detected_1.bmp" Local $aClientSize = WinGetClientSize($hWnd) Local $iPicW=$aClientSize[0] Local $iPicH=$aClientSize[1] Local $hHBmp = _ScreenCapture_CaptureWnd("", $hWnd, $aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3]) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) Local $rG = _GDIPlus_GraphicsDrawImage($g_hGraphics, $hBitmap, 0, 0) ;~ ========================================================================================================================== ;~ Resize square image for intro in objetcs detector Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap) Local $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $sFactor = 1 If $iWidth > $iPicW Then $sFactor = $iPicW / $iWidth EndIf If $iHeight > $iPicH And ($iHeight * $sFactor) > $iPicH Then $sFactor = $iPicH / $iHeight EndIf $iHeight = $iHeight * $sFactor $iWidth = $iWidth * $sFactor $hResizedImage = _GDIPlus_ImageResize($hBitmap, $iWidth, $iHeight) ;~ _GDIPlus_BitmapDispose($hBitmap) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResizedImage, 0x00000000) ;~ ====================objetcs detector====================================================================================================== Global $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP) ;~ _ArrayDisplay($aRes) If $aRes[0][0] <> 0 Then If @error Then Local $iErr = @error Local $asDllErrors[6] = ["No error", "unable to use the DLL file", "unknown ""return type""", """function"" not found in the DLL file", "bad number of parameters", "bad parameter"] If $iErr < 6 Then MsgBox(32, @ScriptName, "DLL Error, " & $asDllErrors[$iErr]) Else MsgBox(32, @ScriptName, "DLL Error, " & _AutoYolo3_GetLastError()) EndIf ElseIf _AutoYolo3_GetLastError() <> "" Then MsgBox(32, @ScriptName, _AutoYolo3_GetLastError()) Else ;nice thick green boxes Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2, 2) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Calibri") Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 0) Local $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20) ;~ Local $hBrushBack = _GDIPlus_BrushCreateSolid(0x7FFFFFFF) ;color format AARRGGBB (hex) ;~ $hGraphics = _GDIPlus_ImageGetGraphicsContext($hHBmp) ;~ _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) For $i = 1 To $aRes[0][0] $sTempImg = $dir & "\face_" & @HOUR & "_" & @MIN & "_" & @SEC & "-" & $aRes[$i][0] & ".jpg" $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $aRes[$i][2], $aRes[$i][3] , $aRes[$i][4], $aRes[$i][5], $GDIP_PXF24RGB) _GDIPlus_ImageSaveToFile($hClone, $sTempImg) _GDIPlus_ImageDispose($hClone) _WinAPI_DeleteObject($hBitmap) ; Draw a frame around the object _GDIPlus_GraphicsDrawRect($g_hGraphics, $aRes[$i][2], $aRes[$i][3] , ($aRes[$i][4] - $aRes[$i][2]), ($aRes[$i][5] - $aRes[$i][3]) , $hPen) ; Label it $sLabel = $aRes[$i][0] & " " & StringLeft($aRes[$i][1], 6) $tLayout = _GDIPlus_RectFCreate($aRes[$i][2] , $aRes[$i][3] , 200, 20) ;~ $iBackLen = 0 ;~ If (StringLen($sLabel) * 8) > $iBackLen Then ;~ $iBackLen = StringLen($sLabel) * 8 ;~ EndIf ;~ _GDIPlus_GraphicsFillRect($hGraphics, $aRes[$i][2] , $aRes[$i][3], $iBackLen, 20, $hBrushBack) ;~ _ GDIPlus_GraphicsDrawStringEx($g_hGraphics, $sLabel, $hFont, $tLayout, $hFormat, $hBrush) Next EndIf ;~ $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp, 0x00000000) ;~ GUICtrlSendMsg($g_hGUI , $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP) _GDIPlus_PenDispose($hPen) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) ;~ _GDIPlus_ImageDispose($hClone) ;~ _GDIPlus_BrushDispose($hBrush) ;~ _GDIPlus_BrushDispose($hBrushBack) _GDIPlus_GraphicsDispose($g_hGraphics) EndIf ;~ ================================================================================================================================ EndFunc ;==>RefreshImage Func win_select($nWin) Local $stPoint = DllStructCreate($tagPOINT), $aPos, $hControl, $hWin, $aLastPos[2] = [-1, -1], $sLastStr = '', $sStr TrayTip ("YOLO - CAPTURE SCREEN LIVE", "Select the window to detect", 5) While Not _IsPressed('01') ;Right mouse button $aPos = MouseGetPos() If $aPos[0] <> $aLastPos[0] Or $aPos[1] <> $aLastPos[1] Then DllStructSetData($stPoint, 1, $aPos[0]) DllStructSetData($stPoint, 2, $aPos[1]) $hControl = _WinAPI_WindowFromPoint($stPoint) $hWin = _WinAPI_GetAncestor($hControl, 2) $sStr = 'Window at ' & $aPos[0] & ',' & $aPos[1] & ': "' & WinGetTitle($hWin) & '"' If $sLastStr <> $sStr Then ToolTip($sStr, $aPos[0] + 10, $aPos[1] + 20) $sLastStr = $sStr EndIf $aLastPos = $aPos EndIf Sleep(15) WEnd ToolTip("") #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Cancel, Try Again, Continue, Icon=Info If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(70,"YOLO - CAPTURE SCREEN LIVE","La ventana seleccionada es " & WinGetTitle($hWin)) Select Case $iMsgBoxAnswer = 2 ;Cancel Case $iMsgBoxAnswer = 10 ;Try Again win_select($nWin) Case $iMsgBoxAnswer = 11 ;Continue #EndRegion --- CodeWizard generated code End --- EndSelect Return WinGetTitle($hWin) EndFunc ;==>win_select Hello, my apologies for not respecting the format of the publications, regarding FaceDetection.au3 if it corresponds to the publication of https://autoit.de/thread/86499-facedetection-udf/ in this case that library is not used but The Yolov3 model also works as in this case, since the root to make the detection is the same, the only thing that changes the detector. I republish my code with the required libraries. Dependency folder structure to run script 1 - AUTOIT_PUBLICATION_YOLO_v1.0.au3 2 - autoyolo.dll 3 - AutoYOLO3.au3 4 - opencv_videoio_ffmpeg430_64.dll 5 - opencv_world430.dll 6 - opencv_world430d.dll The requirements are those shown by smartee, to which I thank for the excellent contribution. https://www.autoitscript.com/forum/topic/202987-real-time-object-detection-using-yolov3-wrapper AUTOIT_PUBLICATION_YOLO_v1.0.au3
    1 point
  6. Nine

    confused by WinGetTitle

    I have asked the devs to look into it...before opening a ticket.
    1 point
  7. Nine

    confused by WinGetTitle

    I believe there is bug with WinGetTitle under Win10 using parameter $hWnd. If you replace $hWnd with "foo", it works. If you use "[CLASS:MyWndMsg]", it works. If you do a WinList(), it will appear in the list. I don't see how it cannot be a bug... Edit : tested on beta still same bug.
    1 point
  8. It's likely the FaceDetection UDF eukalyptus posted on the german autoit forums. https://autoit.de/thread/86499-facedetection-udf/
    1 point
  9. @CYCho Unsure why this is occurring, but it seems like the call to BinaryToString isn't needed. I'll include the change in the next update.
    1 point
  10. Nine

    About the arrays

    A patch has been sent by the devs for approval. If accepted, comparing $b = $a will return True because memory address would be the same. But comparing $c = $a will return False as it would imply to compare internal values of the array which would take too much time. And the use of == for any comparaison involving arrays will return False.
    1 point
  11. Nine

    NC wrapper problem

    1. I do not know why because you did not give anything to work with. I am using this method for many purposes and it is working fine to send multiple commands one after the other. 2. I use this form of communication with the DOS console as it is a persistent (convo) approach, instead of launching multiple cmd.exe repeatedly. Also remember that the form of Run(@comspec & " /c someapps.exe") is not always required. You can run most exe with Run("someapps.exe") directly without the need of cmd.exe. But use whatever form you feel confortable with. As long as it working...
    1 point
  12. New version uploaded v1.1.2 Fixed an error in the $__HTTPAPI_gtagHTTP_BYTE_RANGE structure definition. (unit64 -> uint64)
    1 point
  13. The ‘idea’ is indispensable; stop doing this, do something else instead. As far as computers are themselves concerned, it’s all they know, JMP here, JMP there, oh was that actually a return from whence I sprung? They could care less! Of course, because of our limited cognitive capacity, it is much easier for humans to deal with symmetrical constructs, and I couldn’t agree more. I only think of using GOTOs wistfully, when contemplating creating some state variable to back out of some nested mess from hell. And yes, it’s usually better to just rewrite the mess. Regardless, the GOTO is just a tool, kinda like a sweet pair of bolt-cutters; sure you never start a project thinking “then I’ll use those big-ass bolt cutters...”, but sometimes there’s just nothing better. IMO, what’s not a great idea is: While True WEnd which, despite always starting out with an actual condition, will usually end-up with the condition in the body. Mostly because you can’t assign and test in the same statement. Fwiw, I often code it like: Do Until False just because it looks better at the top
    1 point
  14. Thank you @Davidowicza I didn't realise that you sent a similar solution with Send("1") Throwing the unset should always be the very 1st instruction in the function (and resetting it should be the last one) to avoid several calls to the HotkeySet function. I like to compare this precaution to a similar one when we use _IsPressed : If _IsPressed("01", $hDll) Then While _IsPressed("01", $hDll) Sleep(10) Wend ... Reviewing some old scripts, I realise that sometimes I used both ways in the same HotkeySet function. I don't remember why I did it like that in the script below, maybe because the unsetting wasn't the 1st instruction : HotKeySet("{NUMPAD8}", "_8_Tab_Prec") ... Func _8_Tab_Prec() If WinActive(" - Opera") Then HotKeySet("{NUMPAD8}") ; désactiver Hotkey 8 While _IsPressed("68", $hDll) ; 68 = touche 8 du clavier numérique Sleep(10) Wend ... HotKeySet("{NUMPAD8}", "_8_Tab_Prec") ; réactiver Hotkey 8 EndIf EndFunc ; ==> _8_Tab_Prec
    1 point
  15. Nine

    NC wrapper problem

    There is a number of ways to interact with DOS console. In your case, I believe you should enter in a convo mode. Here how you would do it : ;#AutoIt3Wrapper_Change2CUI=y #include <WinAPIConv.au3> #include <Constants.au3> Opt("MustDeclareVars", 1) Const $sPath = "C:\Users\Rob99\Documents\PROGRAMMAZIONE\AUTOIT\GUI_NJ_MT4" Local $iPID = Run(@ComSpec, "", @SW_SHOW, $STDIN_CHILD+$STDERR_MERGED) ProcessWait($iPID) MsgBox ($MB_SYSTEMMODAL,"",ReadStream ($iPID)) StdinWrite ($iPID, "cd " & $sPath & @CRLF) MsgBox ($MB_SYSTEMMODAL,"",ReadStream ($iPID)) StdinWrite ($iPID, "nc64.exe -c 127.0.0.1 23457" & @CRLF) MsgBox ($MB_SYSTEMMODAL,"",ReadStream ($iPID)) Local $sRep While True $sRep = InputBox("Convo with DOS console", "Enter DOS command :", "", "", 500) If @error Then ExitLoop StdinWrite ($iPID, $sRep & @CRLF) MsgBox ($MB_SYSTEMMODAL,"", ReadStream($iPID)) WEnd Func ReadStream ($iPID, $iDelay = 300) Local $vData, $sStream Do Sleep ($iDelay) $vData = StdoutRead($iPID) If @error Then StdioClose($iPID) ProcessClose($iPID) Exit ConsoleWrite("[ERROR] reading child Stream" & @CRLF) EndIf ; ConsoleWrite($vData & @CRLF) $sStream &= $vData Until $vData = "" Return _WinAPI_OemToChar ($sStream) EndFunc I hard coded the first 2 commands, so you understand how this snippet is working...Enjoy !
    1 point
  16. The variable has simply been renamed in the GDIPlus UDF, so look at the GDIPlus startup function for a variable similar in name. I am not currently in a position to check, but it's something like $g__hGDIPlusDll*. * It's $__g_hGDIPDll
    1 point
  17. I don't wanna fight y'all but if I have to I will. Now leave all this GOTO/GOSUB alone. We're using functions !
    0 points
×
×
  • Create New...