 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tinypig
Joined: 12 Mar 2005 Posts: 14
|
Posted: Sat Mar 12, 2005 9:13 pm Post subject: Capture From Screen To ASCII Art |
|
|
Position mouse in upper-left corner of image to be copied and press ctrl-alt-b (for "begin"). Then position mouse in the lower-right corner of the image to be copied and press ctrl-alt-e (end). Wait for message saying it is complete. The bigger the image, the longer it will take. Go to Notepad and make sure you are using a fixed-width font (as a suggestion, go to Format->Font, select Terminal font, Regular style, and the smallest size you can). Then paste from the clipboard.
It's a fun toy, but I eventually want to use it to locate stuff. Let me know what you think. Refactoring/criticism/comments welcome.
Note: Using the font I suggest here (on my machine at least), the colon (:) contains 2 pixels and the comma (,) contains 3, so I have switched them. However, depending on your font, you may get a better picture if you switch them in the code below ("%scan_current_line%:" and "%scan_current_line%," respectively).
| Code: |
^!e::
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, scan_x_end, scan_y_end
scan_current_y=%scan_y_start%
scan_current_x=%scan_x_start%
scan_current_line=
Loop
{
scan_current_x := scan_current_x + 1
if scan_current_x > %scan_x_end%
{
scan_current_line =%scan_current_line%`r`n
scan_current_y := scan_current_y + 1
if scan_current_y > %scan_y_end%
break
scan_current_x = %scan_x_start%
continue
}
PixelGetColor, found_color, %scan_current_x%, %scan_current_y%
StringMid, scan_rgb_r, found_color, 3, 2
StringMid, scan_rgb_g, found_color, 5, 2
StringMid, scan_rgb_b, found_color, 7, 2
scan_rgb_r=0x%scan_rgb_r%
scan_rgb_g=0x%scan_rgb_g%
scan_rgb_b=0x%scan_rgb_b%
SetFormat, integer, hex
scan_rgb_sum:=scan_rgb_r + scan_rgb_g + scan_rgb_b
if scan_rgb_sum > 0x280
{
scan_current_line =%scan_current_line%.
}
else if scan_rgb_sum > 0x200
{
scan_current_line =%scan_current_line%:
}
else if scan_rgb_sum > 0x180
{
scan_current_line =%scan_current_line%,
}
else if scan_rgb_sum > 0x100
{
scan_current_line =%scan_current_line%+
}
else if scan_rgb_sum > 0x80
{
scan_current_line =%scan_current_line%8
}
else
{
scan_current_line =%scan_current_line%#
}
}
Clipboard=%scan_current_line%
MsgBox, Scan Complete
return
^!b::
CoordMode, Mouse, Screen
MouseGetPos, scan_x_start, scan_y_start
return
|
(edited to make instructions more clear and remove extra code tag)
(edited again to add note)
(edited again due to OCD and that 3 is better replaced by +)
Last edited by tinypig on Sun Mar 13, 2005 3:36 am; edited 4 times in total |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Sat Mar 12, 2005 9:54 pm Post subject: |
|
|
very nice! _________________
 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5009 Location: imaginationland
|
Posted: Sat Mar 12, 2005 10:13 pm Post subject: |
|
|
Neat thinking! Wkd script  _________________
RegExReplace("irc.freenode.net/autohotkey", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
Jon
Joined: 28 Apr 2004 Posts: 373
|
Posted: Sat Mar 12, 2005 11:16 pm Post subject: |
|
|
very nice
I have modified it to allow you to hold control and then click and drag to select an area instead.
| Code: | ~^LButton::
stop=0
#persistent
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
MouseGetPos, scan_x_start, scan_y_start
currentXpos=%scan_x_start%
currentYpos=%scan_y_start%
ToolTip, ., scan_x_start, scan_y_start
WinSet, Transparent, 100, ahk_class tooltips_class32
loop
{
MouseGetPos, scan_x, scan_y
scan_x-=%currentXpos%
scan_y-=%currentYpos%
WinMove, ahk_class tooltips_class32, , , , %scan_x%, %scan_y%
GetKeyState, state, LButton
if state=u
{
tooltip
break
}
}
MouseGetPos, scan_x_end, scan_y_end
TrayTip, , Scanning...., , 1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, scan_x_end, scan_y_end
scan_current_y=%scan_y_start%
scan_current_x=%scan_x_start%
scan_current_line=
Loop
{
scan_current_x := scan_current_x + 1
if scan_current_x > %scan_x_end%
{
scan_current_line =%scan_current_line%`r`n
scan_current_y := scan_current_y + 1
if scan_current_y > %scan_y_end%
break
scan_current_x = %scan_x_start%
continue
}
PixelGetColor, found_color, %scan_current_x%, %scan_current_y%
StringMid, scan_rgb_r, found_color, 3, 2
StringMid, scan_rgb_g, found_color, 5, 2
StringMid, scan_rgb_b, found_color, 7, 2
scan_rgb_r=0x%scan_rgb_r%
scan_rgb_g=0x%scan_rgb_g%
scan_rgb_b=0x%scan_rgb_b%
SetFormat, integer, hex
scan_rgb_sum:=scan_rgb_r + scan_rgb_g + scan_rgb_b
if scan_rgb_sum > 0x280
{
scan_current_line =%scan_current_line%.
}
else if scan_rgb_sum > 0x200
{
scan_current_line =%scan_current_line%,
}
else if scan_rgb_sum > 0x180
{
scan_current_line =%scan_current_line%:
}
else if scan_rgb_sum > 0x100
{
scan_current_line =%scan_current_line%3
}
else if scan_rgb_sum > 0x80
{
scan_current_line =%scan_current_line%8
}
else
{
scan_current_line =%scan_current_line%#
}
}
Clipboard=%scan_current_line%
TrayTip, , Scan complete, , 1
sleep, 1000
TrayTip
return
|
|
|
| Back to top |
|
 |
Jon
Joined: 28 Apr 2004 Posts: 373
|
Posted: Sat Mar 12, 2005 11:33 pm Post subject: |
|
|
You could also use a GUI to display the results instead of using the clipboard. Something like this-
| Code: | gui, font,s1, Terminal
Gui, Add, Edit, x0 y0 w600 h400 -wrap +HScroll +VScroll, %scan_current_line%
Gui, Show, h400 w600, Ascii Art
|
|
|
| Back to top |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 700
|
Posted: Sun Mar 13, 2005 12:48 am Post subject: |
|
|
I've played with alot of ascii art apps, the rendering is really nice with this script. Thanks for sharing. Nice revisions Jon, I'll have to pinch that draw rectangle routine.  |
|
| Back to top |
|
 |
tinypig
Joined: 12 Mar 2005 Posts: 14
|
Posted: Sun Mar 13, 2005 1:03 am Post subject: |
|
|
Thanks for the comments, all. I have already begun using your version with the transparent window, Jon. Nice.  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Sun Mar 13, 2005 1:21 am Post subject: |
|
|
| That's a great effect: An almost magical transformation from graphics to ascii characters. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3005 Location: Minnesota
|
Posted: Sun Mar 13, 2005 2:51 am Post subject: |
|
|
| This is an amazing script. Might I suggest that it be considered for the showcase? There's some unique and interesting stuff in here that could prove useful to anyone reading up on the Pixel commands. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Sun Mar 13, 2005 5:49 pm Post subject: |
|
|
I considered adding it to the showcase but it seems a little obscure in terms of practical uses. The rule of thumb is that a script should be at least mildly interesting to 10% of site visitors.
Maybe in this case the coolness factor is enough to generate interest even though few would actually use the script regularly. So I'm open to the idea if others think it should be put in the showcase. |
|
| Back to top |
|
 |
fsnow55 Guest
|
Posted: Fri Apr 22, 2005 9:09 pm Post subject: |
|
|
| Chris wrote: | I considered adding it to the showcase but it seems a little obscure in terms of practical uses. The rule of thumb is that a script should be at least mildly interesting to 10% of site visitors.
Maybe in this case the coolness factor is enough to generate interest even though few would actually use the script regularly. So I'm open to the idea if others think it should be put in the showcase. |
Definitely has my vote! |
|
| Back to top |
|
 |
meod Guest
|
Posted: Tue Feb 28, 2006 11:20 pm Post subject: |
|
|
| is there any way of making the final ascii art smaller...i realize the original size matters, but it comes out too big even with a small image |
|
| Back to top |
|
 |
1991
Joined: 20 Jan 2006 Posts: 29 Location: Colorado, USA
|
Posted: Wed Mar 01, 2006 1:55 am Post subject: |
|
|
| Code: |
~^LButton::
stop=0
#persistent
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
MouseGetPos, scan_x_start, scan_y_start
currentXpos=%scan_x_start%
currentYpos=%scan_y_start%
ToolTip, ., scan_x_start, scan_y_start
WinSet, Transparent, 100, ahk_class tooltips_class32
loop
{
MouseGetPos, scan_x, scan_y
scan_x-=%currentXpos%
scan_y-=%currentYpos%
WinMove, ahk_class tooltips_class32, , , , %scan_x%, %scan_y%
GetKeyState, state, LButton
if state=u
{
tooltip
break
}
}
MouseGetPos, scan_x_end, scan_y_end
TrayTip, , Scanning...., , 1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
MouseGetPos, scan_x_end, scan_y_end
scan_current_y=%scan_y_start%
scan_current_x=%scan_x_start%
scan_current_line=
Loop
{
scan_current_x := scan_current_x + 1
if scan_current_x > %scan_x_end%
{
scan_current_line =%scan_current_line%`r`n
scan_current_y := scan_current_y + 1
if scan_current_y > %scan_y_end%
break
scan_current_x = %scan_x_start%
continue
}
PixelGetColor, found_color, %scan_current_x%, %scan_current_y%
StringMid, scan_rgb_r, found_color, 3, 2
StringMid, scan_rgb_g, found_color, 5, 2
StringMid, scan_rgb_b, found_color, 7, 2
scan_rgb_r=0x%scan_rgb_r%
scan_rgb_g=0x%scan_rgb_g%
scan_rgb_b=0x%scan_rgb_b%
SetFormat, integer, hex
scan_rgb_sum:=scan_rgb_r + scan_rgb_g + scan_rgb_b
if scan_rgb_sum > 0x2d9
{
scan_current_line =%scan_current_line%.
}
else if scan_rgb_sum > 0x294
{
scan_current_line =%scan_current_line%:
}
else if scan_rgb_sum > 0x273
{
scan_current_line =%scan_current_line%;
}
else if scan_rgb_sum > 0x258
{
scan_current_line =%scan_current_line%t
}
else if scan_rgb_sum > 0x1b9
{
scan_current_line =%scan_current_line%j
}
else if scan_rgb_sum > 0x1a7
{
scan_current_line =%scan_current_line%f
}
else if scan_rgb_sum > 0x1b3
{
scan_current_line =%scan_current_line%L
}
else if scan_rgb_sum > 0x138
{
scan_current_line =%scan_current_line%G
}
else if scan_rgb_sum > 0x108
{
scan_current_line =%scan_current_line%D
}
else if scan_rgb_sum > 0xe1
{
scan_current_line =%scan_current_line%K
}
else if scan_rgb_sum > 0xbd
{
scan_current_line =%scan_current_line%W
}
else
{
scan_current_line =%scan_current_line%#
}
}
Clipboard=%scan_current_line%
TrayTip, , Scan complete, , 1
sleep, 1000
TrayTip
return
|
^this variant adds more possible color variants
13 compared to 6.
TODO:create a sig
TODO:make more posts |
|
| Back to top |
|
 |
1991
Joined: 20 Jan 2006 Posts: 29 Location: Colorado, USA
|
Posted: Wed Mar 01, 2006 1:56 am Post subject: |
|
|
also:
Use lucinda console regular for best results.
 |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Wed Mar 01, 2006 11:05 am Post subject: |
|
|
| meod wrote: | | is there any way of making the final ascii art smaller...i realize the original size matters, but it comes out too big even with a small image |
It needs some work...
You can take a pixel out of n, with poor results.
Or you can make an average of n x n pixels (eg. a square of 2x2 pixels), which can be better. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| 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
|