滚动到ADOBE READER使用按钮C# [英] Scroll into a Adobe Reader using buttons c#
问题描述
我已经创建了我从工具箱中使用步骤中添加ADOBE READER一个简单的形式
I Have Created a Simple form in which i have added Adobe Reader from toolbox using steps
- 右键单击工具箱 - 选择项目
- 选择COM组件选项卡,并有的Adobe PDF阅读器
- 现在,拖放放大器;掉落在Adobe PDF阅读器控制到一个用户控件
我已经成功添加这一点,开辟了一个PDF文件也。现在,它自动通过PDF文档滚动垂直滚动条提供。
I have successfully added this, opened up a pdf file also. Now it automatically provides with vertical scrollbars for scrolling through the pdf document.
我想要实现的是,而不是使用给定的滚动条或鼠标滚动,我想用一个按钮来滚动滚动PDF,那么将有两个按钮,一个用于向上滚动,另一个用于向下滚动。
What i want to achieve is instead of using the given scrollbars or mouse to scroll, i want to use a button to scroll scroll the pdf, So there will be two buttons, One for Scroll Up And the other for scroll down.
我经历了很多论坛,网页等了Havnt发现anythn,我可以用。
I have gone through many forums, pages, etc. Havnt found anythn that i could use.
我曾尝试模拟键presses以
I have Tried Simulating key presses with
SendKeys.Send("{DOWN}");
但正如我preSS按钮,焦点失去了对Adobe Reader的所以它不工作
But as i press the button, the focus is lost on the adobe reader so it doesnt work
请帮我...我已经花了差不多半天Searchin的一个解决方案。
Pls help me... I have spent almost half a day searchin for a solution
推荐答案
给您提供了只有简单的一张$ C $的C让你都试过了,我要去尝试为您提供一个通用的解决方案 - 在这里,您将需要更换指定的变量:
given that you have provided only a simple piece of code you have tried, i am going to try offer you a generic solution - where you will need to replace the specified variables:
- 按钮名称
- 您的Web应用程序名称
作为第一重点,你需要指定它会沿着线的东西:
as for first of the focus you need to specify where it will be, something along the lines of:
var pFocus = webapplication.formname.pdf_document.focus();
// or webapplication.focus(pdf_document);
再次我只是写这虽然我已经说过,你将需要更换列出的变量这个工作,可能调整的重点code,因为我没有测试过一个理想的布局 - 按钮但前提您插入变量名称将作为我已经测试过这些:
again i am just writing this as an ideal layout as i have said you will need to replace the listed variables for this to work and possibly tweak the focus code as i haven't tested that - the buttons however provided you insert your variable names will work as i have tested these:
var buttonAction = ((IJavaScriptExecutor)webapplication).ExecuteScript("window.scrollTo(0, document.body.scrollHeight - 5)");
var buttonAction_2 = ((IJavaScriptExecutor)webapplication).ExecuteScript("window.scrollTo(0, document.body.scrollHeight 0)");
//button action will scroll to x co-ordinate 0(far left), y co-ordinate( 5px from bottom)
//buttonAction_2 will return you to the very top left of page, you can edit these values to mess around and try different settings.
这么干脆看起来应该有点类似(如果您正在使用点击的方法只需插入code下有:
so altogether it should look somewhat similar to (if you are using a method for the click just insert the code under there:
var pFocus = webapplication.formname.pdf_document.focus();
if (button.click = true)
webapplication = pFocus;
var buttonAction = ((IJavaScriptExecutor)webapplication).ExecuteScript("window.scrollTo(0, document.body.scrollHeight - 5)");
pFocus.execute(buttonAction);
然后按钮2
var pFocus = webapplication.formname.pdf_document.focus();
if (button_2.click = true)
webapplication = pFocus;
var buttonAction_2 = ((IJavaScriptExecutor)webapplication).ExecuteScript("window.scrollTo(0, document.body.scrollHeight 0)");
pFocus.execute(buttonAction_2);
希望这有助于在一定程度上。
hope this helps to some extent.
这篇关于滚动到ADOBE READER使用按钮C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!