was mache ich falsch?:
Code: Select all
#Requires AutoHotkey v2.0
; Cursor soll auf die Gerade durch (x1,y1) und (x2,y2) positioniert werden
x1:=0, y1:=0, x2:=1000, y2:=1000
OnExit ExitFunc
F1:: { ; Positionierung ein
global Hook
Hook := WindowsHook(WH_MOUSE_LL := 14, LowLevelMouseProc)
}
F2::ExitFunc(), ToolTip() ; Positionierung aus
*Esc::ExitApp
LowLevelMouseProc(nCode, wParam, lParam)
{
global x1, y1, x2, y2
static WM_MOUSEMOVE := 0x200, WM_COMMAND := 0x111
if wParam = WM_MOUSEMOVE
{
x:=NumGet(lParam+0,0,"Int"), y:=NumGet(lParam+0,4,"Int")
rx:= x2-x1, ry := y2-y1, rb := rx*rx+ry*ry
F := (rx*(x-x1)+ry*(y-y1))/rb
DllCall("SetCursorPos", "int", x1+F*rx, "int", y1+F*ry)
ToolTip "ist`tsoll`n" x "`t" x1+F*rx "`n" y "`t" y1+F*ry
return True ; hatte gefehlt!
}
return DllCall('CallNextHookEx', 'Ptr', 0, 'Int', nCode, 'UInt', wParam, 'Ptr', lParam, 'Ptr')
}
class WindowsHook
{
__New(type, callback, isGlobal := true)
{
this.pCallback := CallbackCreate(callback, 'Fast', 3)
this.hHook := DllCall('SetWindowsHookEx', 'Int', type, 'Ptr', this.pCallback,
'Ptr', !isGlobal ? 0 : DllCall('GetModuleHandle', 'UInt', 0, 'Ptr'),
'UInt', isGlobal ? 0 : DllCall('GetCurrentThreadId'), 'Ptr')
}
__Delete()
{
DllCall('UnhookWindowsHookEx', 'Ptr', this.hHook)
CallbackFree(this.pCallback)
}
}
ExitFunc(*) {
global Hook
Hook := ""
}
Edit: Ich hab's! return True ; hatte gefehlt! hinzugefügt.