Jump to content

Yelp! One Variable for Mouse Coordinates?


Recommended Posts

Hey guys, newbY here. Quick question which has me STOMPED. :)

Basically, I want to put GUICtrlRead($Input1) into MouseClick("left", GUICtrlRead($Input1))

I like getting mouse coordinates with GUI on the fly, and would like to use the x,y stored in the input box... as coordinates in a MouseClick function later, but I can't seem to get the MouseClick to work this way, unless I input seperate variables for (x, & y). Anyway around this?

HotKeySet("{F1}" , "left")
Func left()
    MouseClick("left", $Inp1)
EndFunc

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\owner\Desktop\Backup\AutoIt\Koda\Forms\test.kxf
$Example = GUICreate("Example", 281, 52, 207, 139)
$Button1 = GUICtrlCreateButton("Record", 160, 8, 105, 33)
$Input1 = GUICtrlCreateInput("Input1", 24, 16, 129, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$Inp1 = GUICtrlRead($Input1)

While 1
Global $cd = 2  ;CountDown Time


$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
    Do
     GUICtrlSetData( $Button1, $cd & "..")
     $cd = $cd-1
     sleep(1000)
    Until $cd = 0
     GUICtrlSetData( $Button1, "Record")
   $pos = MouseGetPos()
   GUICtrlSetData( $Input1, $pos[0] & ", " & $pos[1])
EndSwitch
WEnd

test.au3

Link to comment
Share on other sites

Something like this?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#region ### START Koda GUI section ### Form=C:UsersownerDesktopBackupAutoItKodaFormstest.kxf
Global Const $Example = GUICreate("Example", 281, 52, 207, 139, -1, $WS_EX_TOPMOST)

Global Const $Button1 = GUICtrlCreateButton("Record", 160, 8, 105, 33)

Global Const $Input1 = GUICtrlCreateInput("Input1", 24, 16, 129, 21)
show_mouse_coords()

GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

HotKeySet("{F1}" , "left")

Global $cd

While 1
    $cd = 2  ;CountDown Time

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Do
                GUICtrlSetData($Button1, $cd & "..")
                $cd = $cd - 1
                Sleep(1000)
            Until $cd = 0

            GUICtrlSetData($Button1, "Record")
    EndSwitch

    show_mouse_coords()
WEnd

Func left()
    Local Const $coords = StringSplit(GUICtrlRead($Input1), ' ')
    BlockInput(1)
    MouseClick("left", $coords[1], $coords[2])
    BlockInput(0)
EndFunc   ;==>left

Func show_mouse_coords()
    GUICtrlSetData($Input1, MouseGetPos(0) & ", " & MouseGetPos(1))
EndFunc

Link to comment
Share on other sites

Hey Lacastiglione, Thx A Lot! Not exactly what I asked for, but it got me what I wanted. What I was looking for was the StringSplit(GUICtrlRead($Input1), ' ') command, which I didn't know existed till now. Also thx for cleaning up my code, I'm just copy&pasting what works with no code etiquete, but now im getting it. :)

This is what I was looking for:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:UsersownerDesktopBackupAutoItKodaFormstest.kxf
Global Const $Example = GUICreate("Example", 281, 52, 207, 139, -1, $WS_EX_TOPMOST)
Global Const $Button1 = GUICtrlCreateButton("Record", 160, 8, 105, 33)
Global Const $Input1 = GUICtrlCreateInput("", 24, 16, 129, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{F1}" , "left")
Global $cd
While 1
$cd = 2  ;CountDown Time
Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
    Do
     GUICtrlSetData( $Button1, $cd & "..")
     $cd = $cd-1
     sleep(1000)
Until $cd = 0
     GUICtrlSetData( $Button1, "Record")
GUICtrlSetData( $Input1, MouseGetPos(0) & ", " & MouseGetPos(1))
EndSwitch
WEnd

Func left()
    Local Const $coords = StringSplit(GUICtrlRead($Input1), ' ')
    MouseClick("left", $coords[1], $coords[2])
EndFunc
Link to comment
Share on other sites

  • Moderators

darksoltan,

Put [autoit] before and [/autoit] after your posted code and you get the coloured syntax. :)

Newbdome... we meet again

I am sure that you will get over it soon! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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