Python Forum
Learning pixel change detection in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learning pixel change detection in Python
#1
I decided to learn how to code with Python with a specific goal in mind and could use some help with learning resources towards that goal.

Using AutoHotKey I managed to write a little script with a GUI that loads up an image from a directory and then uses ImageSearch in a loop to scan an active window for the previously loaded .png. If detected it acts with a combination of hotkeys or mouse movement/clicks.

Now I would like to rewrite that script in Python, but I was unable to find any equivalent to ImageSearch that AutoHotKey uses. AHK has also another way of doing the job, PixelSearch. With PixelSearch I was able to select a region of an active window and it would scan the region for any change in the pixels, allowing for the script to act with hotkeys/mouse clicks.

How would I go about coding this in Python? Or maybe theres a different way to detect area of the screen changes?

Please don't be too harsh Angel
Reply
#2
pyscreenshot looks cross platform: https://github.com/ponty/pyscreenshot

There's nothing builtin, because getting random pixels of a display is a very weird thing to do. What is it you're trying to accomplish? There might be a "better" way than image scraping yourself lol
Reply
#3
(Nov-07-2018, 08:03 PM)nilamo Wrote: pyscreenshot looks cross platform: https://github.com/ponty/pyscreenshot There's nothing builtin, because getting random pixels of a display is a very weird thing to do. What is it you're trying to accomplish? There might be a "better" way than image scraping yourself lol

Thank you, PIL looks like a tool for the job. I can think of a few uses for this, the main one could be games. For example if I'm selling an item in an online game, my PC has to be running in order for the shop to be online. So instead of leaving my PC running all night every night, I could detect whether someone bought an item and the little program could proceed to shut down my PC.

Thanks again :)

(Nov-07-2018, 08:46 PM)Hallucin88 Wrote:
(Nov-07-2018, 08:03 PM)nilamo Wrote: pyscreenshot looks cross platform: https://github.com/ponty/pyscreenshot There's nothing builtin, because getting random pixels of a display is a very weird thing to do. What is it you're trying to accomplish? There might be a "better" way than image scraping yourself lol
Thank you, PIL looks like a tool for the job. I can think of a few uses for this, the main one could be games. For example if I'm selling an item in an online game, my PC has to be running in order for the shop to be online. So instead of leaving my PC running all night every night, I could detect whether someone bought an item and the little program could proceed to shut down my PC. Thanks again :)

Actually after reading a bit more on PIL I don't think it's possible to actively scan for a change of pixels in a region. It seems that PIL can do everything to an image, but not to what is displayed in real time. Hm...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Voxel to pixel graphics voicemail 3 534 Nov-19-2023, 09:45 AM
Last Post: paul18fr
  Pixel color and action Sartre 4 1,971 Apr-13-2023, 03:26 AM
Last Post: Sartre
  Dynamic pixel display jerryf 2 675 Mar-17-2023, 07:26 PM
Last Post: jerryf
Question convert autohotkey script to python / macro - press key when pixel get colour willson94d 1 3,574 Jan-01-2022, 08:13 PM
Last Post: Yoriz
  Plotting Pixel Intensity Doev 0 1,703 Oct-21-2020, 10:56 PM
Last Post: Doev
  What is the best way to search for a pixel in a screenshot? TheZadok42 1 2,531 May-15-2020, 12:37 PM
Last Post: scidam
  how to compare two different size images in python and find corresponding pixel value squidsirymchenry 1 4,516 Feb-03-2020, 06:48 AM
Last Post: michael1789
  Python Project - Parkinson's Detection shivani 2 2,725 Sep-28-2019, 12:07 PM
Last Post: karansingh
  Fast get pixel and oparate. storzo 7 6,980 Aug-26-2019, 07:36 PM
Last Post: Larz60+
  random change of color pixel with PIL louloudevinci 4 8,378 May-31-2018, 03:55 PM
Last Post: louloudevinci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020