本文介绍了向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;
}
推荐答案
#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;
}
这篇关于向Powerpointviewer发送击键.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!