Jump to content

Send Msg To Gui


Recommended Posts

#include <GUIConstants.au3>

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

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit, @CRLF & "line "& $n)
next

$EM_GETSEL = 0x00B0

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    if $msg >0 then
        $a=GUICtrlRecvMsg($nEdit, $EM_GETSEL)
    ;GUICtrlSendMsg($nEdit, $EM_GETSEL,1,5)
        GUICtrlSetState($nEdit,$GUI_FOCUS); set focus back on edit control

; will display the wParam and lParam values return by the control
        MsgBox(0,"Current selection",StringFormat("start=%d end=%d", $a[0], $a[1]))
    endif
Until $msg = $GUI_EVENT_CLOSE

Now you READ the selected text, how to SEND what the select text is ?

-jaenster

Link to comment
Share on other sites

maybe

#include <GUIConstants.au3>

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

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
$btn = GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit, @CRLF & "line "& $n , 1)
next

$EM_GETSEL = 0x00B0

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    if $msg = $btn then
        $a=GUICtrlRead($nEdit)
        GUICtrlSetState($nEdit,$GUI_FOCUS); set focus back on edit control

; will display the wParam and lParam values return by the control
        MsgBox(0,"Current selection", $a); StringFormat("start=%d end=%d", $a[0], $a[1]))
    endif
Until $msg = $GUI_EVENT_CLOSE

8)

NEWHeader1.png

Link to comment
Share on other sites

or... for 1 line

#include <GUIConstants.au3>

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

$nEdit = GUICtrlCreateList ("line 0", 10,10)
$btn = GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit, "line "& $n , 1)
next

$EM_GETSEL = 0x00B0

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    if $msg = $btn then
        $a=GUICtrlRead($nEdit)
        GUICtrlSetState($nEdit,$GUI_FOCUS); set focus back on edit control

; will display the wParam and lParam values return by the control
        MsgBox(0,"Current selection", $a); StringFormat("start=%d end=%d", $a[0], $a[1]))
    endif
Until $msg = $GUI_EVENT_CLOSE

8)

NEWHeader1.png

Link to comment
Share on other sites

TRy

#include <GUIConstants.au3>

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

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit, @CRLF & "line "& $n)
next

$EM_GETSEL = 0x00B0

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    if $msg >0 then
        $a=GUICtrlRecvMsg($nEdit, $EM_GETSEL)
  ;GUICtrlSendMsg($nEdit, $EM_GETSEL,1,5)
        GUICtrlSetState($nEdit,$GUI_FOCUS); set focus back on edit control

; will display the wParam and lParam values return by the control
        MsgBox(0,"Current selection",GUICtrlRead($nEdit))
    endif
Until $msg = $GUI_EVENT_CLOSE

Edit - too slow and probably wrong

Edited by BigDod


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

then...... maybe

#include <GUIConstants.au3>

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

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
$btn = GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit, @CRLF & "line "& $n , 1)
next

$EM_GETSEL = 0x00B0

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    
    if $msg = $btn then set_data()

Until $msg = $GUI_EVENT_CLOSE

Func set_data()
    GUICtrlSetData ($nEdit, "")
    GUICtrlSetData ($nEdit, "Iam an Edit")
    for $x = 1 to 5
        GUICtrlSetData ($nEdit, @CRLF , 1)
    Next
    GUICtrlSetData ($nEdit, "With Enters in it" , 1)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

no!

i want to

Fixed pic

You know that's rather rude, they are only trying to help. You would think the first thing you would do, is explain WHAT THE HELL YOU MEAN PROPERLY!

Where do you want to send it? You have one edit there, do you want to send it somewhere other than the GUI that that Edit is in? Do you want to send it to another application? I mean come on, your one line explinations are horrible.

Edit:

And what information do you want to send?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i think he wants an edit box and sum1 types something in clicks ok and it sets it to the list?

I thought it was something like this

#include <GUIConstants.au3>
#Include <GuiList.au3>

$Form1 = GUICreate("AForm1", 277, 344, 192, 125)
$Button1 = GUICtrlCreateButton("OK", 48, 272, 57, 25, 0)
$List1 = GUICtrlCreateList("", 40, 16, 129, 214,$LBS_MULTIPLESEL)
GUICtrlSetData(-1, "Line1|Line2|Line3|Line4|Line5|Line6")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        $ret = _GUICtrlListGetSelItemsText ($list1)
        If (Not IsArray($ret)) Then
                MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
            Else
                For $i = 1 To $ret[0]
                    MsgBox(0, "Selected", $ret[$i])
                Next
            EndIf

    Case Else
    ;;;;;;;
    EndSelect
WEnd

But what the hell I have been wrong many times before.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

pshh who knows what he wants ....

#include <GUIConstants.au3>
; == GUI generated with Koda ==

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("AForm1", 412, 427, 192, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
$go = GUICtrlCreateButton("DO IT", 152, 376, 105, 33)
GUICtrlSetOnEvent(-1, "setdata")

$input = GUICtrlCreateInput("", 120, 328, 169, 21, -1, $WS_EX_CLIENTEDGE)
$list = GUICtrlCreateList("", 120, 24, 161, 279, -1, $WS_EX_CLIENTEDGE)
GUISetState(@SW_SHOW)
while 1
    sleep(100)
wend

Func setdata()

$text = Guictrlread($input)
guictrlsetdata($list,$text)
guictrlsetdata($input,"")
EndFunc

Func close()
Exit
endfunc
Link to comment
Share on other sites

  • Moderators

ARG OMG

I want to c8 some script that SELECT some text from the gui !

Well, no one can read through your ebonics... what the hell is c8? Maybe you should try the AutoIt 123 tutorial, you've been given many choices here and the only thing you've shown you could do is copy and paste out of the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

maybe if you READ THE FING HELP FILE WITH BETA U MIGHT FIND IT

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $input, $listbox, $button, $label, $button2

GUICreate("ListBox Select String Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter String to Select", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Start from index 3", 85, 160, 120, 40)
$button2 = GUICtrlCreateButton("Start from index 0", 215, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If (StringLen(GUICtrlRead($input)) > 0) Then
                $ret = _GUICtrlListSelectString ($listbox, GUICtrlRead($input), 3)
                If ($ret == $LB_ERR) Then
                    MsgBox(16, "Error", "Not Found")
                Else
                    GUICtrlSetData($label, "Item #: " & $ret)
                EndIf
            EndIf
        Case $msg = $button2
            If (StringLen(GUICtrlRead($input)) > 0) Then
                $ret = _GUICtrlListSelectString ($listbox, GUICtrlRead($input))
                If ($ret == $LB_ERR) Then
                    MsgBox(16, "Error", "Not Found")
                Else
                    GUICtrlSetData($label, "Item #: " & $ret)
                EndIf
            EndIf
    EndSelect
WEnd

congrats theres the example for finding string of text in a list and it selects it

by the way theres not fing point in getting pissed off when people are trying to help you but your some ungrateful piece of crap who gets mad and never even said in the first place what you wanted, so when someone takes time out of there day to write a script to help you, you got to act like mr tough guy and get all mad how about you read the beta help file about selecting or something its quite simple, and if you get "mad" at me cuz its a listbox and not an edit box so be it go screw urself

Edited by thatsgreat2345
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...