向Powerpointviewer发送击键. [英] sending keystrokes to powerpointviewer.

查看:109
本文介绍了向Powerpointviewer发送击键.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过我的应用程序向Powerpoint Viewer发送击键.当我向应用程序提供输入时,它会扫描输入并使用sendmessage()将相应的击键发送给P.P.viewer.
但是sendmessage()无法正常工作.输入不会传递给查看器.请帮助我发送输入.还让我知道错误在哪里.

这是我的代码:

I am sending keystrokes to power point viewer through my application. When i give input to my application it scans input and sends the corresponding keystroke to P.P.viewer using sendmessage().
But the sendmessage() is not working. the input is not passed to the viewer. pls help me in sending input.also let me know where the mistake is.

here is my code:

#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#define VK_N 0x4E
#define VK_P 0x50
#define WN_KEYUP 0x0101
#define WN_KEYDOWN 0x0100

int _tmain(int argc, _TCHAR* argv[])
{	
	char c;
	HWND hwnd;
	printf("make the target window topmost");
	Sleep(10000);  
	hwnd=GetForegroundWindow();
	//hwnd=FindWindow(NULL,PPTVIEW); 
	//if i want to use find window, how to get the classname and windowname of P.P.viewer??
	SetWindowPos(hwnd,HWND_TOPMOST,600,0,500,500,NULL);
	printf("\n caught handle now press p for previous slide and n for next slide");
	// now the input is given to my app which will scan and sendmessage to P.P.viewer.
	while(1)
	{
	scanf("%c",&c);
	switch(c)
		{
		case 'n':
			SendMessage(hwnd, WM_KEYDOWN, VK_N, 0);//this should take me to next slide
			flushall();
			break;
		case 'p':
			SendMessage(hwnd, WM_KEYDOWN, VK_P, 0);// this should take me to previous slide
			flushall();
			break;
		default:
			printf("enter n for next slide and p for previous slide");
			break;
		}
	}
	return 0;
}

推荐答案

在上面的代码中,从逻辑上讲,您似乎将Power Point窗口置于最顶部(如果使用的是FindWindow).并且仍然希望收到您的应用程序的输入.

但是实际上,当您运行应用程序时,最终会收到自己的窗口句柄的句柄. (如果您使用的是GetForegroundWindow())
In the above code Logically, it seems that you''re making the Power Point window top most window (if you''re using FindWindow). And still expecting to receive input to your application.

But actually when you run your application you end-up with receiving handle to your own window handle. (if you are using GetForegroundWindow() )


感谢您的帮助..我发现了如何使用findwindow.下面的代码应该将密钥传递给ppviewer,但没有传递.请告诉我参数是否错误或发送消息是否有问题.

Thanks for helping.. I had found how to use findwindow. The below code should pass the keys to ppviewer, but it is not passing. pls tell me whether the parameters are incorrect or its problem with send message.

#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#define VK_N 0x4E
#define VK_P 0x50
#define WN_KEYUP 0x0101
#define WN_KEYDOWN 0x0100
 
int _tmain(int argc, _TCHAR* argv[])
{	
	char c;
	HWND hwnd;
	hwnd=FindWindow(NULL,L"Powerpoint Viewer Slide Show - [Injection_Attacks.ppt]"); 
	printf("\n caught handle now press p for previous slide and n for next slide");
	// now the input is given to my app which will scan and sendmessage to P.P.viewer.
	while(1)
	{
	scanf("%c",&c);
	switch(c)
		{
		case 'n':
			SendMessage(hwnd, WM_KEYDOWN, VK_N, 0);//this should take me to next slide
			flushall();
			break;
		case 'p':
			SendMessage(hwnd, WM_KEYDOWN, VK_P, 0);// this should take me to previous slide
			flushall();
			break;
		default:
			printf("enter n for next slide and p for previous slide");
			break;
		}
	}
	return 0;
}


使用
Use the SendInput[^] function to inject keystrokes.


这篇关于向Powerpointviewer发送击键.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆