AutoHotkey Community

It is currently May 25th, 2012, 11:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: March 12th, 2005, 9:13 pm 
Offline

Joined: March 12th, 2005, 7:57 pm
Posts: 15
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 March 13th, 2005, 3:36 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2005, 9:54 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
Image
very nice!

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2005, 10:13 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Neat thinking! Wkd script :D

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2005, 11:16 pm 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2005, 11:33 pm 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2005, 12:48 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
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. ;)

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2005, 1:03 am 
Offline

Joined: March 12th, 2005, 7:57 pm
Posts: 15
Thanks for the comments, all. I have already begun using your version with the transparent window, Jon. Nice. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2005, 1:21 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
That's a great effect: An almost magical transformation from graphics to ascii characters.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2005, 2:51 am 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2005, 5:49 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 22nd, 2005, 9:09 pm 
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!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2006, 11:20 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2006, 1:55 am 
Offline

Joined: January 20th, 2006, 4:48 am
Posts: 29
Location: Colorado, USA
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. :shock:

TODO:create a sig
TODO:make more posts


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2006, 1:56 am 
Offline

Joined: January 20th, 2006, 4:48 am
Posts: 29
Location: Colorado, USA
also:

Use lucinda console regular for best results.
:wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2006, 11:05 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: tidbit and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group