3

I have opened the visio from java by following code..

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 i.e. 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.

enter image description here

  • I can't understand the problem, just explain it in detail. – Alanmars Feb 15 '12 at 12:46
  • @Bloodwolf I need to open the Visio drawing page by java program that i opened by above code now the problem is that it required a manual click to open new drawing page that i want remove. I want to load a visio balnk page by default i hope it would be enough to understand the problem. –  Feb 15 '12 at 12:54
  • What is causing that OK button to appear? – Oleg Mikheev Feb 15 '12 at 13:45
  • i have write the code to open visio by OleClinetSite it opened the visio but it need a manual click to opened a new page i think i am repeating the problem it is quite simple as u have code above which allow u to see that it is interfacing with visio but not open a new drawing page thats it. –  Feb 15 '12 at 13:56

1 Answers1

0

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. 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

//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. e.g hitting tab a few times then enter key. This solution would be far from ideal. But would do the job IMO

Fred
  • 1,486
  • 1
  • 9
  • 6