Jump to content

Mouse Movement based on Pixel Color - (Moved)


Recommended Posts

Hello! New to AutoIt but have used AHK and some other languages.  I am trying to write something where if I press a key, auto-it finds a preset color on the screen.  It then locks the cursor onto that color, wherever it goes until either 1) the color is no longer on the screen or 2) I press the same key to toggle it off.  I don't want any key presses or mouse clicks, just to control the mouse.  Is this possible?  I have found other posts on here from 10-12 years ago so I wasn't sure how much they would apply.  If I'm missing recent posts that deal with this because I'm not searching the right params, please link.  Thanks!

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

That's a quite general question. Can you please describe which program you try to automate or which goal you try to achieve?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

It will be a program running a video clip.  The clip will have a lot of movement with one specific person that shows up (and sometimes blends back into a crowd) and is as uniquely dressed as possible.  Imagine where's waldo but in video.  Some of these may get very hard to find, so having an "answer" button to toggle on which will move the mouse to the color and then stay on it as this person moves releasing if the color disappears and immediately regaining once it reappears.

I expect there will be some variance of color allowed due to lighting changes so I'm not looking for a perfect solution, but trying to get as close as I can for this.

Link to comment
Share on other sites

  • Moderators

hellomoto,

And what is the purpose of all this?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Well, my kids love seek and find books. I was hoping for a way to take it to the next level and make it easy to make new puzzles. Like me wearing some specific hat and having some else record on their phone in a mall, street corner, restaurant. Then I could queue this up as a way to find me if they get stuck

 Just for fun. Like a moving wheres waldo. Which is why I'd like it to be program agnostic. Just find the color and stay on it. I'm even thinking a snap function would be nice. So if they need a little help, they can mouse over close by and find it. Or have the option to get the answer by scanning the whole screen.

Link to comment
Share on other sites

  • Moderators

hellomoto,

That sounds like a fun project - but one which is perilously close to game automation, which you will see is not permitted by the Forum rules. The thread can remain open for the moment, but will remain under review.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

This example may help.

#include <WinAPIGdi.au3>

; Press Esc key to terminate script.
; Press Home key to toggle search for color.
; Press Shift-Alt-d keys to enter a new color.

Global $g_bPaused = False, $iColor = 0x63C4AB ; "H" avatar greenish color on AutoIt Forums. ;
Global $scale = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth

HotKeySet("{HOME}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "SearchColor") ; Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        $a = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $iColor, 5)
        #cs
            The search directions (from AutoIt help file - PixelSearch() function):
            Left-to-Right because "left" parameter < "right" parameter
            and
            Top-to-Bottom because "top" parameter < "bottom" parameter
            So, the top left search color is found first.
        #ce
        If IsArray($a) Then
            MouseMove($a[0] / $scale, $a[1] / $scale)
            ToolTip('Script is "Running"')
        Else
            ToolTip('Script is "Running"')
            $a = 0
        EndIf
    WEnd
    ToolTip('')
EndFunc   ;==>TogglePause

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func SearchColor()
    $iColor = InputBox("Color", "Enter color (0xRRGGBB) you wish to find." & @CR & " eg. For red enter 0xFF0000", "0xFF0000")
EndFunc   ;==>SearchColor

 

Edited by Malkey
Replaced _GetScale() function from https://www.autoitscript.com/forum/topic/156251-mouse-coordinates/?do=findComment&comment=1130002
Link to comment
Share on other sites

Melba23,

Wow.  Sorry.  Don't want to break any rules.  I travel a lot, so there's always cool new places to do this.  Kind of a virtual hide and seek.  Thanks for allowing the community to help.

Malkey,

Gonna read through this. Thanks for the start.

Link to comment
Share on other sites

I dont want to do the atmosphere breacker :P But it also depend of the video. 

 

There is 10 000 000 of colors. So ... gonna be hard. 

 

I will folow this project too. If you give us feedbacks :) . I like it too.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...