Hey
How can I make line, that turn opposite direction of specific coordinate and follows mouse 1 pixel away from it ( so it is able to click too)
Line should be 20 pixel long
That example gif maybe tell that thing better ?
50 pixel from mouse
Started by
0mega
, May 17 2007 04:23 PM
5 replies to this topic
#1
-
Posted 17 May 2007 - 04:23 PM
there is no easy way to draw arbitrary lines with AHK.
#2
-
Posted 17 May 2007 - 07:11 PM
engunneer is right, you need to use GDI with DllCalls. This is confusing, I never done this before. I took a quick look at the GDI line and curve functions reference and came up with this:
You can get rid of the border by changing the Gui options. My calculations aren't exactly correct, so you need to fix it using the information in the highlighted lines.
; points on centre screen cx := A_ScreenWidth // 2 cy := A_ScreenHeight // 2 axis = 50 ; grid size offset = 3 ; offset from mouse CoordMode, Mouse ; set all coords relative to the screen Gui, -Caption +LastFound +AlwaysOnTop +ToolWindow +Border Gui, Color, White Gui, Show, w%axis% h%axis% WinSet, TransColor, 0xffffff ; make white background transparent OnExit, GuiClose Gui := WinExist() DC := DllCall("GetDC", "UInt", Gui) ; create device context Pen := DllCall("CreatePen", "UInt", 0, "UInt", 2, "UInt", 0) ; create pen DllCall("SelectObject", "UInt", DC, "UInt", Pen) ; select pen Loop { MouseGetPos, x, y If (x != lx or y != ly) { WinMove, x - axis - offset, y + offset ;[color=violet]c := Sqrt((cx - x) ** 2 + (cy - y) ** 2)[/color] ; hypotenuse (using Pythagoras) ;[color=violet]s := ASin((cy - y) / c) [/color]; sine angle g := (cy - y) / (cx - x) ; gradient ; clear previously drawn line: DllCall("FloodFill", "UInt", DC, "UInt", 1, "UInt", 1, "UInt", 1) DllCall("MoveToEx", "UInt", DC, "UInt", 1, "UInt", -axis * g, "UInt", 0) ; start DllCall("LineTo", "UInt", DC, "UInt", 50, "UInt", axis * g + axis) ; end lx := x, ly := y } Sleep, 1 } Return ~*Esc:: GuiClose: DllCall("DeleteObject", "UInt", Pen) DllCall("ReleaseDC", "UInt", Gui, "UInt", DC) ExitApp
You can get rid of the border by changing the Gui options. My calculations aren't exactly correct, so you need to fix it using the information in the highlighted lines.
#3
-
Posted 17 May 2007 - 07:30 PM
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Just tried again to make it, but this time different..
But I dont understand those transform things :S
I edited subject name.
But I dont understand those transform things :S
CoordMode, SetBatchLines, -1 SetMouseDelay, -1 setWinDelay, 5 LButton:: Click down SplashImage, C:\Documents and Settings\0mega\Työpöytä\Omega\Splashimages\Ringula.gif, B X3 Y3,,,Ringula Loop { X :=946 Y :=251 MouseGetPos, XX, YY if (X-XX<0) { DistanceX := XX-X } else { DistanceX := X-XX } if (Y-YY<0) { DistanceY := YY-Y } else { DistanceY := Y-YY } Asd := DistanceY/DistanceX Transform, Angle1, ATan, %Asd% Angle2 :=Angle1*180/3.14 Transform, Angle3, Cos,%Angle2% Transform, Angle4, Sin,%Angle2% XXX := Angle3*50 YYY := Angle4*50 XXXX:= XX-XXX YYYY:=YY-YYY WinMove, Ringula,, %XXXX% , %YYYY% GetKeyState, state, LButton, P if state = U break } Splashimage, Off Click up Return
I edited subject name.
#6
-
Posted 07 August 2007 - 03:23 PM