Script needed to measure length of image

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scripts
Posts: 8
Joined: 12 Dec 2013, 21:35

Script needed to measure length of image

27 Jan 2014, 15:15

In my script, I'm using Pixel Search to find one end of a short, solid yellow line on a complex background. Once the script has found the start point of the line, I need it to measure the total length in pixels. Can anyone point me to an already-written script I can add/edit/modify that would return the length in pixels?
Last edited by scripts on 28 Jan 2014, 05:39, edited 1 time in total.
User avatar
LazyMan
Posts: 26
Joined: 14 Jan 2014, 00:22
Location: peering out from behind my favorite rock

Re: Script needed to meaure length of image

27 Jan 2014, 19:10

Is your yellow line vertical, horizontal, or neither?
If neither:
  • Can you specify its general orientation, or will it be random?
  • How many pixels thick will the line be?
What is the BGR (or RGB) ID of your yellow?
Guest

Re: Script needed to meaure length of image

27 Jan 2014, 23:32

BGR = 0xB3B300
Clarification: I have a hollow square here, formed by a thin yellow line. I want the script to return a variable containing the length in pixels of the horizontal and vertical lines that form the square. I don't know how thick the line is; maybe about 5 pixels.
User avatar
LazyMan
Posts: 26
Joined: 14 Jan 2014, 00:22
Location: peering out from behind my favorite rock

Re: Script needed to measure length of image

29 Jan 2014, 18:56

scripts wrote:Can anyone point me to an already-written script I can add/edit/modify that would return the length in pixels?
Guest wrote:BGR = 0xB3B300
This will find the pixel length of your yellow, horizontal line (I think your BGR is a shade of cyan.)

Code: Select all

UpperLeftX := 0
UpperLeftY := 0
LowerRightX := A_ScreenWidth
LowerRightY := A_ScreenHeight
ColorID := 0x00B3B3
Variation := 0

CoordMode Pixel, Screen
PixelSearch FoundX, FoundY, UpperLeftX, UpperLeftY, LowerRightX, LowerRightY
   , ColorID, Variation, Fast

If ( ErrorLevel != 0 )
{
   MsgBox Color not found on screen
   Return
}

StartX := FoundX
Loop
{
   PixelToRight := FoundX + 1
   PixelSearch FoundX, FoundY, PixelToRight, FoundY, PixelToRight, FoundY
      , ColorID, Variation, Fast
} Until ( ErrorLevel != 0 )

MsgBox % "LineLength = " (PixelToRight - StartX)

Return
scripts
Posts: 8
Joined: 12 Dec 2013, 21:35

Re: Script needed to measure length of image

29 Jan 2014, 20:50

Thanks you very much - I sure appreciate it!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], wilkster and 136 guests