Reizvoller

ImageSearch Script Closing w/ Error

14 posts in this topic

#1 ·  Posted (edited)

Hello,

I am back once again to ask for assistance. I am just trying to fool around with the "ImageSearch" function in order to detect when certain elements appear on my active window to then respond to. To begin testing this I simply cut out a small segment of my background, saved it as a BMP, and used that as the bmp for the search function. I had hoped for it to just run through quickly and say it found it and spit out the X Y coords of where it was found. Instead I am getting this : http://screencast.com/t/MD9aOzPhETE

Here's my script thus far :

#Include <msgBoxConstants.au3>
#Include <ImageSearch.au3>

global $x = 0
global $y = 0
CheckForImage ()
Func checkForImage ()
   Local $Search = _ImageSearchArea ('ninjaCheck.bmp', 1, 0, 0, 1366, 768, $x, $y, 100)
   If $Search = 1 Then
      MsgBox ($IDOK,"Found",$resultPosition)
   EndIf
EndFunc
While 1
   Sleep (10)
WEnd

What I would like assistance with is how do I "Debug" this in order to see where/why it is failing.

I've reviewed https://www.autoitscript.com/wiki/FAQ#How_can_I_debug_my_script.3F but I am not entirely sure how to apply the information. If I could get a return on "Hey, this Func or This Line is where I died" , that would be awesome.

Any suggestions on how I can tackle this issue?

Thank you for your time!

-Reiz

 

checkNinja.bmp is " " around it now and it has the same result 

Edited by Reizvoller
I changed and tested my scripting

Share this post


Link to post
Share on other sites



Maybe the Ninja is against checking and killed your script?

Share this post


Link to post
Share on other sites

Reizvoller,

Given the name of the image for which you are checking, you might like to read the Forum rules before you post again.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
16 hours ago, Melba23 said:

Reizvoller,

Given the name of the image for which you are checking, you might like to read the Forum rules before you post again.

M23

Howdy!

"Given the name of the image for which you are checking" , I am guessing that is referencing "ninjaCheck.bmp".

I've reviewed the forum rules, as you suggested, but... I don't see what you are trying to say to me. This isn't an attempt at being facetious or evading but honestly asking for guidance with what you are saying to me. Thank you!

Share this post


Link to post
Share on other sites
8 minutes ago, Reizvoller said:

what you are saying to me

Thought that would be pretty obvious...right.. as your guess is correct?
In case it isn't clear then read the part about Game automation.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

4 minutes ago, Jos said:

Thought that would be pretty obvious...right.. as your guess is correct?
In case it isn't clear then read the part about Game automation.

Jos

Okay, I have done so. How does this apply to me? 
When did I reference a game in my posts? 

"To begin testing this I simply cut out a small segment of my background, saved it as a BMP, and used that as the bmp for the search function." 

So...Am I being told to review rules rather than getting actual replies regarding my question due to an assumption that I am trying to automate game processes?

I've attached a copy of my desktop background and the segment I cut out to hopefully further emphasise the fact that I am not breaking any rules... 

d092ecd9fae122c90aedd6734647ef23.jpg

ninjaCheck.bmp

Edited by Reizvoller
More evidence

Share this post


Link to post
Share on other sites
3 minutes ago, Reizvoller said:

Okay, I have done so. How does this apply to me? 

You have just been pointed to the rules since you used a term used in games.
In case we were convinced it was against our rules, you wouldn't have been able to post in it anymore, as we would have closed it already.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
1 minute ago, Jos said:

You have just been pointed to the rules since you used a term used in games.
In case we were convinced it was against our rules, you wouldn't have been able to post in it anymore, as we would have closed it already.

Jos

Hello,

So assumptions were made rather than asking questions for clarification. I understand.

I'd like to bring this thread back on topic since we now validated it as an actual question that doesn't break the rules.

#Include <msgBoxConstants.au3>
#Include <ImageSearch.au3>

global $x = 0
global $y = 0
CheckForImage ()
Func checkForImage ()
   Local $Search = _ImageSearch ("ninjaCheck.bmp", 1, $x, $y, 50)
   If $Search = 1 Then
      MsgBox ($IDOK,"Found",$resultPosition)
   EndIf
EndFunc
While 1
   Sleep (10)
WEnd

I've re-modified my script to try the _ImageSearch function rather than _ImageSearchArea . This tosses the same error pop-up that I linked to in my original post. 

Share this post


Link to post
Share on other sites
Just now, Reizvoller said:

So assumptions were made rather than asking questions for clarification. I understand.

What about you step of your high horse before continuing?
This is our standard approach and when you don't like then that is your problem... sorry. ;) 

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
1 minute ago, Jos said:

What about you step of your high horse before continuing?
This is our standard approach and when you don't like then that is your problem... sorry. ;) 

Jos

To iterate again... I'd like to bring this thread back on topic since we now validated it as an actual question that doesn't break the rules.

#Include <msgBoxConstants.au3>
#Include <ImageSearch.au3>

global $x = 0
global $y = 0
CheckForImage ()
Func checkForImage ()
   Local $Search = _ImageSearch ("ninjaCheck.bmp", 1, $x, $y, 50)
   If $Search = 1 Then
      MsgBox ($IDOK,"Found",$resultPosition)
   EndIf
EndFunc
While 1
   Sleep (10)
WEnd

I've re-modified my script to try the _ImageSearch function rather than _ImageSearchArea . This tosses the same error pop-up that I linked to in my original post. 

Jos : You are a skilled developer , do you have any insight you can provide regarding this?

Share this post


Link to post
Share on other sites
1 minute ago, Reizvoller said:

To iterate again.

 

1 minute ago, Reizvoller said:

Jos : You are a skilled developer , do you have any insight you can provide regarding this?

Seriously...   after first trying to tell me to shut up?  
simple answer: No

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
8 minutes ago, Jos said:

 

Seriously...   after first trying to tell me to shut up?  
simple answer: No

Jos

Howdy,

I am sorry you somehow feel that my posts were saying "Shut up" to you. Could you cite the exact line that suggests that notion? I'd rather not make that impression again in the future.

Regarding your reply I accept it and thank you for taking the time to respond.

Now, to iterate once again to get this thread back on topic...

After manipulating my script multiple times and running it in two different environments with clean installs of AutoIt I have come to the conclusion that the library of ImageSearch.au3 is erroneous and I've reached out to the developer of said script. If I get any useful information in return I will post it here so everyone may have said information.

-Reiz 

Share this post


Link to post
Share on other sites

 

Just now, Reizvoller said:

Now, to iterate once again to get this thread back on topic...

... ahh that is why you reported me. It never dawned on you that I wouldn't appreciate you keep on going on and on about it.

Let me help you to stop this BS

*click*


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Reizvoller,

I would strongly suggest a serious change of attitude if you want to stick around here.

You posted a question using a filename which in our experience indicated that the question was against the forum rules. Rather then simply assuming that the question was game-related and closing the thread, I gently pointed you to the Forum rules so as to prevent any future unpleasantness. I fail to see why you have suddenly become all excited and started acting as if we had come over all heavy-handed. What you saw was our normal response when we have doubts about a question - all you needed to do was to assure us that your question was legal and we could have avoided a great deal of annoyance all round. As it is you have managed to alienate 2 of the Mods here in fairly short order - pretty good going after only 9 posts.

So I suggest you wind your neck very firmly back in and try in future not to take unwarranted offence when absolutely none has been offered.

M23

 

 

2 people like this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • DeathChicken
      By DeathChicken
      If possible please add or edit the comments to explain how this works.
       
      ;includes functions from other things
      #include <GDIPlus.au3>
      #include <ScreenCapture.au3>
      ;hotkeys
      HotKeySet("{ESC}", _exit)
      HotKeySet("{F1}", _scan)
      ;global variables
      Global $win_title                    ;name of the window
      Global $area_x                        ;
      Global $area_y                        ;
      Global $area_w                       ;
      Global $area_h                        ;
      Global $cursor                         ;
      Global $rect_file                      ;
      Global $hbmpscreen              ;
      Global $i=  1043                      ;moves the rect
      Global $ii=    378                      ;moves the rect
      Global $x=1044                        ;inner rect offset
      Global $y=501                          ;inner rect offset
      Global $hbmprect                    ;image inside rect
      Global $hscreen                        ;image whole screen
                                         
      _GDIPlus_Startup()                    ;?
      ;display hotkeys on screen
      ToolTip("Press F1 to scan | Press ESC to Exit",0,0)
                                          ;infinite loop to keep prog running
      While 1
          Sleep(100)
      WEnd
      Func _scan()
      ;~ reads your screen area:
      _read()
      ;~ converts screen captured into bmp
      _convert()
      ;~ .  Loads converted bmp to be read
      _loadBMP()
      ;~ compares the bmp of your scanned screen to the actual screen that is being displayed
      _compare()
      EndFunc
                                          ;reads screen
      Func _read()
          $hscreen = _ScreenCapture_CaptureWnd("", WinGetHandle($win_title), $area_x, $area_y, $area_x + $area_w, $area_y + $area_h, $cursor)
      EndFunc
                                          ;converts screen into bmp
      Func _convert()
          _GDIPlus_BitmapCreateFromHBITMAP($hscreen)
      EndFunc
                                          ;loads converted screen
      Func _loadBMP()
      _GDIPlus_BitmapCreateFromFile($rect_file)
      EndFunc
                                          ;compares savedBMP to current screen
      Func _compare()
      ;If(                              below code                                     ) = (                   below code           ) Then
      If _GDIPlus_BitmapGetPixel($hbmpscreen, ($i + $x) - $area_x, ($ii + $y) - $area_y) = _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) Then
      ;display message box titled found with a message of found
      MsgBox("","","found")
      ;if above is not correct then
      EndIf
      EndFunc
                                          ;exit func
      Func _exit()
          Exit
      EndFunc
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
      Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
      I'll attach a portion of the code in order to let you understand what my script does.
      $objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
      Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
      How can I make all of these, faster?
      If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
      Thanks for your help
    • au3leecher
      By au3leecher
      Hellow everybody,
      I tryed to manipulate a game called "Assault Cube" which is a easy beginning in coding. I run the code but the wished value doesn't change, i don't understand why.
      The Pointers are fine, I checked that the pointers don't change every time while restart the game.
      My Code:
      <snip>
      _____________________________________________________________________________________________________________________________________________________________________________________________
      Checklist:
      The Offsets are 18C & 4
      In Cheat Engine: ("ac_client.exe"+0010F418) <- Pointer
      4 Bytes = 'dword'
       
    • careca
      By careca
      Hi, having an issue with an application i did, seems to crash randomly, and can take hours to do so.
      Simply says in the error msgbox:
      AutoIt Error
      Line 16392 (whatevermyapppath.exe)
      Error: The requested action with this object has failed.
       
      Recent changes to the script include this:
       
      ObjGet("winmgmts:\\localhost\root\CIMV2") $oSelect_active_network_cards = $objWMIService.ExecQuery('SELECT ProductName FROM Win32_NetworkAdapter WHERE NetConnectionStatus = 2 OR NetConnectionStatus = 9', "WQL") For $oSelect_active_network_card In $oSelect_active_network_cards $Adapter = $oSelect_active_network_card.ProductName Next Is the only thing i can see that can be related to an "object"
      This lines run only once at the top of the script.
      When i run the script itself and wait for a crash, it doesn't, or at least yet i didn't.
      What do you think this error could be?
      UPDATE: Runing the script eventually output this:
      "C:\script.au3" (894) : ==> The requested action with this object has failed.:
      $oNetwork_cards = $objWMIService.ExecQuery('SELECT BytesReceivedPerSec, BytesSentPerSec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface WHERE name LIKE "' & $Adapter & '"', "WQL")
      $oNetwork_cards = $objWMIService^ ERROR
    • argumentum
      By argumentum
      UDF to intercept the error window of AutoIt, showing more details about the error, including ability to save and send by email!