Jump to content

Small bundle of (possibly silly) questions.


 Share

Recommended Posts

Alright, so I've done some googling to try and find my answer, but no luck.

I've got a few questions, hopefully they're not to stupid. ;D

1. Is it possible to use PixelSearch(or anything else) to lock onto a pixel/area that is located?

Example: I search for a specific color and PixelSearch finds it. Is it possible to literally lock onto that pixel? Even if it was moving? I highly doubt that it's possible, but I still feel the need to ask.

2. In my previous topic:

(For anybody willing to help I won't include my other post in this post to save some space.)

I was given some help with dividing the screen in half...

So I was wondering if it would be possible to divide the screen up into more sections instead of just half? Maybe 4ths? A dozen? A hundred? Even a thousand?

3. Assuming question 2 was possible, and say that the screen was divided into 100 even sections, is there a third party program that could be used to display a grid showing where each section was?

I have more questions, but those all depend on what (if anything) is possible.

Hopefully somebody can point me in the right direction. Thanks :)

Edited by BitOfHope
Link to comment
Share on other sites

I can only address #2 and #3. You do not need an outside program to draw gridlines. Below is an example of your screen getting split up in to 100 equal sections. Press the ESC key to exit.

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#NoTrayIcon

$width = @DesktopWidth
$height = @DesktopHeight

Global $tRECT, $hFont, $hOldFont, $hDC

HotKeySet("{ESC}", "_Exit")

$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, "Left", 5)
DllStructSetData($tRECT, "Top", 5)
DllStructSetData($tRECT, "Right", 250)
DllStructSetData($tRECT, "Bottom", 50)

$hDC = _WinAPI_GetDC(0)
$hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$hOldFont = _WinAPI_SelectObject($hDC, $hFont)

_WinAPI_SetTextColor($hDC, 0x0000FF)
_WinAPI_SetBkColor($hDC, 0x000000)

While 1
    For $i = 1 To 100 step 1
    _WinAPI_DrawLine($hDC, $width / 100 * $i, 0, $width / 100 * $i, $height)
    Next
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($hDC, $hOldFont)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_InvalidateRect(0, 0)
    $tRECT = 0
    Exit
EndFunc   ;==>_Exit

#include <ByteMe.au3>

Link to comment
Share on other sites

  • Moderators

BitOfHope,

There is nothing native in AutoIt to let you "lock on" to a particular pixel. You would have to write a function to do it and the speed of the various Pixel* functions are such that I doubt you could follow that particular pixel if it were moving with any speed. But I am quite prepared to be proved wrong on that last point. ;)

What sort of "lock on and follow" behaviour were you contemplating? :)

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

I can only address #2 and #3. You do not need an outside program to draw gridlines. Below is an example of your screen getting split up in to 100 equal sections. Press the ESC key to exit.

#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#NoTrayIcon

$width = @DesktopWidth
$height = @DesktopHeight

Global $tRECT, $hFont, $hOldFont, $hDC

HotKeySet("{ESC}", "_Exit")

$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, "Left", 5)
DllStructSetData($tRECT, "Top", 5)
DllStructSetData($tRECT, "Right", 250)
DllStructSetData($tRECT, "Bottom", 50)

$hDC = _WinAPI_GetDC(0)
$hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$hOldFont = _WinAPI_SelectObject($hDC, $hFont)

_WinAPI_SetTextColor($hDC, 0x0000FF)
_WinAPI_SetBkColor($hDC, 0x000000)

While 1
    For $i = 1 To 100 step 1
    _WinAPI_DrawLine($hDC, $width / 100 * $i, 0, $width / 100 * $i, $height)
    Next
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($hDC, $hOldFont)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_InvalidateRect(0, 0)
    $tRECT = 0
    Exit
EndFunc   ;==>_Exit

Thanks, it works great and after 10 minutes of googling I was able to start understanding some of the parts I didn't understand ;D
Link to comment
Share on other sites

BitOfHope,

There is nothing native in AutoIt to let you "lock on" to a particular pixel. You would have to write a function to do it and the speed of the various Pixel* functions are such that I doubt you could follow that particular pixel if it were moving with any speed. But I am quite prepared to be proved wrong on that last point. ;)

What sort of "lock on and follow" behaviour were you contemplating? :)

M23

Well, long story short: At work I have times of 'sit there and wait' which last anywhere from 2 minutes to 2 hours. So I like to keep myself busy, but I can't hop onto xbox live or anything without getting interrupted(which I find highly annoying). Autoit is great for keeping me busy.

As silly as it may sound, I'm doing little exercises with pictures/colors (sometimes I just use my desktop icons) to test what is possible. It's really simple: Put the color over at 'this part of my screen' and then click and drag it over to 'this part'. Then try and see if the script will find the same color again. So I was hoping there would be an actual way to 'lock on' to that color(pixel?). But I guess not, so I'll have to use other methods. That's what the grid is for. I was thinking "Hey, what if the screen was divided up into tons of little boxes? Then I could place my desktop icon in 'gridbox1' so then when the script detects that color(desktop icon) in 'gridbox1' it could make it's own action for that specific grid. Then if it finds that color in 'gridbox14' it could do something slightly different..." etc etc.

Would that not work the way I'm imagining it? ;)

I figure it's as good as any other way to learn new things.

Edit: Sorry for the doublepost.

Edited by BitOfHope
Link to comment
Share on other sites

  • Moderators

BitOfHope,

Not silly at all - a good way of learning how to use AutoIt. :)

You might find this of interest. I have not used it myself, but it seems to do quite a lot of what you want - locating an image on screen for example. ;)

M23

Edited by Melba23
Fixed link

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

You can't "lock on" to a moving pixel for the reason that the pixel itself isn't moving. Let's say you have a red pixel at 50,50 and it moves to 50,51. It doesn't really "move"; the pixel at 50,50 goes dark (or to another color) and the pixel at 50,51 that was previously dark is now illuminated to red. But it's a different pixel.

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...