zhenglei 发表于 2010-9-29 15:46:41

★★自动监控程序1输入框内容并同步至程序2输入框★★

本帖最后由 zhenglei 于 2010-9-29 15:47 编辑



★★自动监控程序1输入框内容并同步至程序2输入框★★
程序1 为全屏程序   大家可以吧程序1先转成EXE运行

随后 程序2 是置顶的程序2 开始监控程序1的输入框内容如果空则不同步如果程序1有输入 则程序2自动将监控到的数据读取到自身输入框中   
                     当程序2在INPUT1中按下回车后 则弹出读取到程序1的数据。。。。。。    就这几个功能不知道兄弟们有没办法实现!!



研究很久没成功。 不知有没高手能搞定。。谢谢。。。。。   代码如下:#include <EditConstants.au3>   l;;;;;;;;;;;程序1 内容   被监控端
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("程序1---全屏的", @DesktopWidth,@DesktopHeight)
$Label1 = GUICtrlCreateLabel("程序1", 32, 16, 34, 17)
$Input1 = GUICtrlCreateInput("88888", 96, 136, 345, 80, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetFont(-1, 50, 400, 0, "黑体")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
#include <ButtonConstants.au3>;;;;;;;;;;;;;;;;程序2监控程序1输入框的   
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("程序2", 423, 188)
$Input1 = GUICtrlCreateInput("等待获取程序1输入框的信息", 48, 32, 313, 21)

$Input2 = GUICtrlCreateInput("", 48, 80, 313, 21)
$Button1 = GUICtrlCreateButton("Button1", 120, 120, 113, 41)
$Button2 = GUICtrlCreateButton("Button1", 248, 120, 113, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

WinSetOnTop($Form1, "", 1)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

zhenglei 发表于 2010-9-29 15:48:08

自己先顶一下。。。。。

lanfengc 发表于 2010-9-29 16:09:21

在WHILE循环中加入读取程序1的那个EDIT框的的代码就可以了啊。

landays 发表于 2010-9-29 16:21:51

本帖最后由 landays 于 2010-9-29 16:23 编辑

#include <ButtonConstants.au3>;;;;;;;;;;;;;;;;程序2监控程序1输入框的
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("程序2", 423, 188)
$Input1 = GUICtrlCreateInput("等待获取程序1输入框的信息", 48, 32, 313, 21)

$Input2 = GUICtrlCreateInput("", 48, 80, 313, 21)
$Button1 = GUICtrlCreateButton("Button1", 120, 120, 113, 41)
$Button2 = GUICtrlCreateButton("Button1", 248, 120, 113, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

WinSetOnTop($Form1, "", 1)
While 1
        $Text = ControlGetText("程序1---全屏的", "", "Edit1")
        If $Text = "" Then
                GUICtrlSetData($Input2, "")
        Else
                GUICtrlSetData($Input2, $Text)
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                              Case $Button
Msgbox (0,0,GuictrlRead($Input2))
        EndSwitch
WEnd

republican 发表于 2010-9-30 07:35:11

数据传递部分,你可以参考一下此贴:
http://www.autoitx.com/thread-18488-1-1.html


其实不管 程序1 的 input 为不为空,都应该考虑传递的,譬如按下"删除键"。

检测 input 更改的话,可以使用WM_COMMAND中的$EN_CHANGE消息。
页: [1]
查看完整版本: ★★自动监控程序1输入框内容并同步至程序2输入框★★