简体   繁体   English

通过java程序打开visio

[英]Open visio by java program

I have opened the visio from java by following code.. 我已经通过以下代码从java打开了visio ..

Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("Visio Example");
        shell.setLayout(new FillLayout());
        try {
            OleFrame frame = new OleFrame(shell, SWT.NONE);
            new OleClientSite(frame, SWT.NONE, "Visio.drawing");
        } catch (SWTError e) {
            System.out.println("Unable to open activeX control");
            display.dispose();
            return;
        }
        shell.setSize(800, 600);
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();

now the problem is that it is opening a page after taking a manual click ie OK 现在问题是它是在手动点击后打开一个页面,即OK

I want to directly jump on new page to draw, what enhancement in my code required to do so ? 我想直接跳转到新页面进行绘制,我的代码需要增强哪些内容?

This can be seen in image too. 这也可以在图像中看到。

thanks. 谢谢。

在此输入图像描述

One solution might be to check out the Java Robot class, I'm not saying it's the ideal solution perhaps far from it but, what the Robot class allows you to do is trigger click events on the screen. 一个解决方案可能是检查Java Robot类,我不是说它是可能远离它的理想解决方案但是,Robot类允许你做的是触发屏幕上的点击事件。 You may want to do this later, if it doesn't solve this particular problem it may be useful later. 您可能希望稍后执行此操作,如果它不能解决此特定问题,则稍后可能会有用。

http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Robot.html

//Something like this
Robot robot = new Robot();
//Where 100 is x and y being the onscreen co-ordinates
robot.mouseMove(100,100);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);

Like is said it may not be the ideal solution but for your intended purposes, you may find it helpful. 据说它可能不是理想的解决方案,但对于您的预期目的,您可能会觉得它很有帮助。

Edit: You could also use this class to do, Key presses. 编辑:您也可以使用此类来执行,按键。 eg hitting tab a few times then enter key. 例如,按几次标签然后输入密钥。 This solution would be far from ideal. 这个解决方案远非理想。 But would do the job IMO 但是会做IMO的工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM