Jump to content

lamnhan066

Active Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by lamnhan066

  1. Hi @tobius, Those are the right parameters in your case, but I think that function has issues because its body doesn't use those parameters (I'm not sure about this because it is quite a long time but I still have a quick rewrite of the function at the end of this post). This parameter is also known as color in bounds or color variation of each pixel, it has a value between 0 and 255 (usually between 15 and 30 is used). When the value is 0, it means that all pixel colors must be the same between the finding image and the result image. This is the max number of results. It will increase the performance if you know the max number of results that you need. Here is a quick rewrite of that function (without testing). Please try it and let me know the result: Func _BmpImgSearch($SourceBmp, $FindBmp, $x = 0, $y = 0, $iWidth = -1, $iHeight = -1, $Tolerance = 15, $Transparency = "", $MaxImg = 1000) Local $SourceBitmap = _GDIPlus_BitmapCreateFromFile($SourceBmp) If @error Then Return SetError(1, 0, 0) Local $Right = $iWidth + $x If $iWidth = -1 Or $iWidth = Default Then $Right = _GDIPlus_ImageGetWidth($SourceBitmap) + $x Local $Bottom = $iHeight + $y If $iHeight = -1 Or $iHeight = Default Then $Bottom = _GDIPlus_ImageGetHeight($SourceBitmap) + $y Local $pos = __ImgSearch($x, $y, $Right, $Bottom, $FindBmp, $SourceBitmap, $Tolerance, $Transparency, $MaxImg) Return SetError(@error, 0, $pos) EndFunc ;==>_BmpImgSearch
  2. Hi @tobius, I wrote these UDF function headers in Vietnamese, so I think your computer shows weird letters because it doesn't support Vietnamese. I will translate it into English when I have time. And yes, you are using the right function and you don't have to fill in all the parameters if you don't need to. For instance: #include <Array.au3> #include "HandleImgSearch.au3" Local $Find_this_image = @ScriptDir & '\folder_symbol.bmp' Local $In_this_image = @ScriptDir & '\desktop.bmp' Local $aResult = _BmpImgSearch($In_this_image, $Find_this_image) _ArrayDisplay($aResult) Since AutoIt doesn't support named parameters, if you want to modify $Tolerance you can fill default values in all parameters before it like below: #include <Array.au3> #include "HandleImgSearch.au3" Local $Find_this_image = @ScriptDir & '\folder_symbol.bmp' Local $In_this_image = @ScriptDir & '\desktop.bmp' Local $aResult = _BmpImgSearch($In_this_image, $Find_this_image, 0, 0, -1, -1, 30) _ArrayDisplay($aResult)
  3. Hi, Here are my thoughts about your opinions: 1. You're right, this is a function that I worte before anything else so I didn't take care it enough because it's just an internal function, most users don't need to take care it much. 2. Because the ImageSearch DLL uses hBitmap for searching, but I want the users just need to input the file path so I have to convert it to hBitmap. 3. Most of AutoIt users do not so familiar to the Struct, so you can make them harder to understand the code. 4. Mình đã đọc và cảm ơn bạn đã góp ý nhé, UDF này mình viết từ khoảng thời gian khá sớm sau khi tìm hiểu về AutoIt và không có UDF nào đáp ứng được nhu cầu của mình về độ linh động và không cần đính kèm DLL khi build. I also moved the BinaryCall.au3, MemoryDll.au3 code to separated file in the new version. My work does not relate to AutoIt after I finished this UDF so I don't have much time to improve or optimize the code. I have created the new version here, you can create the Issue, PR for your optimization or new features. Thank you and I very appreciate your suggestion.
  4. Whatever the color is (except alpha color), you just need to add it to the $Transparency parameter like this example:
  5. I've implemented this feature to the code but I haven't made it public yet because I don't have time to test it completely right now. You can access the repo here: https://github.com/lamnhan066/HandleImgSearch/tree/add-transparency You can add 0x000000 (means Black) or 0xFFFFFF (means White) or any color that you want to ignore to the `$Transparency` parameter. You can check it out and give me the feed back if possible so I can merge it to the main repo. Thank you!
  6. It is so easy to make mistakes if you need to capture in a loop and analyze it with multiple functions in 1 capture, so I create build-in _Global functions to mainly manage memory to reduce memory leaks. I think _Static is not enough meaning because it already uses the global variable to manage the captured photo and uses it across other _Global functions.
  7. The _HandleImgSearch doesn't depend on where the window is if you're using $device as a handle of that window, it just capture that specific window and search $bmpLocal inside it. If you want to search your whole screen, you can try using this code: $aCords = _HandleImgSearch("", $bmpLocal, $startX, $startY, $startWidth, $startHeight, 70, 20) When you let the handle = "", the UDF will capture your whole screen or your specific area if you want to and search inside it.
  8. In your code, I see that you just call `_TestHandle` instead of calling both `_TestHandle` and `_TestHandle2`, so that the STEP 2 doesn't work because it isn't called.
  9. I'm only bring the best way to get the results because the UDF can return multiple positions, so you can modify the UDF yourself to get the result that you want to or just write a function to parse the results, the second way may be easier to do because it won't break the core function of the UDF.
  10. How can you do a specific area searching when you don't know these coordinates? Let's look at this function: _HandleImgSearch($hwnd, $bmpLocal, $x = 0, $y = 0, $iWidth = -1, $iHeight = -1, $Tolerance = 15, $MaxImg = 1000) You have to know at least one parameter in $x, $y, $iWidth, $iHeight to search for an area. Let's say you want to search in area [50, 60, 800, 600], so the function will look like: _HandleImgSearch($hwnd, $bmpLocal, 50, 60, 800, 600) and the result is `[1, [10, 20, 50, 50]]` which means it has 1 matched possition at [$x, $y, $width, $height] = [10, 20, 50, 50]. If you want to get the relative to your $hwnd coordinates then you need to add [10 + 50, 20 + 60] = [60, 80]. In addition, if you want to get the relative to your current whole screen coordinates, you need to use WinGetPos to get your current $hwnd coordinates and add the [x, y] coordinates to it like the above.
  11. It's a coordinate (left, top) of your search image in the search area.
  12. When you create new Form Studio, the script auto create new file named `<name>.isf`, it will auto #include to your main script and open in new form editor. When you create a new control, you need to add the handle name to it which is also the variable name that you can to use anywhere else in your code. For more details, you can open the `<name>.isf` file in your editor to see the source code (it's just AutoIt code and the config created by Form Studio) or using the Generate button to generate the code then you can understand when you look at it.
  13. In the current version, the result will relate to the search area, you just need to add (x, y) of the result to your search area coordinates to get the results you need. For instance, you need to search in (30, 40, 300, 300) coordinates and get a result (10, 15) then the result you need is (30 + 10, 40 + 15).
  14. I found DPI settings in File > Settings > Display > Monitor and windows > Enable High DPI Mode. If your window still have issue after save and close, try reopening that window and press Reset main window view. Hope it help!
  15. It's because of your internet connection (This site may be blocked by your internet provider). You should try to change your dns first to open this site, if not then pm me I will send you directly. Here is the download url from that site: https://www.isnetwork.at/phocadownload/138/
  16. I have no English version now. Sorry about that. I will add it later when I have free time and update on this thread. Some default parameters (You can ask me here if you have another thing make you confused): $hwnd: Handle of window you want to find in. If $Handle = "" then it will find images in your current screen. $bmpLocal: Path of local image you want to find. $x, $y, $iWidth, $iHeight: Area of $hwnd image you want to find in. Default values is full image. $MaxImg: Max number of images you want to find (or return). $Tolerance: (0 - 100) This is the variation of color you want to find. This parameter is helpfull when you want to share your app with your friend who use other devices. Some default return values: $aCords[0][0]: Total number of positions found. $aCords[$i][0]: X coordinate of position $i. $aCords[$i][1]: Y cooridinate of position $i. $aCords[$i][2]: Bitmap width of position $i. $aCords[$i][3]: Bitmap height of position $i. The width and height of the bitmap are the same as your finding image. No, it's now not support this. You can use this by add this a function like: ;~ I have not tested this code yet, but you can use something like this Func _HandleMultiImgSearch($hwnd, $ImgsPath, $x = 0, $y = 0, $iWidth = -1, $iHeight = -1, $Tolerance = 15, $MaxImg = 1000) Local ImgsPathArray = StringSplit($ImgsPath, "|", 2) ;$ImgsPath = 'Path1|Path2|...|PathN' Local $Results For ImgPath in ImgsPathArray $Results = _ArrayAdd($Result, _HandleImgSearch($hwnd, $ImgPath, $x, $y, $iWidth, $iHeight, $Tolerance, $MaxImg)) Next Return $Results EndFunc ;~ Using this func Local $ImgsPath = 'a.png|b.png|c.png' Local $Results = _HandleMultiImgSearch($hwnd, $ImgsPath) ConsoleWrite("> Total of finding images: " & Ubound($Results)) Local $count = 0 For $Coords in $Results ;~ An array of positions of each image $count += 1 ConsoleWrite(">> Total of position found of image " & $count & " found: " & Ubound($Coords[0][0])) Next
  17. Nice update! I don't know if I can copy controls between two different forms, and is there a way to load each tab (opening the last project on startup) without activating ISN AutoIt Studio?
  18. Today, I will share my work with image search in inactive windows (windows that run in the background) with tolerances (variations). After a long time of searching and using image search UDF on the internet. I combined all of that with my experienced and created a UDF name HandleImgSearch. I have embedded the .dll file in this script so it doesn't need any external files, just include it and run. However, this UDF uses a pure AutoIT loop to make the multiple positions returned work so it may be slower if you set the $MaxImg to a high number. Some highlights: Very fast with imagesearchdll embedded, no external files required. Tolerances and Max Images are supported. Optimized. Use with a handle or full screen easily. Included global functions, so you can run multiple functions in one capture. Examples used for testing included. Notes: Only used to compile to 32-bit AutoIt version (It can completely run on Windows 64-bit) The image used for searching should be in a "24-bit Bitmap" format. I included the $IsUser32 variable in some places like _GlobalImgInit, _HandleCapture. This variable allowed you to use DllCall with the "PrintWindow" parameter instead of _WinAPI_BitBlt with $SRCCOPY. $IsUser32 = True is useful for the window explorer handle, $IsUser32 = False is useful for the emulator handle (NoxPlayer handle example included). If hwnd parameter equals "", it will use the whole screen instead. Functions: Global Functions: Run multiple functions with one capture. _GlobalImgInit: Initialization variables. _GlobalImgCapture: Capture the handle. _GlobalGetBitmap: Get captured bitmap handle. _GlobalImgSearch: This is the main function of this UDF. _GlobalGetPixel: Get pixel color in the captured image. _GlobalPixelCompare: Compare pixel color with captured image pixel color. Handle Functions: Capture every time. _HandleImgSearch: This is the main function of this UDF. Search for images in the handle of the window with the tolerance and maximum image options. _BmpImgSearch: Search the picture in the picture instead of the handle. _HandleGetPixel: Get pixel in the handle image. _HandlePixelCompare: Compare color with pixel color of handle image. _HandleCapture: Capture handle screen. Source code: v1.0.5 (First release): https://github.com/vnniz/HandleImgSearch/releases/tag/v1.0.5 v2.0.0 (14/04/2023): https://github.com/vnniz/HandleImgSearch/releases/tag/v2.0.0 Thanks to: ImageSearchDLL (Author: kangkeng 2008) MemoryCall (Author: Joachim Bauch) BinaryCall (Author: Ward) GAMERS - Asking for help with ANY kind of game automation is against the forum rules. DON'T DO IT.
  19. Bugs: - Form studio2: All controls in this area will disappear after I click the collapse button - ISN Autoit Studio: The project tree is sometimes unresponsive, I cannot collapse / expand or right-click a folder or a file. It can only work again after I restart the program. Question and Suggest new features: - Have you ever thought about adding version control systems like Git to this project? - Does the editor have line spacing option?
  20. @DocfxitYou need to go to AutoIt path like this first and see what it is
  21. It works pretty well. But sometimes the expand and collapse buttons of Project Tree freeze until I restart the application.
  22. @MattHiggs The things you mentioned above are a very basic function in AutoIt like "Click Func" (use for GUIOnEventMode), " ExtraCode " is explained in its name (The code is written after the control you use, You can use the Generate Code feature to see what's going on when you add code to ExtraCode ). This program is free, so we can't ask the OP to do everything clearly instead of exploring it ourselves. If you have anything you don't know, just ask here and get your answer!
  23. .isf file just a file make by FormStudio2 and include to main .au3 file as an UDF. The line "code=" will not appear in that .isf file unless I generate a code. If I delete that line from .isf file, the compiler run completely without an error. So that I think that error cause by that function (I think this function just use for reducing code generation's time).
  24. I think FormStudio2 should be fixed this This Bug cause by Code Generator Function, Code after generate will save in .isf file with key word "code=" above #ce comment (end of file) and it too long for Au3Stripper to strip if form have a bit complex.
  25. GUISetFont as Extracode just take effect after running app, if I have a feature to set default font name, size I can add new control directly in Form Studio 2 and It take effect immediately (It's faster then changing one by one when a control was added) and It help me easier to create a complex Form with various button, label, inputbox . And Undo/Redo: ... Hope to see it soon Thanks for your answer
×
×
  • Create New...