Jump to content
Sign in to follow this  
AU3Newbie

GUI's private clipboard shared to aother application

Recommended Posts

HOW to share the GUI-form's information to another programs?

e.g.

#include <GUIConstants.au3>


$Form1 = GUICreate("testGUI", 186, 174, 193, 115)
$testcontent = GUICtrlCreateEdit("", 9, 8, 167, 113)
GUICtrlSetData(-1, "testcontent")
$Button1 = GUICtrlCreateButton("test clipborad", 56, 136, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            ClipPut(GUICtrlRead($testcontent))
            run("notepad.exe")
            Sleep(100)
            send("^V")

    EndSwitch
WEnd

AS the example above,why the notepad cannot recieve the clipboard's content?

Share this post


Link to post
Share on other sites

I have a feeling that notepad didn't get time to become active before Send was executed. Try this :

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 4) ; added

$Form1 = GUICreate("testGUI", 186, 174, 193, 115)
$testcontent = GUICtrlCreateEdit("", 9, 8, 167, 113)
GUICtrlSetData(-1, "testcontent")
$Button1 = GUICtrlCreateButton("test clipborad", 56, 136, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            ClipPut(GUICtrlRead($testcontent))
            run("notepad.exe")
            WinWaitActive("classname=Notepad") ; replaced with sleep
            send("^V")

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

thank you very much.

Maybe the problem is ACTIVE problem or my OS isn't stable.

here's another,it works well.

thank you.

#include <GUIConstants.au3>

Opt("WinTitleMatchMode", 4); added

$Form1 = GUICreate("testGUI", 186, 174, 193, 115)
$testcontent = GUICtrlCreateEdit("", 9, 8, 167, 113)
GUICtrlSetData(-1, "testcontent")
$Button1 = GUICtrlCreateButton("test clipborad", 56, 136, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
                        $content=GUICtrlRead($testcontent)
            run("notepad.exe")

                        for $i=1 to StringLen($content) step 1
ClipPut(Stringleft($content,$i)&@CRLF)
      
            WinActivate("classname=Notepad"); replaced with sleep
            send("^V")
next
    EndSwitch
WEnd

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  

×
×
  • Create New...