Jump to content

Finder Tool ...


 Share

Recommended Posts

I'm trying to make a tool like the one from the AutoIt Window Info. The Finder Tool ! I need it to be able to be left clicked and dragged, when dropped I need it to give the mousepos in the X / Y input boxes.

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 116, 111, -1, -1)
$Button1 = GUICtrlCreateButton("Drag", 24, 8, 65, 65, 0)
$Button2 = GUICtrlCreateButton("Stop", 24, 8, 65, 65, 0)
GUICtrlSetState(-1,$gui_Hide)
$Label1 = GUICtrlCreateLabel("X:", 5, 82, 10,20)
$Input1 = GUICtrlCreateInput("", 20, 80, 30, 20)
$Label2 = GUICtrlCreateLabel("Y:", 60, 82, 10, 20)
$Input2 = GUICtrlCreateInput("", 75, 80, 30, 20)
GUISetState(@SW_SHOW)
Global $T = 0

While 1
    $msg = GuiGetMsg()
    Switch 1
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button1
            $T = 1
            GUICtrlSetState($Button1,$gui_Hide)
            GUICtrlSetState($Button2,$gui_Show)
        Case $msg = $Button2
            $T = 0
            GUICtrlSetState($Button1,$gui_Show)
            GUICtrlSetState($Button2,$gui_Hide)
        Case $T = 1
            $pos = MouseGetPos()
            GUICtrlSetData($Input1,$pos[0])
            GUICtrlSetData($Input2,$pos[1])
    EndSwitch
WEnd
Link to comment
Share on other sites

I'm trying to make a tool like the one from the AutoIt Window Info. The Finder Tool ! I need it to be able to be left clicked and dragged, when dropped I need it to give the mousepos in the X / Y input boxes.

Siao's magnifier has got what you want I think (in Example SCripts)

Here's a quick attempt at another way by modifying your code though.

#include <GUIConstants.au3>
#include <GUIConstants.au3>
#include <misc.au3>
$Form1 = GUICreate("Form1", 116, 111, 100, 100)
$Button1 = GUICtrlCreateButton("", 24, 8, 65, 65, 0)
$Button2 = GUICtrlCreateButton("Stop", 24, 8, 65, 65, 0)
GUICtrlSetState(-1, $gui_Hide)
$Label1 = GUICtrlCreateLabel("X:", 5, 82, 10, 20)
$Input1 = GUICtrlCreateInput("", 20, 80, 30, 20)
$Label2 = GUICtrlCreateLabel("Y:", 60, 82, 10, 20)
$Input2 = GUICtrlCreateInput("", 75, 80, 30, 20)
GUISetState(@SW_SHOW)
$Form2 = GUICreate('', 40, 40, 24 + 115, 111 + 28 + 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$Pic1 = GUICtrlCreatePic("info.bmp", 0, 0, 40, 40)
GUISetState()

Global $T = 0

While 1
    $msg = GUIGetMsg()
    Switch $msg
        
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1 * 8
            $T = 1
            GUICtrlSetState($Button1, $gui_Hide)
            GUICtrlSetState($Button2, $gui_Show)
        Case $Button2
            $T = 0
            GUICtrlSetState($Button1, $gui_Show)
            GUICtrlSetState($Button2, $gui_Hide)

    EndSwitch
    If _IsPressed("01") Then
        $bp = GUIGetCursorInfo($Form1)
        $cp = GUIGetCursorInfo($Form2)
        If $cp[4] = $Pic1 Or $bp[4] = $Button1 Then
            AdlibEnable("coords", 150)
            DllCall("User32.dll", "int", "ShowCursor", "int", 0)
            MouseMove($vp[0] + 20, $vp[1] + 20, 0)
            While _IsPressed("1")
                $mp = MouseGetPos()
                WinMove($Form2, '', $mp[0] - 20, $mp[1] - 20)
            WEnd
            AdlibDisable()
            DllCall("User32.dll", "int", "ShowCursor", "int", 1)
            WinMove($Form2, '', $wp[0] + 26 + 14, $wp[1] + 10 + 28 + 11)
        EndIf
        
    EndIf
    $wp = WinGetPos($Form1)
    $vp = WinGetPos($Form2)
    
WEnd

Func coords()
    $pos = MouseGetPos()
    GUICtrlSetData($Input1, $pos[0])
    GUICtrlSetData($Input2, $pos[1])
EndFunc  ;==>coords

here is a simple bitmap for the 'cursor'.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...