Jump to content
Psychobird25

Printing out info to GUICtrlCreateEdit

Recommended Posts

Psychobird25

Here's my code so far:

 

Global $getEditGui = GUICtrlSetData(-1, "test")

This initializes the GUI and sets the "test" string.

Later on in the script, I use this code to record my mouse position. My goal is to print out the contents of $getCoords into the GUI without it executing it. Also, I want to make sure I can do this as many times as I want without it erasing the previous edits. My current code just prints "1" in the GUI and executes the contents of $getCoords

Func getCords()
   Opt("MouseCoordMode", 2)
   WinActivate("Calculator")
   sleep(3000)
   $MousePos = MouseGetPos()
   $MousePos[0] ; Mouse X position
   $MousePos[1] ; Mouse Y position
      $getCoords = MouseClick("Left", $MousePos[0], $MousePos[1])
      $getEditGui = GUICtrlSetData(-1, $getCoords)
EndFunc

 

Share this post


Link to post
Share on other sites
KickStarter15
Posted (edited)

How about something like this.

$Edit = GUICtrlCreateEdit("", 176, 32, 121, 97, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))

; some code here..

$getEditGui = GUICtrlSetData($Edit, $getCoords)

BTW, can you post the working code so we can see what went wrong.

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
KickStarter15

Yahhh... missed that:>...


Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
FrancescoDiMuro
Posted (edited)

@Subz
@KickStarter15

Not if you set the last parameter of GUICtrlSetData() to "non-empty"...
From the Help file:

default [optional]
Combo, List: The default value.
Edit, Input: If non-empty (""), the string is inserted at the current insertion point (caret).

And, this thing is showed in the GUICtrlCreateEdit() in the Help file:

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

Example()

Func Example()
    GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

    Local $idMyedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

    GUISetState(@SW_SHOW)

    Send("{END}")

    ; will be append dont' forget 3rd parameter
    GUICtrlSetData($idMyedit, "Second line", 1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example


Best Regards.

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

ALWAYS GOOD TO READ:

In case I am violating some pseudo Forum rule, or I am doing something wrong, I want let you know that I'm not doing this on purpose, and for this, I kindly ask you to send me a private message about the "bad content" I posted, in order to edit/remove it, and to not be warned wrongly.
Thanks in advance.

 

Share this post


Link to post
Share on other sites
Subz

The problem with this method is that it depends where the caret is, to me the GuiCtrlEdit_AppendText is more reliable.

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

×