Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 2)

Модерирует : gyra, Maz

Widok (01-06-2010 13:08): Лимит страниц. Продолжаем здесь.  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

ViSiToR



Silver Member
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору

 
Reciever:
 

Код:
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
 
$hGUI = GUICreate("AU3COM Interaction", 400, 200)
 
$Edit1 = GUICtrlCreateEdit("", 20, 20, 360, 160)
 
GUIRegisterMsg($WM_COPYDATA, "_GUIRegisterMsgProc")
 
GUISetState(@SW_SHOW)
 
While 1
    $nMsg = GUIGetMsg()
 
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
 
Func
_GUIRegisterMsgProc($hWnd, $MsgID, $WParam, $LParam)
    If $MsgID = $WM_COPYDATA Then
        Local
$vs_Msg = _AU3COM_RecvData($LParam)
        Local $sMSGRECVD = DllStructGetData($vs_Msg, 1)
 
        ;Here is go whatever we need to do with the recieved string ($sMSGRECVD)
        GUICtrlSetData($Edit1, $sMSGRECVD)
    EndIf
EndFunc
 
Func
_AU3COM_RecvData($iCOM_LParam)
    ; $COM_LParam = Poiter to a COPYDATA Struct
    Local $STRUCTDEF_AU3MESSAGE = "char var1[256];int"
    Local $StructDef_COPYDATA = "dword var1;dword var2;ptr var3"
    Local $vs_cds = DllStructCreate($StructDef_COPYDATA, $iCOM_LParam)
    ; Member No. 3 of COPYDATA Struct (PVOID lpData;) = Pointer to Costum Struct
    Local $vs_msg = DllStructCreate($STRUCTDEF_AU3MESSAGE, DllStructGetData($vs_cds, 3))
    Return $vs_msg
EndFunc

 
Sender.au3:
 

Код:
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
 
$hGUI = WinGetHandle("[CLASS:AutoIt v3 GUI;TITLE:AU3COM Interaction]")
 
$sMessage = "This is a AU3COM Interaction Test"
 
WinActivate($hGUI)
_AU3COM_SendData($sMessage, $hGUI)
 
Func _AU3COM_SendData($sInfoToSend, $hRecvWinHandle)
    Local $StructDef_COPYDATA = "dword var1;dword var2;ptr var3"
    Local $sCDString = DllStructCreate("char var1[256];char var2[256]") ;the array to hold the string we are sending
 
    DllStructSetData($sCDString, 1, $sInfoToSend)
    Local $pCDString = DllStructGetPtr($sCDString) ;the pointer to the string
    Local $vs_cds = DllStructCreate($StructDef_COPYDATA);create the message struct
    DllStructSetData($vs_cds, "var1", 0) ;0 here indicates to the receiving program that we are sending a string
    DllStructSetData($vs_cds, "var2", String(StringLen($sInfoToSend) + 1));tell the receiver the length of the string
    DllStructSetData($vs_cds, "var3", $pCDString) ;the pointer to the string
    Local $pStruct = DllStructGetPtr($vs_cds)
 
    DllCall("User32.dll", "int", "SendMessage", "hwnd", $hRecvWinHandle, "int", $WM_COPYDATA, "int", 0, "ptr", $pStruct)
 
    $vs_cds = 0 ;free the struct
    $sCDString = 0 ;free the struct
 
    Return 1
EndFunc

Всего записей: 3251 | Зарегистр. 01-04-2006 | Отправлено: 12:18 01-02-2009
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 2)
Widok (01-06-2010 13:08): Лимит страниц. Продолжаем здесь.


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru