C# 从另一个独立应用程序获取数据?

发布于 2024-12-09 12:36:58 字数 156 浏览 1 评论 0原文

如何让我的 C# 程序从另一个应用程序获取数据?

假设应用程序是“Yahoo Messenger”,有人在聊天框中对你说“嗨”...

现在,我希望我的 C# 程序从“Yahoo Messenger 聊天框”中读取/获取该数据或信息将其打印在我的申请表上吗?是否可以?

How will I let my c# program to get data from another application?

assume that application is, for example , "Yahoo Messenger" and someone say to you "hi there" on the chatbox...

Now, I want my c# program to read / get that data or information from "Yahoo Messenger chat box" in print it on my application? is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别想她 2024-12-16 12:36:58

您将需要使用 Visual Studio 工具名称 SPY++ 来了解 win32 api 的流程。

之后,请参阅这些链接

从其他应用程序获取文本

http:// /www.dreamincode.net/forums/topic/66140-scraping-the-text-from-another-application-with-win32-api/

实现部分内容后代码,请重新发布与编程相关的更具体的问题

You will need to use visual studio tool name SPY++ for understanding the flow of win32 api.

After that refer to these link

Get text from another application.

http://www.dreamincode.net/forums/topic/66140-scraping-the-text-from-another-application-with-win32-api/

After implementing some part of the code , please repost more specific question related to programming

白衬杉格子梦 2024-12-16 12:36:58

如果该应用程序(例如 Yahoo Messenger)为其他应用程序提供一个接口(例如:COM)来访问其信息,那就很容易了。

如果没有,您将必须通过 Windows API,捕获文本所在的确切窗口的句柄等。

您知道您的其他应用程序是什么吗?

编辑:
检查这个雅虎答案。有人问了同样的问题,也许答案中提供的链接会对您有所帮助: http: //answers.yahoo.com/question/index?qid=20081126161509AAhr6Dz

雅虎问答帖子 内容:

我建议查看 libpurple。这是一个支持 Yahoo 的通用 IM 后端。它被 Pidgin IM 客户端等使用。

但是,请注意 libpurple 是一个 C++ 库,因此您必须调用本机代码。

It will be easy if that application (Yahoo messenger for example) provides an interface (ex: COM) for other applications to access its information.

If not, you will have to go through Windows API, capturing the handle of the exact window where the text is and all.

Have you any idea what your other application is?

EDIT:
Check this Yahoo Answer. Someone has asked the same question, maybe the links provided in the answer would help you: http://answers.yahoo.com/question/index?qid=20081126161509AAhr6Dz

Yahoo Answers post content:

I would suggest looking at libpurple. This is a general-purpose IM backend with Yahoo support. It's used by the Pidgin IM client, among others.

However, note that libpurple is a C++ library, so you'd have to call into native code.

枕花眠 2024-12-16 12:36:58

如果您可以控制“该应用程序”(例如YahooMessenger),您可以使用winapi创建共享内存:

    LPSECURITY_ATTRIBUTES lpAtt=NULL;

    HANDLE INVALID_FILE_HANDLE=(HANDLE)0xFFFFFFFF; //Memory handle
    hMapFile=::CreateFileMapping(INVALID_FILE_HANDLE,
    lpAtt,PAGE_READWRITE, 0,nSize, SharedMemName);
    if (hMapFile == NULL) 
    { 
        ShowSomeMessageBox("Could not create shared memory");
        return NULL;
    }

    LPTSTR pBuf = (LPTSTR) MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS,0,0,nSize);
    if(NULL==pBuf) 
    {
        ShowSomeMessageBox("Could not create mapped view of theshared memory");
        return NULL;
}

一旦您拥有该缓冲区,您可以使用CopyMemory或任何api向其中写入数据。

在您的 C# 应用程序中,您可以使用 InterOp (P-invoke) 来调用 WinAPI:

使用:
OpenFileMapping(),MapViewOfFile()
等打开共享内存

使用:
Marshal.ReadInt32()、Marshal.StructureToPtr()
等将数据读取到 C# 数据结构。

If you have control over "that application" (e.g.Yahoo messenger), you can create a shared memory using winapi:

    LPSECURITY_ATTRIBUTES lpAtt=NULL;

    HANDLE INVALID_FILE_HANDLE=(HANDLE)0xFFFFFFFF; //Memory handle
    hMapFile=::CreateFileMapping(INVALID_FILE_HANDLE,
    lpAtt,PAGE_READWRITE, 0,nSize, SharedMemName);
    if (hMapFile == NULL) 
    { 
        ShowSomeMessageBox("Could not create shared memory");
        return NULL;
    }

    LPTSTR pBuf = (LPTSTR) MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS,0,0,nSize);
    if(NULL==pBuf) 
    {
        ShowSomeMessageBox("Could not create mapped view of theshared memory");
        return NULL;
}

Once you have that buffer, you can write data to it using CopyMemory or whatever api.

In your C# application you can use InterOp (P-invoke) to call WinAPI:

Use:
OpenFileMapping(),MapViewOfFile()
etc. to open the shared memory

Use:
Marshal.ReadInt32(), Marshal.StructureToPtr()
etc to read the data to your C# data structures.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文