Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/12/2015 in Posts

  1. Thx for the link and anyway for all your replies, trancexx. The basic reasons that I saw you explaining there, seem to be: "Using dllstructs that way goes directly against the typing paradigm of the language. On top of that dllstruct is not safe type because data is also accessible through pointer." Honestly I don't understand the dangers in either. But that may be because I am only a bad hobby programmer. I mean - no harm meant - who cares about typing paradigms or "safeness of type regarding accessibility through pointer", unless it could be accessed through pointer accidently and then make me loose data or even worse cause my windows system to crash and loose the current windows session (blue screen & loss of currently not saved data). If that is not the case, I don't know what should be "unsafe" about it? What I wonder about is, maybe you and your colleagues speak heavily against its widespread usage, because otherwise it would spread throughout scripts on the net and be a bother to stumble upon / work with and maybe cause uncontrollable side effects like in Terminator, or so. ;-) If this is the case, then just say so and I would understand. Thanks again for your help, in any case. Regards, Stephan
    2 points
  2. kangkeng

    Image Search Library

    Hi Folks, I'm a great fan of AutoIT. While trying to automate data entry into a java applet based ERP, I found that checking for entry error or success is quite a pain using pixelsearch. Instead, check for a data entry "success" or "failed" image is far simpler. This a feature found in AHK, I've cut out the necessary code and compiled it into a DLL, and written a au3 library around it. I've tested it in various XP and W2k3 machines, and it seems to work fine. It's a quick and dirty hack I did to get a job done, so your mileage may vary ImageSearch.zip (84K) Number of downloads:
    1 point
  3. Concerning the discussion in this thread. I'm curious why some people deem using DllStructs for anything other than arguments for DllCall, wrong. If there is some technical reason why it's wrong or foolish or something I sure would like to hear it. In that thread it's mentioned that an ex code dev (probably valik) who was well clued up said it's wrong, and also trancexx who is also clued up and also ex dev mentioned it being a "no no". One thread is linked but no explanation is given, I'd be mighty obliged if anyone has the link to the other discussion. I'd like to point out also that DllStructs are used other than in DllCalls inside some standard UDF's,
    1 point
  4. zxtnt09

    [Solved ]if Problem !!!

    Hi guys, i have an issue ! 1 ) i use that and its fine : if $ok then Opt("GUIOnEventMode",0) else error() endif 2 ) now i want need sleep for 5sec , i was use that but it was make delay and make it back to Opt("GUIOnEventMode",0) !! script for dly i used : if $ok then Opt("GUIOnEventMode",0) Sleep(5000) Opt("GUIOnEventMode",1) else error() endifi don't like that , i want delay run when script was load successfuly , it's meant => 1 ) Time for loading program example: 1 sec 2 ) After 5sec ( or X Sec ) program was loaded => Opt("GUIOnEventMode",1) change. thanks for helping and sorry for my bad english. ========================= Solved By Myself i Should Use That : Func buttonloginclick() Local $username, $password $username = GUICtrlRead($inputusername) If NOT $username Then _showerror("Enter Your Username!", $inputusername) Return False EndIf $password = GUICtrlRead($inputpassword) If NOT $password Then _showerror("Enter Your Password!", $inputpassword) Return False EndIf GUICtrlSetState($inputusername, $gui_disable) GUICtrlSetState($inputpassword, $gui_disable) GUICtrlSetState($buttonlogin, $gui_disable) Local $data, $request $data = "username=" & urlencode($username) $data &= "&password=" & urlencode($password) $request = _httprequest($endpoint_login, "POST", $data) If $debug_mode Then _arraydisplay($request) Local $json = json_decode($request[2]) Local $success = json_get($json, '["success"]') GUICtrlSetState($inputusername, $gui_enable) GUICtrlSetState($inputpassword, $gui_enable) GUICtrlSetState($buttonlogin, $gui_enable) If $success Then Opt("GUIOnEventMode",0) GUICtrlSetState($inputusername, $gui_disable) GUICtrlSetState($inputpassword, $gui_disable) GUICtrlSetData($buttonlogin, "Logout") GUICtrlSetOnEvent($buttonlogin, "Logout") ; i Was Should That :) If $success Then Sleep (5000) Opt("GUIOnEventMode",1) EndIF ; i Was Should That :) togglecontrol(1) Return True Else Local $errorcode = json_get($json, '["data"]') If $errorcode = -1 Then _showerror("Your username or password is incorrect!", $inputusername) Return False Else _showerror("You have already logged in at other device. Please logout first!") Return False EndIf EndIf EndFuncMaybe It was help someone <3
    1 point
  5. czardas

    [Solved ]if Problem !!!

    @Ihab_InjeCtor that code is plain wrong. You cannot create a function with the same name as an existing native function. @zxtnt09 I don't entirely understand the question. Using Sleep() pauses the whole script and that might include whatever is loading. Perhaps if you posted more of your code, it would be easier to see what you are trying to do.
    1 point
  6. Excellent. You nailed it. ...Go away now, I'm starting to like you. Shoo!
    1 point
  7. and without regexp. This is provided this string doesnt have a bunch of bonus pipe characters thrown in. $sString = "|A&| & |B#| & |*C| & |%5|" $i = 1 $sMax = stringinstr($sString , "|" , 0 , -1) Do $sFirst = Stringinstr($sString, "|" , 0 , $i) $i += 1 $sSecond = Stringinstr($sString, "|" , 0 , $i) $i += 1 $sString = stringreplace($sString , stringmid($sString , $sFirst + 1 , $sSecond - $sFirst - 1) , "Alex") Until $sSecond >= $sMax msgbox(0, '' , $sString)
    1 point
  8. I don't think skynet will arise as a result of using DllStruct wrong.
    1 point
  9. or this (last attempt for me) : $sString = "|A| & |B| & |C| & |5|" $sNewString = StringRegExpReplace($sString, "(?<=\|)\h*[^|&]+\h*(?=\|)", "Alex") ConsoleWrite($sNewString & @CRLF)
    1 point
  10. Alex1986, Stop changing the goalposts as the thread progresses! How about this: $sString = "|A&| & |B#| & |*C| & |%5|" $sReplace = "Alex" $sNewString = StringRegExpReplace($sString, "(?U)(^|\s)\|.+\|(\s|$)", " |" & $sReplace & "| ") ConsoleWrite($sNewString & @CRLF)M23
    1 point
  11. Finally, my code is not so bad...
    1 point
  12. I will ignore you previous sarcastic comment and answer this one. Why should I explain when it's obvious? It's like asking me to explain why a hammer shouldn't be used as a saw.
    1 point
  13. Celtic88, Thanks for posting, but given the content of the other thread by this member I do not think he deserves that much help. M23
    1 point
  14. 1 point
  15. @Celtic88. As I said. AutoIt does not support that. I meant that you can use structure to simulate a C variable. so the answer to autocart's asking is not. Saludos
    1 point
  16. Jos

    Mouth on InputBox Edit

    Doesnt _DateTimeFormat() give the requested result? jos
    1 point
  17. I don't remember which line works, but put both in user properties: code.page=65001 output.code.page=65001
    1 point
  18. So this should be better documented in HelpFile . I will do a track ticket but before must change the example of ObjEvent. Thanks. mLipok
    1 point
  19. You need to always know the size of the window and its position and the relative positions of the controls fro the windows position. I just maximize the window to solve this. You'll probably need to check the desktop resolution if its for other computers too. You can imgsearch and pixelgetcolor OCR and pixelchecksums to do most of the rest.
    1 point
  20. Unc3nZureD

    Webcam Detection

    Please use the search button '?do=embed' frameborder='0' data-embedContent>> a little bit modified: MsgBox(0,"", IsWebcamPresent()) Func IsWebcamPresent() $StructName = DllStructCreate("char[1024]") $StructDesc = DllStructCreate("char[1024]") For $i = 0 To 9 $aRslt = DllCall("Avicap32.dll", "bool", "capGetDriverDescription", "dword", $i, "ptr", DllStructGetPtr($StructName), "dword", DllStructGetSize($StructName), "ptr", DllStructGetPtr($StructDesc), "dword", DllStructGetSize($StructDesc)) If Not @error Then If $aRslt[0] Then Return True EndIf Next Return False EndFunc
    1 point
  21. I added this code in _imageSearchArea Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $HBMP = 0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage If IsString($findImage) Then $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage, "ptr", $HBMP) $err = @error Else $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "ptr", $findImage, "ptr", $HBMP) $err = @error EndIf Switch $err Case 1 ConsoleWriteError("unable to use the DLL file" & @CRLF) exit 1 Case 2 ConsoleWriteError('unknown "return type" ' & @CRLF) exit 1 Case 3 ConsoleWriteError('"ImageSearch" not found in DLL' & @CRLF) exit 1 Case 4 ConsoleWriteError('bad number of parameters' & @CRLF) exit 1 Case 5 ConsoleWriteError('bad parameter' & @CRLF) exit 1 EndSwitch ; If error exit If $result[0] = "0" Then Return 0 ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0], "|") $x = Int(Number($array[2])) $y = Int(Number($array[3])) If $resultPosition = 1 Then $x = $x + Int(Number($array[4]) / 2) $y = $y + Int(Number($array[5]) / 2) EndIf Return 1 EndFunc ;==>_ImageSearchArea I down loaded the 64 bit version, and I get the "unable to use the DLL file" error. I thought this might help some to debug. I don't have it working, but I'll try the 32 bit version even though I'm running 64 bit windows 7.
    1 point
  22. Hello and thank you for the tutorial. I have been trying to get this imagesearch function to work for weeks! I took your code and copied it exactly. Then I took ImageSearch.au3, imagesearchdll.dll and my script (Which is a new script file with your code) along with my checkImage.bmp and put them all into my working directory folder. I click the script, I click P and nothing happens but the script no longer runs. I get no error or anything. Did I miss something?
    1 point
  23. I was having trouble like you were having trouble. This topic is very helpful. I was working on this image search for hours and hours and I could not get it to work! I was able to find the droid I was looking for (heh) when I saved the image as a 24-bit BMP rather than 256 or 16-bit. Not sure why this is but I hope that helps someone. If it isn't working for you, try saving the picture as a different bmp file.
    1 point
  24. Hello, i think that there's a typo on your "Example of my script using _ImageSearchArea". With this line : local $search = _ImageSearchArea('check5.bmp', 1, 800, 40, 900, 80, $x, $y, 0)Local $search = _ImageSearch('checkImage.bmp', 0, $x, $y, 0)
    1 point
  25. I think it's fine. I appreciate that I can use that now instead of merging Auto Hot Key/AutoIT type features. I look forward to re-writing some of my mcros to incorporate this and thank you again for the intro into Image search
    1 point
  26. nice work! thx~
    1 point
  27. <Bump> Anyone know the difference in these .dll's?
    1 point
  28. I've used this for automating a daily job at work that refreshes +/- 35 reports daily with each one searching, and it hasn't missed a beat. I'm curious as to the difference in .dll files, compared to the one in the original post from 2008. Here's the two versions: Original ImageSearchDLL.dll 92k 2/28/2008 Your ImageSearchDLL.dll 77k 1/24/2010 Can you (or anyone else) tell me what the differences are?
    1 point
  29. therms

    Access AutoIt

    This is the best thing I've ever seen on the internet. Thanks for this!
    1 point
  30. Zedna

    Image Search Library

    You can make UDF wrapper which will call this search function from DLL in a loop. Everytime it find something you must add found coordinates to output array and shrink search area accordingly.
    1 point
  31. Memories

    Image Search Library

    Hi, nice project! And my first question on this forum. There are some identical images on the screen. _ImageSearchArea returns the coordinates of 1st image it recognizes. Is it possible to get array with all the coordinates of identical images (without dll recompiling if possible ^) )?
    1 point
  32. pezo89

    Image Search Library

    Fixed my issue with Win7 64bit. Thx alot. it works now!
    1 point
  33. rapot

    Image Search Library

    #include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language: English ; Description: Functions that assist with Image Search ; Require that the ImageSearchDLL.dll be loadable ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Description: Find the position of an image on the desktop ; Syntax: _ImageSearchArea, _ImageSearch ; Parameter(s): ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of ; the color to be used as transparency; can be omitted if ; not needed ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify ; a desktop region to search ; ;=============================================================================== Func _ImageSearch($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance,$transparency=0) return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$transparency) EndFunc Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance, $transparency=0) ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom) if not ($transparency = 0) then $findImage = "*" & $transparency & " " & $findImage if $tolerance>0 then $findImage = "*" & $tolerance & " " & $findImage $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage) ; If error exit if $result[0]="0" then return 0 ; Otherwise get the x,y location of the match and the size of the image to ; compute the centre of search $array = StringSplit($result[0],"|") $x=Int(Number($array[2])) $y=Int(Number($array[3])) if $resultPosition=1 then $x=$x + Int(Number($array[4])/2) $y=$y + Int(Number($array[5])/2) endif return 1 EndFunc ;=============================================================================== ; ; Description: Wait for a specified number of seconds for an image to appear ; ; Syntax: _WaitForImageSearch, _WaitForImagesSearch ; Parameter(s): ; $waitSecs - seconds to try and find the image ; $findImage - the image to locate on the desktop ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of ; the color to be used as transparency can be omitted if ; not needed ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$transparency=0) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs sleep(100) $result=_ImageSearch($findImage,$resultPosition,$x, $y,$tolerance,$transparency) if $result > 0 Then return 1 EndIf WEnd return 0 EndFunc ;=============================================================================== ; ; Description: Wait for a specified number of seconds for any of a set of ; images to appear ; ; Syntax: _WaitForImagesSearch ; Parameter(s): ; $waitSecs - seconds to try and find the image ; $findImage - the ARRAY of images to locate on the desktop ; - ARRAY[0] is set to the number of images to loop through ; ARRAY[1] is the first image ; $tolerance - 0 for no tolerance (0-255). Needed when colors of ; image differ from desktop. e.g GIF ; $resultPosition - Set where the returned x,y location of the image is. ; 1 for centre of image, 0 for top left of image ; $x $y - Return the x and y location of the image ; $transparent - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of ; the color to be used as transparent; can be omitted if ; not needed ; ; Return Value(s): On Success - Returns the index of the successful find ; On Failure - Returns 0 ; ; ;=============================================================================== Func _WaitForImagesSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$transparency=0) $waitSecs = $waitSecs * 1000 $startTime=TimerInit() While TimerDiff($startTime) < $waitSecs for $i = 1 to $findImage[0] sleep(100) $result=_ImageSearch($findImage[$i],$resultPosition,$x, $y,$tolerance,$transparency) if $result > 0 Then return $i EndIf Next WEnd return 0 EndFunc ; find recycle bin if it is in the top left corner of screen ; change 2nd argument to 0 to return the top left coord instead $result = _ImageSearchArea("recycle.bmp",1,0,0,200,200,$x1,$y1,0,0x000000) ;perfect black used as transparency if $result=1 Then MouseMove($x1,$y1,3) MsgBox(0,"Found","Found a recycle bin with stuff in top left corner") EndIf line: $result = _ImageSearchArea("recycle.bmp",1,0,0,200,200,$x1,$y1,0,0x000000) ;perfect black used as transparency why it not found "recycle.bmp" (this bmp file have some transparency 0x000000) someone tell me about transparency parameter? recycle.bmp
    1 point
  34. Earthgas

    Image Search Library

    i think this will make GUI window to full screen mode but i need that when i open it it would dissable everithing that is out side of GUI and search,and do things only in GUI forgetting about rest of desktop i fail at explaining
    1 point
  35. Hey, there! First I wanna thank you for porting this function into a dll for usage in AutoIT. Secondly, I want to ask if it would be possible to make it support the transparency option.Working with objects that don't fit well in a rectangle I think that would be a really nice feature! From what I understand, the code placed here to support transparency can treat things on the screen as being transparent.I was looking for something that treats part of the image in the file as being transparent. Or maybe I'm just confused
    1 point
  36. therms

    Image Search Library

    Can anyone tell me if this is working for them on Vista? I cannot get it to work at all. Of course the demo script doesn't work because of Vista's changed icons, but even replacing the included sample images with my own, the function returns a 0 every time.
    1 point
  37. ygm

    Image Search Library

    How to use this on a windows? So not on the desktop, but in the windows file browser or something like that.
    1 point
  38. Zedna

    Image Search Library

    It would be absolutelly awesome to have new optional parameter hWnd as it is in AutoIt's PixelSearch in latest 3.2.12 version. In this case search would be done only inside given window/control (and not on whole desktop.). This way you could search for image also on hidden/minimized/non active windows. and search could be narrowed on desired control so it will be much faster. I need such functionality in my current project. This could be very simple to implement: Just use GetDC($hWnd) instead of GetDC(0)
    1 point
  39. bf2forlife

    Image Search Library

    How this _ImageSearchArea works? $x1=143 $y1=200 _ImageSearchArea("lol.bmp",1,0,0,473,33,$x1,$y1,0) I wanna search image in area size of 473,33 pixels and is in position 143, 200. But it doesnt work. So whats the problem? EDIT: Fixed some of the code but still dont work
    1 point
  40. ssjdennis

    Image Search Library

    It was a example, but can you help me???
    1 point
  41. Kickassjoe

    Image Search Library

    When I first started using AutoIt, this is the type of thing I was looking for, looks nice
    1 point
  42. JRSmile

    Image Search Library

    This is great, dude. Already included it into my projects. VERY MUCH THX
    1 point
  43. kangkeng

    Image Search Library

    Haven't tried out your code, but I don't think you should have the While 1 and WEnd in the Func, unless you want to repeatedly show the message box.
    1 point
  44. ssjdennis

    Image Search Library

    I have a problem. my codes will not work. #include <ImageSearch.au3> $x1=0 $y1=0 HotKeySet( "+s", "Start" ) HotKeySet( "+e", "end" ) While 1 Sleep (100) WEnd Func Start() While 1 $result = _ImageSearch("recycle2.bmp",1,$x1,$y1,0) if $result=1 Then MouseMove($x1,$y1,3) MsgBox(0,"Found","Found a empty recycle bin here...") EndIf WEnd EndFunc Func End() Exit EndFunc and #include <ImageSearch.au3> $x1=0 $y1=0 HotKeySet( "+s", "Start" ) HotKeySet( "+e", "end" ) While 1 Sleep (100) WEnd Func Start() While 1 $result = _ImageSearchArea("recycle2.bmp",1,0,0,200,200,$x1,$y1,0) if $result=1 Then MouseMove($x1,$y1,3) MsgBox(0,"Found","Found a empty recycle bin in top left corner") EndIf WEnd EndFunc Func End() Exit EndFunc but, this code working. #include <ImageSearch.au3> $x1=0 $y1=0 $result = _ImageSearch("recycle.bmp",1,$x1,$y1,0) if $result=1 Then MouseMove($x1,$y1,3) MsgBox(0,"Found","Found a recycle bin with stuff here...") EndIf $result = _ImageSearchArea("recycle.bmp",1,0,0,200,200,$x1,$y1,0) if $result=1 Then MouseMove($x1,$y1,3) MsgBox(0,"Found","Found a recycle bin with stuff in top left corner") EndIf Plz help me.
    1 point
  45. 1 point
  46. kangkeng

    Image Search Library

    See here... http://www.autohotkey.com/docs/commands/ImageSearch.htm Other than GIF, I have not tested the code for any of the other formats. BTW, for lossy image formats you will need to use the variance parameter or the match will likely fail.
    1 point
  47. ssjdennis

    Image Search Library

    what file type can I use???
    1 point
  48. A. Percy

    Image Search Library

    Perfect!
    1 point
  49. ssjdennis

    Image Search Library

    Thx It working 100%
    1 point
×
×
  • Create New...