Sign in to follow this  
Followers 0
darksoltan

Yelp! One Variable for Mouse Coordinates?

5 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

also, how do you paste code in color?

Newbdome... we meet again :)

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0