 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
xueying608
Joined: 16 Jun 2009 Posts: 4
|
Posted: Tue Jun 16, 2009 9:01 am Post subject: Screen ruler--an useful Measurement Tool |
|
|
Screen ruler is a tool used to measure.The ahk script can be used to measure the distance between two points or more.
This script may be useful for web designers.
| Code: |
lx := A_ScreenWidth/2-75
Gui, +AlwaysOnTop +ToolWindow -caption
Gui +LastFound
WinSet, Transparent, 200
gui, font, s12 w600
Gui, Show,NoActivate W150 H50 X%lx% Y0 ,
color := 0x0000FF
width := 4
hdc_screen := DllCall( "GetDC", "uint", 0 )
hdc_buffer := DllCall( "CreateCompatibleDC", "uint", hdc_screen )
hdc_canvas := DllCall( "GetDC", "uint", 0)
return
f4:: ;按下此快捷键开始测量 ,start to measure width and height.
CoordMode, Mouse, Screen
MouseGetPos,,, win_id2, ctrl_id2
WinGetTitle, win_title, ahk_id %win_id2%
Loop
{
Sleep,100
KeyIsDown := GetKeyState("LButton")
if (KeyIsDown = 1)
{
MouseGetPos, xpos, ypos
px = %xpos%
py = %ypos%
Sleep,10
Loop
{
Sleep,100
KeyIsDown := GetKeyState("LButton")
if (KeyIsDown = 1)
{
drawline(px, py, px1, py, color, width)
drawline(px1, py, px1, py1, color, width)
drawline(px, py1, px1, py1, color, width)
drawline(px, py, px, py1, color, width)
gui,2:destroy
Exit
}
MouseGetPos, px1, py1
Sleep,10
MouseGetPos, px2, py2
pw = % px1 - px
ph = % py1 - py
gui,2:color,00FF00
Gui, 2:+LastFound
WinSet, Transparent,150
Gui, 2:-Caption
Gui, 2:Show, x%px% y%py% h%ph% w%pw%
if px2!=%px1%
{
Gui, Add, Text, x40 y10 r4 cMaroon,W:%pw% px`r`nH:%ph% px
}
}
}
}
return
F2:: ;按下此快捷键清屏,重置测量值.reset width and height ,clear screen
px=
py=
px1=
py1=
px2=
py2=
WinHide,%win_title%
WinShow,%win_title%
reload
return
drawLine(x0, y0, x1, y1, color_ini=0, width=1)
{
global hdc_canvas, hdc_buffer
color := color_ini
erase := false
if color_ini=ERASE
erase := true
dx := x1 - x0
dy := y1 - y0
stepx := 0
stepy := 0
if (dx < 0) {
dx := -dx
stepx := -1
} else
stepx := 1
if (dy < 0) {
dy := -dy
stepy := -1
} else
stepy := 1
Loop %width%
{
x := x0+A_Index-1
y := y0
if erase
color := DllCall( "GetPixel", "uint", hdc_buffer, "int", x, "int", y )
DllCall( "SetPixel", "uint", hdc_canvas, "int", x, "int", y, "uint", color )
}
if (dx > dy) {
fraction := dy - (dx >> 1)
Loop
{
if (x0 = x1)
break
if (fraction >= 0) {
y0 += stepy
fraction -= dx
}
x0 += stepx
fraction += dy
Loop %width%
{
x := x0+A_Index-1
y := y0
if erase
color := DllCall( "GetPixel", "uint", hdc_buffer, "int", x, "int", y )
DllCall( "SetPixel", "uint", hdc_canvas, "int", x, "int", y, "uint", color )
}
}
} else {
fraction = dx - (dy >> 1)
Loop
{
if (y0 = y1)
break
if (fraction >= 0) {
x0 += stepx
fraction -= dy
}
y0 += stepy
fraction += dx
Loop %width%
{
x := x0+A_Index-1
y := y0
if erase
color := DllCall( "GetPixel", "uint", hdc_buffer, "int", x, "int", y )
DllCall( "SetPixel", "uint", hdc_canvas, "int", x, "int", y, "uint", color )
}
}
}
}
Escape::
ExitApp
|
_________________ xueying608 |
|
| Back to top |
|
 |
BF2 Player
Joined: 27 Mar 2009 Posts: 71
|
Posted: Tue Jun 16, 2009 9:14 pm Post subject: |
|
|
No one use this, it screws up all the icons and makes them not show.
I had to restart my computer...  |
|
| Back to top |
|
 |
xueying608
Joined: 16 Jun 2009 Posts: 4
|
Posted: Wed Jun 17, 2009 4:08 am Post subject: |
|
|
| BF2 Player wrote: | No one use this, it screws up all the icons and makes them not show.
I had to restart my computer...  |
i didn't understand.it works well in my computer.
First,you shuould press F4, click anywhere and drag your mouse.Click again,a transparent green rectangle
will appear and the width and height of the rec will show in a window at the top of the screen.
Second,everytime you measure ,you should press F3 ,which will reset the values and clear the screen.
Your problem ,i realy do not understand.
Could you please tell me more?
It will like this
 _________________ xueying608 |
|
| Back to top |
|
 |
BF2 Player
Joined: 27 Mar 2009 Posts: 71
|
Posted: Thu Jun 18, 2009 6:33 pm Post subject: |
|
|
I beleive I pressed F2 before, then a whole bunch of ahk programs popped up.
Then after that it was like a canvas was over my desktop,
I couldn't do any iterations with my mouse and all my icons weren't being shown. |
|
| Back to top |
|
 |
manicresin
Joined: 15 May 2007 Posts: 33
|
Posted: Fri Jun 19, 2009 6:24 am Post subject: |
|
|
| Does not work on my computer, but I'm running Windows 7 so could just not be compatible. |
|
| Back to top |
|
 |
icefreez
Joined: 15 May 2007 Posts: 169
|
Posted: Fri Jul 10, 2009 2:42 pm Post subject: |
|
|
Ya I had some issues with this script as well. I got it to work but my icons did flicker some while using it.
It also left the area selection boarders on my background after closing the script. After closing the script a simple F5 to refresh the desktop removed the remnant lines afterward.
Using Win XP Sp3. |
|
| 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
|