AutoHotKey - Fast image/Pixel scanning class

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ก.ค. 2024
  • This class is designed to be very easy to use but also fast, simple and lightweight.
    GitHub - github.com/Spawnova/ShinsImag...
    Simple examples are covered in the video, but make sure to read the functions for a better understanding, it's really not too hard to start making cool stuff =)
    0:00 Basic overview
    3:11 Preparing images
    5:51 Coding the example
  • เกม

ความคิดเห็น • 76

  • @Spawnova
    @Spawnova  2 ปีที่แล้ว +4

    Hey guys, if you have any questions or advice feel free to add me on discord @ Spawnova#2957
    I check there a couple times a day, I don't mind helping out with anything, even if it's a small questions or whatnot.
    If you are new to AutoHotkey and want some more generalized help, check out the amazing help section on the forums! - www.autohotkey.com/boards/viewforum.php?f=76

  • @Ashura1104
    @Ashura1104 ปีที่แล้ว +1

    Cannot explain how amazing this tutorial and your class was bro it genuinely was so easy to learn how to use it especially with your really nice examples thank you for this!!!

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      Hey thanks! That's what I was trying to go for, something even beginners can pickup and just start having fun with, hopefully you make some cool stuff with it =)

  • @snow86241
    @snow86241 2 ปีที่แล้ว +1

    By the way I don't know if my first comment a few days back went through, I think you did an amazing job with creating this script! It's super useful and a great improvement over the original! Especially adding background functionality, that was genius!

  • @alpocatfruit2355
    @alpocatfruit2355 2 ปีที่แล้ว +2

    Ive been looking for days on how to run a script in background
    And bam u show up 😁😁
    Thanks bro

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      No problems, if you have any questions or requests feel free to make a discussion on github, I check there daily, have fun! =)

  • @JoeGlines-Automator
    @JoeGlines-Automator 2 ปีที่แล้ว +4

    This is sooo cool! :)

  • @user-ll1hd9zk6u
    @user-ll1hd9zk6u ปีที่แล้ว +1

    Thank you! Your classes are very helpful

  • @stammpe2
    @stammpe2 2 ปีที่แล้ว +2

    Hi Shin, (I hope this is your name :-) I just by accident dropped over this video and have downloaded your Image/Pixel scanning class and i must say: I am impressed ! You really deserve a big shoutout. I have not tried every function yet, mainly scan.Image() and scan.ImageRegion() and i'm absolutely amazed. Also being able to scan background images sounds very unique and promising. I have a full HD monitor (3840 x 2160) and that's a lot of pixels to scan through, and it seven takes less than 100 milliseconds for a full screen image scan. Scan.ImageRegion even in the range of 20 to 50 milliseconds. Thank you for all your effort and time you have put into all this and thank you for your generosity to make this available to all of us. Keep up that great work. I have subscribed to your channel and i hope that you get a lot more subscribers.
    Kind regards and all the best, Peter Stammbach

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      Hey, thanks peter! I'm glad you are enjoying it, it was my intention to make it as user friendly as possible but still retain a lot of usability so hopefully that shows =P
      I've got some new projects I want to release soon that you may also find useful so stay tuned, and thanks again for the kind words =)

  • @CivReborn
    @CivReborn ปีที่แล้ว +1

    Really nice work here spawnnova.

  • @elektrocode
    @elektrocode ปีที่แล้ว +1

    This is an amazing class, working very fast and accurate. Thank you very much. Beside all other ways I have tried, this isn't capturing the window but directly searching in it I believe. I was using Gdip_imagesearch, it was working as intended but it was flashing window's borders on my Win11 system and pausing the screen(flashing was the real problem for me but had to mention this since your script not pausing the screen which is very nice as well) for a moment while capturing. Then I found your script and worked like a charm without any problem. ControlClick implementation is also working very nice, had to figure out how to use since I couldn't find usage on github page. A simpler version of ControlSend would be a nice touch as well but it's just very good as it's current state. Just a quick note from my side, I don't know if it would be possible to fix from your side but I couldn't make it work with MEmu emulator on my laptop at first while using OpenGL(didn't try with OpenGL on my pc I believe, only on laptop) but worked just fine after switching to DirectX in MEmu settings and no problem at all afterwards. Thank you again!

    • @Spawnova
      @Spawnova  ปีที่แล้ว +1

      Thanks, glad you are enjoying it =P
      The way the image buffer is updated is not compatible with certain software, it seems the way MEmu renders the screen in openGL may not be compatible. There is no fix currently for that as it's not a bug but rather a limitation of the capture method, I am in my spare time trying to learn other methods but they are more difficult.
      I'll look into adding user friendly ControlSend support later as well =)

  • @lynkkx
    @lynkkx 10 หลายเดือนก่อน +3

    is your image viewer tool available to dl anywhere? been looking for something like that for a while, launching software like gimp takes too much time every time I want to grab an image

  • @envoyremain
    @envoyremain 7 วันที่ผ่านมา

    Is it possible to react with a click when a pixel appears? I'm just new

  • @user-ui7gf4os2q
    @user-ui7gf4os2q ปีที่แล้ว

    I do a picture search whether it is true or not, and then the action after 25-40 minutes, the script closes in the event log ntdll.dll the failure was checked on 2 computers win 11 put a crutch after each pass restarts the script and zany

  • @thepragmatic6383
    @thepragmatic6383 2 ปีที่แล้ว

    Thank you, I think you just gave me an answer to what I was looking for.
    I was looking for a way to include in a script, (waiting for a progress bar, to reach the 100% mark), before continuing with the next steps in the script.
    This script extracts audio from a video, then converts and saves it to an Mp3 file. The conversion time varies depending on the length of the track,
    so I had to wait for the conversion to finish before proceeding to save the Mp3 file.

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      Yeah there are several functions which may help with that, hope you can get something working! =)

  • @ABtonatiza
    @ABtonatiza ปีที่แล้ว +1

    ;centerResults : Return the results centered on the image how to apply it in a script

    • @Spawnova
      @Spawnova  ปีที่แล้ว +1

      You just supply a 1 for that variable when calling the function, if you don't it defaults to 0.

  • @ABtonatiza
    @ABtonatiza ปีที่แล้ว +1

    как с вами можно связаться

  • @kentpachi143
    @kentpachi143 3 หลายเดือนก่อน

    that image viewer+saver is very useful, where can we download it?

  • @donovanzeanah
    @donovanzeanah 2 ปีที่แล้ว

    Wondering if you could help me out. I can set a chrome window by going to chrome and pressing f10, space, l,w and "dkz". When i use scan := new shinscanimgclass (dkz), it correctly finds the color pink in that window, and moves mouse to the correct location.
    I have tried to use the same result inside an instance of OBS, but no matter what I do, it wont find the image, or scan the color, anything. I can never get the function to find the window for obs. I also tried to scan a windows photo container, all sorts of combinations of (obs,"obs","ahk_exe " obs, changing the titlematch mode... everything. it would not find the window. (its active and showing). Any idea of what the problem could be?
    For reference, I've painted a screwdriver pink, and I want to look for pink on the video, as if the video were a game instance, so that a timer can start whenever obs (the camera) has a pink tool in view.
    The varying degree of color pinks that it could be depending on the lighting could be a problem, eventually, but that will come later.

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      Hey there, some windows do not update their device context which means my program cannot scan them in the background, they must be in the foreground
      To see if your window has that issue use 'scan.SaveImage("obs.png")'
      if the image is saved and it does not look like what you expect it to be, then it may be one of those windows that doesn't work in the background
      I'm not sure yet how to solve that problem, as I don't understand it fully.. =\
      If that's not the case though, you can add me on discord @ Spawnova#2957 or create a discussion on the github and I can assist further =)

  • @lokabrunn6867
    @lokabrunn6867 ปีที่แล้ว

    I get some weird bug when I create a new class with specifying a window title. When I use SaveImage("img", 0, 0, 1000, 1000) I get an image of a window that doesn't even exist anymore (that I closed 10 min ago)

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      Not all windows are compatible when using target window mode, generally when you use SaveImage and the image is from a time ago, or it's all black then it probably won't work, this generally happens with directx/opengl windows, unfortunately I don't currently have a solution to this as it requires a completely different capture method

  • @penumbral_psithurism
    @penumbral_psithurism 2 หลายเดือนก่อน

    It doesn't seem to work on Logitech G HUB, which is a real bummer. Using SaveImage to try and capture the window, it looks like it only captures the very background portion of the drawn window, none of the HUD elements (buttons, dropdown menus, etc) show up...

    • @Spawnova
      @Spawnova  2 หลายเดือนก่อน +1

      That is unfortunate =[
      Might be some ui automation libraries though that can interact with the window itself, if possible it would be much more reliable

    • @penumbral_psithurism
      @penumbral_psithurism 2 หลายเดือนก่อน

      @@Spawnova Way beyond the knowledge base of my bumbling fool self. The problem I was trying to solve is that G HUB doesn't allow user to apply macros to any key (only the F1 - F12 keys). I think what I'm going to have to do is completely stop using third party macro software and just do everything in AHK: profiles, macros, lighting... everything. Problem solved!

  • @Zlavik
    @Zlavik 7 หลายเดือนก่อน

    that image viewer though... Where can I get that?

  • @pgarza2
    @pgarza2 หลายเดือนก่อน

    hi, recently ive tried using the ahkv2 version of your image class. it seems as though im running into a run away memory leak while using it in a timer like shown in this video. is there any way you can help me troubleshoot this? or point me in the right direction?

    • @pgarza2
      @pgarza2 หลายเดือนก่อน

      edit: @Spawnova was able to help me fix my issue via discord. Thanks for all the support and for sharing your awesome creations!

  • @feratilik4375
    @feratilik4375 ปีที่แล้ว

    Hi, I have an issue. scan.Image("1.png",0,x,y) is always 0, regardless the window and 1.png are exist and active. Is there any suggestion ? Thanks. Ferhat

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      Could be a few things, try higher variance, but also it doesn't work on all games, you can check by running
      f5::
      scan.SaveImage("test.png")
      return
      if the image is all black or it's from an earlier point in time then it's not compatible with that window and has to be used in desktop mode, by not supplying a title
      If you need more help you can add me on discord @ Spawnova#2957 it's easier to help there

  • @yuriel9656
    @yuriel9656 ปีที่แล้ว

    what if you want to search image from other directory, example from %A_WorkingDir%
    esources\image.bmp gives error. so the main dir will be clean from any images. thanks a lot!

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      It assumes working directory by default, the reason you may get that error is because you don't use percent signs for real functions so instead of
      Scan.Image(%A_WorkingDir%
      esources\image.bmp
      you instead do this
      Scan.Image("resources\image.bmp")
      or this
      Scan.Image(A_WorkingDir "
      esources\image.bmp")

    • @yuriel9656
      @yuriel9656 ปีที่แล้ว

      @@Spawnova thanks a lot man!, i tried to experiment with your class, made a while loop with a thousand pics to search and it was definitely faster than regular imagesearch. right now im trying to make it as a custom ocr to see its full potential. hope it can handle trans background
      while(scan.image(A_WorkingDir "
      esources\monsters\abs.png",,x,y,0,RLTB)){
      Done:
      c := 1
      while(c

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      @@yuriel9656 If the source image has transparency it will ignore any pixels less than 0xFF alpha, meaning a fully transprent picture would match everything
      also a lot of the params are optional and do not need to be supplied every time, here's an example
      pastebin.com/2uVXSrfz

  • @VenikhTV
    @VenikhTV ปีที่แล้ว

    I tried this and works for me but i have an issue, i have 2 monitors so when i try to put the title of a window it doesnt work or find any images. However if i leave it in blank (desktop as default) it works if the window is in the "main" monitor but no on the second one. Is there a way to solve this in AHK ? im new to AHK.
    But overall its really fast, nice class!

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      It is a current limitation that if used in desktop mode (not supplying a target window) then it only works on the main screen
      Always use a target window when possible, although some games are not compatible with the capture method =[

    • @VenikhTV
      @VenikhTV ปีที่แล้ว

      @@Spawnova Thank you for the reply!

  • @snow86241
    @snow86241 2 ปีที่แล้ว

    Do you think this script is probably best for text search in the background too?

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      It does not have any sort of OCR capability,
      it's almost entirely for finding images and pixels.
      If the text you are looking for does not change then you could save it to an image file then search for it though which would work.
      Hope that helps

  • @ABtonatiza
    @ABtonatiza ปีที่แล้ว

    How can I contact you I can’t run your script to search for an image with pixels in any way Everything works great,please tell me why the script constantly shows that there is an image Although I specifically substitute an image that is not on the screen, but the creak works positively That they say he found a picture Although this picture is not

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      my public discord is @ Spawnova#2957
      the class may not work with all games though.
      you can try saving a screenshot and seeing if it looks correct as well
      f1::
      scan.SaveImage("test.png")
      return

  • @LtdMusic
    @LtdMusic ปีที่แล้ว

    Awesome program! Trying to using this with osrs, can't get it find the picture. Did exactly what you did.
    What I did:
    - Took a screengrab and pasted it in GIMP, zoomed in, marked a part of the picture in inventory, clicked it, exported as a png-file.
    - i then make a new clas object in my program and call image("mypicture.png")
    - It returns 0
    What am I doing wrong? :)
    Thanks!

    • @LtdMusic
      @LtdMusic ปีที่แล้ว

      Also - tried to disable HW-Acceleration + GPU plugin :/

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      You can save the image from the script and check if it's a black screen or just wrong which may indicate compatibility issues
      f1::
      scan.saveimage("test.png")
      return
      it that's good then just make sure you have a good search image and it doesn't include pixels that will be dynamic

  • @snow86241
    @snow86241 2 ปีที่แล้ว

    By the way silly question! Does ahk_id work for the title area? because if I have multiple runescapes open the title will be the same for all :x I tried using "ahk_id " %win_id% but it says it wasn't found

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      Yes it will work like that, functions parameters work in expression mode so it should be like this 'scan := new ShinsImageScanClass("ahk_id " hwnd)'
      no percent signs around the variable
      Also feel free to open discussions on the github or even request for new features, I check there daily =P

    • @snow86241
      @snow86241 2 ปีที่แล้ว

      @@Spawnova thank you mucho XD sorry I don't know how to use github, I'll look up a video about it to do so!

  • @dr4g0nt4nk3r
    @dr4g0nt4nk3r ปีที่แล้ว

    First of all, thanks for creating this! It is very easy to use and an amazingly useful script. However, I'm having an issue where it isn't able to detect Runelite on my laptop. It works perfectly on my desktop and used to work on my laptop, but now it isn't able to detect the actual game screen. Using 'scan.SaveImage' I can see Runelite's border, but the game area is black, and there is a large black border to the right and beneath the Runelite border in the screenshot. Do you know of anything that could be causing that?
    It works when used in desktop mode, instead of looking directly at the Runelite window

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      I'm not sure what could cause that issue, I haven't had any problems with runelite specifically, you could try copying your runelite settings from the desktop to your laptop to rule that out
      Generally black screens on the saved image are from hardware acceleration which GDI does not support (my capturing method)
      try ensuring it's disabled, you can read more here > github.com/runelite/runelite/wiki/Disable-Hardware-Acceleration
      If none of that helps then I'm not really sure =[

    • @dr4g0nt4nk3r
      @dr4g0nt4nk3r ปีที่แล้ว

      @@Spawnova You were right on the money! Disabling the GPU plugin fixed the issue (which I think has some hardware acceleration built into it or something). Confusing, because I am signed in and the plugins are supposed to be synced between the two computers, but hey. Thanks for the speedy reply!

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      @@dr4g0nt4nk3r I have GPU plugin enabled on runelite so it's not necessarily the root of the issue, honestly I don't know exactly why sometimes a windows device context is valid and sometimes it's not with accelerated windows.
      You could try the 117 hd plugin as well and see if it also causes problems, or maybe try restarting with gpu off, then turning it on after etc.
      I've looked into other ways to capture the screen which are more compatible but I can't quite get it working atm =[

  • @Oragami1337
    @Oragami1337 2 ปีที่แล้ว

    so i downloaded it and it errors out on opening it

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      Well it's a library it doesn't do anything on it's own, you have to include the class file in your script directory and also use #include, create an instance of it then you can start using the functions
      There are some examples in the github you could look at, they are commented too so it should be pretty helpful

  • @snow86241
    @snow86241 2 ปีที่แล้ว

    Do you think you can also include shins image viewer? :D Seems like a very nice tool!

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว +2

      Yeah I would love to make that public but it's not in a very user friendly state atm.
      I'd love to incorporate it with my scanning class so that you can test image and pixel matching on the fly before having to write anything.
      I do plan to release it though, but it may be a while sorry!

    • @snow86241
      @snow86241 2 ปีที่แล้ว

      @@Spawnova that's really neat! Thank you for thinking about it already :) Also do you think ahk is capable of animation recognition or anything? I play rs3 and I'm trying to figure out if there's a way to react to boss animations but that seems very complicated already because even if you do an image search it might be mirrored or turned 90/180 degrees haha

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      @@snow86241 Thanks for your comments, it's good to know people are finding this useful =D
      As far as your RS3 question, detecting 3d model animations is probably out of scope for this type of library, sorry =[
      Can may be able to get creative though, for instance if it spawns a lot of bright particles you could do PixelCount searches, but it would probably be a lot of fine tuning and lots of work XD

  • @annybodykila
    @annybodykila 3 หลายเดือนก่อน

    Id love to see more on the custom paint.

  • @raycapo9728
    @raycapo9728 ปีที่แล้ว

    How are you not banned showing your name? I looked you up

    • @Spawnova
      @Spawnova  ปีที่แล้ว

      I don't break any rules is why, no mouse interactions or automation of any kind, just some overlay stuff that informs me what I'm doing =P

  • @balls2thewall724
    @balls2thewall724 11 หลายเดือนก่อน

    any chance this will be updated for ahk v2?

    • @Spawnova
      @Spawnova  11 หลายเดือนก่อน

      It is updated for ahk v2, on the github it's in the V2 folder

    • @balls2thewall724
      @balls2thewall724 11 หลายเดือนก่อน

      @@Spawnova can't believe I missed it. that's awesome. thanks a ton!

    • @Spawnova
      @Spawnova  11 หลายเดือนก่อน

      @@balls2thewall724 No problem, I don't use ahk v2 personally so if you run into any issues with that version please let me know on the github =)

  • @mixacb3153
    @mixacb3153 6 หลายเดือนก่อน

    @spawnova How can I contact you?

    • @Spawnova
      @Spawnova  6 หลายเดือนก่อน

      If you have questions about my ahk scripts you can add my public discord here > .spawnova
      I check it once or twice daily

  • @zen8
    @zen8 2 ปีที่แล้ว

    Hi! May I check if this works properly on images with anti-aliasing issues as well? Sample image here - i.imgur.com/P6a2Naq.png
    Also, how does it compare to FindClick() function? Thank you.

    • @Spawnova
      @Spawnova  2 ปีที่แล้ว

      It does not handle any special scenarios like anti aliasing, it simply compares source image with a user supplied image, although specifying a variance will allow for some difference and still match
      I'm not familiar with FindClick function but if it's core is to find an image then it should be comparable