程序2代码不变,
程序1
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>
#include <sendmessage.au3>
$Form1 = GUICreate("程序1", 226, 165)
$Button1 = GUICtrlCreateButton("Button1", 56, 80, 97, 49)
$Input1 = GUICtrlCreateInput("", 56, 32, 97, 21)
Local $hStatic = 0
Local $tBuffer = DllStructCreate('wchar[2048]')
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If(_WinAPI_IsWindow($hStatic)=0) Then
$hStatic = _WinAPI_GetWindow(WinGetHandle('程序2'),5)
EndIf
DllStructSetData($tBuffer,1,GUICtrlRead($Input1))
_SendMessage($hStatic,$WM_SETTEXT,0,DllStructGetPtr($tBuffer),0,'wparam','ptr')
EndSwitch
WEnd
|