Jump to content

Size and Coordinates


Recommended Posts

Is there any program that lets you chose area and after that it tells you the size of it, and the coordinates where it is?

GoogleMaps?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I mean area from screen, not from earth

Well, you weren't very specific, were you?

What does "choose area" mean? Something like detecting left-click-and-drag with MouseGetPos() at each end? Or maybe like Au3Info.exe with the highlighting turned on?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Im thinking something like this: U drag square to screen, then it tells u the size of square and the x and y coordinates.

See how we got all the way to post #5 before you said what you wanted to do...? :)

Lookup _IsPressed() in the help file to detect the mouse button being held down.

Lookup TimerInit() and TimerDiff() in the help file to detect mouse button held long enough to be a "drag".

Lookup MouseGetPos() to capture mouse coordinates at beginning and end of operation.

If you get stuck, post enough demo code to show where you are with it.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This is what i got now:

#include <Misc.au3>
HotKeySet("{F5}", "Start") 
Func Start() 
While 1
$pos =  Mousegetpos()
$pos2 = Mousegetpos()
    If _IsPressed("01") Then
        $pos
        ContinueLoop
        If not _IsPressed("01") Then
            $pos2
            ExitLoop
        MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
        MsgBox(0, "Mouse x,y:", $pos2[0] & "," & $pos2[1])
        Endif
            
    EndIf
WEnd
EndFunc

While 1
    SLeep(100)
    Wend

But is there anyway i can get the size? And it puts error when i try to run the script.

Link to comment
Share on other sites

It's not really correct :) e.g. the $pos2 wich stands alone is wrong :( This is a working example, a bit extended:

#include <Winapi.au3>
#include<Constants.au3>
#include <Misc.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("{F5}", "Start")
$GUI = GUICreate("",1,1,0,0,$WS_POPUP,$WS_EX_TOPMOST)
GUISetBkColor(0x000000)
_WinSetTransEx($GUI, "", 70, 1)
Func Start()
While 1
;~ $pos =    Mousegetpos()
;~ $pos2 = Mousegetpos()
    If _IsPressed("01") Then
        $pos = Mousegetpos()
        WinMove($GUI,"",$pos[0],$pos[1],1,1)
        GUISetState(@SW_SHOW)
        $x1 = $pos[0]
        $y1 = $pos[1]
        While _IsPressed("01")
            Sleep(10)
            $pos2=Mousegetpos()
            $x = $pos2[0]-$pos[0]
            Switch $x < 0
                Case 1
                    $x1 = $pos2[0]
                    $x = $pos[0]-$pos2[0]
                Case 0
                    $x1 = $pos[0]
            EndSwitch
            $y = $pos2[1]-$pos[1]
            Switch $y < 0
                Case 1
                    $y1 = $pos2[1]
                    $y = $pos[1]-$pos2[1]
                Case 0
                    $y1 = $pos[1]
            EndSwitch
            WinMove($GUI,"",$x1,$y1,$x,$y)
;~          ConsoleWrite($pos[0]-$pos2[0] & @CRLF)
        WEnd
        MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
        MsgBox(0, "Mouse x,y:", $pos2[0] & "," & $pos2[1])
        GUISetState(@SW_HIDE)
            Return
        EndIf
        Sleep(10)
WEnd
EndFunc

While 1
    SLeep(100)
Wend


#include-once

;===============================================================================
;
; Function Name:   _Win_SetTransEx($Title, [$Text, [$Transparency, [$NoClick]]])
; Description::    Makes a window transparent and/or not to recieve mouse clicks(so that you can click through)
; Parameter(s):    $Title -> Title or hWnd of Window
;                  $Text [Optional] -> Text in Window
;                  $NoClick [Optional] -> 0(default): Window will still register mouse input; 1: Mouse input will pass; 2: The window will be clickable and intransparent again($Transparency will be ignored)
; Requirement(s):  <WINApi.au3>
; Return Value(s): Success: 1, Error: 0 and @error
;                       @error Values: 1 -> Window does not exist
;                                      2 -> Error in Setting the Styles
; Author(s):       Prog@ndy (most of code) and Fast2 (some changes)
;
;===============================================================================
;
Func _WinSetTransEx($Title, $Text = "", $Transparency = 220, $NoClick = 0)
    Local $hWnd = WinGetHandle($Title, $Text)
    If @Error Then Return SetError(1, 0, 0)
    Switch $NoClick
        Case 0
            WinSetTrans($hWnd, "", $Transparency)
            If @Error Then Return SetError(2, 0, 0)
        Case 1
            _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))
            If @Error Then Return SetError(2, 0, 0)
            WinSetTrans($hWnd, "", $Transparency)
            If @Error Then Return SetError(2, 0, 0)
        Case 2;Restore
            _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), BitNOT($WS_EX_TRANSPARENT)))
            If @Error Then Return SetError(2, 0, 0)
            WinSetTrans($hWnd, "", 255)
            If @Error Then Return SetError(2, 0, 0)
    EndSwitch
    Return 1
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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...