كيفية قراءة محتويات الشاشة من تطبيق آخر [Office Communicator

StackOverflow https://stackoverflow.com/questions/3764208

سؤال

معرفة hwnd من النافذة ، كيف أقرأ محتويات هذا؟ قبل أن يسألني أحد ، أحاول الحصول على النص الذي تم استخدامه في نافذة التواصل.

فيما يلي الرمز الذي وجدته على الإنترنت. الكود ليس لي.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace EventFun
{
class EventHookUp
{
    CommunicatorAPI.Messenger mCommunicator = null;

    static void Main(string[] args)
    {
        EventHookUp hu = new EventHookUp();
        hu.InitializeEventHocks();
        Console.ReadKey();
    }

    public void InitializeEventHocks()
    {
        mCommunicator = new CommunicatorAPI.Messenger();
        mCommunicator.OnIMWindowCreated += new CommunicatorAPI.DMessengerEvents_OnIMWindowCreatedEventHandler(mCommunicator_OnIMWindowCreated);
        mCommunicator.OnIMWindowDestroyed += new CommunicatorAPI.DMessengerEvents_OnIMWindowDestroyedEventHandler(mCommunicator_OnIMWindowDestroyed);
    }

    void mCommunicator_OnIMWindowCreated(object pIMWindow)
    {
        CommunicatorAPI.IMessengerConversationWndAdvanced stpIMWindow = pIMWindow as CommunicatorAPI.IMessengerConversationWndAdvanced;
        //stpIMWindow.History;
        long Hwnd = (long)stpIMWindow.HWND;
        Console.WriteLine("New IM Window Created : {0}", Hwnd);

        CommunicatorAPI.IMessengerContacts contactList = (CommunicatorAPI.IMessengerContacts)stpIMWindow.Contacts;
        StringBuilder sb = new StringBuilder();
        foreach (CommunicatorAPI.IMessengerContact imc in contactList)
        {
            sb.Append(imc.FriendlyName);
            sb.Append(Environment.NewLine);
        }
        Console.WriteLine(sb.ToString());
    }

    void mCommunicator_OnIMWindowDestroyed(object pIMWindow)
    {
        Console.WriteLine("IM Window Destroyed.");
    }
}
}
هل كانت مفيدة؟

المحلول

يبدو أنك تحاول الحصول على سجل نص المحادثة من نافذة المحادثة؟ لو ذلك، جورج دورزي لديه ممتاز مشاركة مدونة على هذا.

نصائح أخرى

نظرًا لأن منشور المدونة هذا غير متوفر ، فقد استخدمت الطريقة أدناه لاسترداد تاريخ المحادثة:

object obj = msgrAdv.StartConversation(
    CONVERSATION_TYPE.CONVERSATION_TYPE_IM, // Type of conversation
    sipUris, // object array of signin names for having multiple conversations or just a string
    null,
    "Test",
    "1",
    null);

 imWindowHandle = long.Parse(obj.ToString());

 if (imWindow == null) //If there is already an open window...
 {
     imWindow = (IMessengerConversationWndAdvanced)msgrAdv.InstantMessage(sipUris);
 }
 //else there was no open window, we have opened the window using "msgrAdv.StartConversation" so there is a imWindow associated which is implemented in communicator_OnIMWindowCreated.
 //and then...
string history = imWindow.History;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top