Jump to content
Sign in to follow this  
NewBe

Copy

Recommended Posts

NewBe

Hello, I want a copy function but this do not work proper.

I wants it to only copy the selected text :)

#include <GUIConstants.au3>
$Form1 = GUICreate("Form1", 460, 328)
$Edit1 = GUICtrlCreateEdit("copy me", 0, 0, 457, 297)
$Button1 = GUICtrlCreateButton("copy", 0, 296, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ClipPut(GUICtrlRead($Edit1))
            MsgBox(0 , "test" , ClipGet())
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Achilles

#include <GUIConstants.au3>
$Form1 = GUICreate("Form1", 460, 328)
$Edit1 = GUICtrlCreateEdit("copy me", 0, 0, 457, 297)
$Button1 = GUICtrlCreateButton("copy", 0, 296, 75, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GuiCtrlSetState($Edit1, $GUI_FOCUS)
            Send('^c')
            MsgBox(0 , "test" , ClipGet())
    EndSwitch
WEnd


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
Zedna

This is how to get selection position

but I don't know how to get text from this positions.

#include <GUIConstants.au3>
#include <GuiEdit.au3>

$Form1 = GUICreate("Form1", 460, 328)
$Edit1 = GUICtrlCreateEdit("copy me", 0, 0, 457, 297)
$Button1 = GUICtrlCreateButton("copy", 0, 296, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $aSel = _GUICtrlEdit_GetSel ($Edit1)
            MsgBox(0 , "selection position" , "Start: " & $aSel[0] & @CRLF & "End: " & $aSel[1])
                        $text = GUICtrlRead($Edit1)
            ClipPut($text)
            MsgBox(0 , "test" , ClipGet())
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Zedna

$text = ControlCommand($Form1, '', $Edit1, 'GetSelected', '')

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 460, 328)
$Edit1 = GUICtrlCreateEdit("copy me", 0, 0, 457, 297)
$Button1 = GUICtrlCreateButton("copy", 0, 296, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$text = ControlCommand($Form1, '', $Edit1, 'GetSelected', '')
            ClipPut($text)
            MsgBox(0 , "test" , ClipGet())
    EndSwitch
WEnd
Edited by Zedna

Share this post


Link to post
Share on other sites
Achilles

$text = ControlCommand($Form1, '', $Edit1, 'GetSelected', '')

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 460, 328)
$Edit1 = GUICtrlCreateEdit("copy me", 0, 0, 457, 297)
$Button1 = GUICtrlCreateButton("copy", 0, 296, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$text = ControlCommand($Form1, '', $Edit1, 'GetSelected', '')
            ClipPut($text)
            MsgBox(0 , "test" , ClipGet())
    EndSwitch
WEnd
Always have to do it the professional way... :)

Jk, I learned from this too...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.