 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Thu Mar 31, 2005 6:38 pm Post subject: Anything wrong with this script? |
|
|
I am trying to make a small script to scan pixels (using PixelGetColor) in a particular region and output them into a file so that I may eventually get to some pattern recognition abilities.
I had a script like this that was working fine which scanned a small area in a black and white picture and output it as a simple ascii version of only 0 and X, 0 if it was white, X if it was black. After I made some simple modifications to it, the script wouldn't work anymore, and even after I simplified it, I couldn't get it to make even a simple scan.
When I scan a small region with only black and white pixels, and output the colors read into a text file, I get colors other than black and white.
And it isn't an issue of my switching programs before the scanning is done so that it would accidentally read the desktop. I keep the picture on the side and can see the file as it is created on the desktop.
Here is the script. It scans a 100x100 pixel region with the current mouse position at the top left corner of that region. Is there something wrong with the script or my computer? | Code: | #a::
MouseGetPos, MouseX, MouseY
Loop, 100
{
Loop, 100
{
PixelGetColor, color, %MouseX%, %MouseY%
FileAppend, %color%`n, C:\patternrec.txt
MouseX++
}
MouseY++
} |
|
|
| Back to top |
|
 |
New_G Guest
|
Posted: Thu Mar 31, 2005 10:25 pm Post subject: |
|
|
Hi ..
| Code: |
#a::
MouseGetPos, MouseX, MouseY
FileAppend, *******`n Start `n*******`n, C:\patternrec.txt
Loop, 100
{
Loop, 100
{
PixelGetColor, color, %MouseX%, %MouseY%
FileAppend, at x=%MouseX% and y= %MouseY% color is %color%`n, C:\patternrec.txt
MouseX++
}
MouseY++
}
FileAppend, *******`n END `n*******, C:\patternrec.txt
msgbox end
|
I added some lines just to check the start and the end and to know when it's all done... (nothing changed in your code).
It works fine and the output file has 10006 lines (10000 pixel + 3 for the start + 3 for the end)
so it works..!! I can't see anything wrong there!
maybe I didn't understand what do you want it for .. but it works! |
|
| Back to top |
|
 |
alex Guest
|
Posted: Wed Apr 20, 2005 2:15 am Post subject: Same thing happens to me |
|
|
I ran this code on my all black desktop and the file is black until line 975 then has some other colors, and the last 90% of the file is white consistiently when I'm not seeing any white on the screen.
See below for the entire file
BLACK
...
at x=975 and y= 88 color is 0xF7FFFF
at x=976 and y= 88 color is 0x9CFFFF
at x=977 and y= 88 color is 0x9CFFFF
at x=978 and y= 88 color is 0x9CFFFF
at x=979 and y= 88 color is 0x9CFFFF
at x=980 and y= 88 color is 0x9CFFFF
at x=981 and y= 88 color is 0x9CFFFF
at x=982 and y= 88 color is 0x9CFFFF
at x=983 and y= 88 color is 0x9CFFFF
at x=984 and y= 88 color is 0x9CFFFF
at x=985 and y= 88 color is 0x9CFFFF
at x=986 and y= 88 color is 0x9CFFFF
at x=987 and y= 88 color is 0x9CFFFF
at x=988 and y= 88 color is 0x009C9C
at x=989 and y= 88 color is 0x080808
...
BLACK
...
at x=1196 and y= 90 color is 0x6B6B6B
at x=1197 and y= 90 color is 0x293142
at x=1198 and y= 90 color is 0x18314A
at x=1199 and y= 90 color is 0x293152
at x=1200 and y= 91 color is 0x293152
at x=1201 and y= 91 color is 0x393163
at x=1202 and y= 91 color is 0x316B84
at x=1203 and y= 91 color is 0x08A5A5
at x=1204 and y= 91 color is 0x526B84
at x=1205 and y= 91 color is 0x00426B
at x=1206 and y= 91 color is 0x29315A
at x=1207 and y= 91 color is 0x393163
at x=1208 and y= 91 color is 0x29315A
at x=1209 and y= 91 color is 0x393163
at x=1210 and y= 91 color is 0x005284
at x=1211 and y= 91 color is 0x4A84AD
at x=1212 and y= 91 color is 0x215A8C
at x=1213 and y= 91 color is 0x004A73
at x=1214 and y= 91 color is 0x29315A
at x=1215 and y= 91 color is 0x293152
at x=1216 and y= 91 color is 0x29315A
at x=1217 and y= 91 color is 0x293152
at x=1218 and y= 91 color is 0x29315A
at x=1219 and y= 91 color is 0x293152
at x=1220 and y= 91 color is 0x29315A
at x=1221 and y= 91 color is 0x293152
at x=1222 and y= 91 color is 0x293152
at x=1223 and y= 91 color is 0x293142
...
WHITE
I have been working with PixelGetColor for 3 days now with intermittent problems that I just cannot explain. I keep rewriting the same code to get 100 pixels square from the screen at mouse cursor, then draw 100 colored letters in a GUI window.
Then I mouseover one of my taskbar icons and try to "scan" it in.
The best I've gotten is 10 pixels in either direction.
Maybe its because I'm not incrementing at the correct stages in the loop.
My last attempt was little short of 100 different variables in a loop
I would post my code, but it's not doing so well anymore
%color% = MyArray%i%_%j%
Gui, Add, Text,c%color% X%xLocation% Y%yLocation% ,p
If %ErrorLevel% = "it didn't work"
{
Uninstall AHK
Format C:\
Bathtub := Hairdryer + User
}
else
Go to bed |
|
| Back to top |
|
 |
alex Guest
|
Posted: Wed Apr 20, 2005 4:17 am Post subject: nevermind |
|
|
| I solved it with someone elses code posted here |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|