Skip to content

Commit

Permalink
2012-03-16_03-53-58
Browse files Browse the repository at this point in the history
  • Loading branch information
camerb committed Mar 16, 2012
1 parent 5cacd83 commit 2b69166
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 9 deletions.
36 changes: 27 additions & 9 deletions FcnLib.ahk
Expand Up @@ -214,7 +214,25 @@ SendViaClipboard(text)
Sleep 100
}

;If you see the image, move the mouse there
SimpleImageSearchWithDimensions(filename, xStart, yStart, width, height)
{
;TODO merge this mode into the others
;should probably have a usage that looks like:
; SimpleImageSearch("file.bmp", "{CoordZone:\"0,0,10,20\"}")
;should use json to specify the coordzone to search

if NOT FileExist(filename)
{
errord(A_ThisFunc, filename, "the aforementioned file does not exist")
return false
}

;WinGetPos, no, no, winWidth, winHeight, A
ImageSearch, xvar, yvar, %xStart%, %yStart%, %width%, %height%, %filename%

return NOT ErrorLevel
}

SimpleImageSearch(filename)
{
if NOT FileExist(filename)
Expand Down Expand Up @@ -247,7 +265,7 @@ MouseMoveIfImageSearch(filename)
}

;If you see the image, click it
ClickIfImageSearch(filename, clickOptions="left mouse")
ClickIfImageSearch(filename, options="left mouse")
{
;TODO make this look a little more like:
;if NOT VerifyFileExist(A_ThisFunc, filename)
Expand All @@ -265,7 +283,7 @@ ClickIfImageSearch(filename, clickOptions="left mouse")
ImageSearch, xvar, yvar, 0, 0, winWidth, winHeight, %filename%

if NOT ErrorLevel
Click(xvar, yvar, clickOptions)
Click(xvar, yvar, options)

return NOT ErrorLevel
}
Expand Down Expand Up @@ -295,10 +313,10 @@ WaitForImageSearch(filename, variation=0, timeToWait=60, sleepTime=20) ;TODO opt
return false
}

WFCIImageSearch(filename, clickOptions="left mouse")
WFCIImageSearch(filename, options="left mouse")
{
WaitForImageSearch(filename)
ClickIfImageSearch(filename, clickOptions)
ClickIfImageSearch(filename, options)
}

;FIXME I don't like the boolean logic here... just doesn't seem readable
Expand Down Expand Up @@ -345,7 +363,7 @@ MouseMoveRandom()
;deprecated:
MoveToRandomSpotInWindow()
{
MouseMoveRandom()
MouseMoveRandom()
}

WeightedRandom(OddsOfa1, OddsOfa2, OddsOfa3=0, OddsOfa4=0, OddsOfa5=0)
Expand Down Expand Up @@ -398,7 +416,7 @@ BoolToString(bool)
return "false"
}

;TODO write
;WRITEME
;Returns true if color1 is darker than color2
ColorIsDarkerThan(color1, color2)
{
Expand All @@ -407,7 +425,7 @@ ColorIsDarkerThan(color1, color2)
;determine difference
}

;TODO write
;WRITEME
;Continuously checks a pixel's color until it stabilizes at a certain color
;returns the color that it is holding at
WaitUntilColorStopsChanging(x, y)
Expand All @@ -421,7 +439,7 @@ WaitUntilColorStopsChanging(x, y)
return currentColor
}

;TODO write
;WRITEME
;Keeps clicking a spot until it is as dark/as light as possible
;(for selecting/deselecting a checkbox)
ForcePixelColorChangeByClicking(x, y, lightestOrDarkest, checkboxStates=2)
Expand Down
43 changes: 43 additions & 0 deletions firefly-FcnLib.ahk
Expand Up @@ -243,6 +243,49 @@ GetStatus()
}
return status
}

;TODO put this sucker into the ASE macro
GetThatStupidDate()
{
xDate := 0
yDate := 0
wDate := 100
hDate := 20

Loop, 12
{
file=images/firefly/date/monthWords%A_Index%.bmp
if SimpleImageSearchWithDimensions(file, xDate, yDate, wDate, hDate)
{
sawMonth := A_Index
break
}
}

Loop, 31
{
file=images/firefly/date/%A_Index%.bmp
if SimpleImageSearchWithDimensions(file, xDate, yDate, wDate, hDate)
{
sawDay := A_Index
break
}
}

Loop, 3
{
thisYear := 2010 + A_Index
file=images/firefly/date/%thisYear%.bmp
if SimpleImageSearchWithDimensions(file, xDate, yDate, wDate, hDate)
{
sawYear := thisYear
break
}
}

returned=%sawMonth%/%sawDay%/%sawYear%
return returned
}
;}}}

;{{{ Generic things
Expand Down

0 comments on commit 2b69166

Please sign in to comment.