문제

How to click on Systemtray program through AutoITx in java?

I know there are many library files available like "GuiToolBar.au3" which we need to include in AutoIt program, but we cannot import it in Java, so we cannot use method available in in java while using AutoItX and Jacob library.

도움이 되었습니까?

해결책 2

I achieved this using below code:

public static void Func_LaunchSystrayProgram() throws IOException

{

    try {
        AutoItX objX = new AutoItX();
        int indexinSystray = 3;
        boolean resultflag = false;
        Thread.sleep(2000);
        boolean isfocus = objX.controlFocus(
                "[CLASS:Shell_TrayWnd]", "User Promoted Notification Area",
                "[CLASS:ToolbarWindow32]");
        objX.sleep(2000);

        System.out.println("isfocus:" + isfocus);
        if (isfocus == true) {

            for (int count = 0; count < indexinSystray; count++) {
                boolean clcik = objX.controlSend(
                        "[CLASS:Shell_TrayWnd]", "",
                        "[CLASS:ToolbarWindow32; ID:1504]", "{RIGHT}",
                        false);
                // objX.send("{RIGHT}");
                objX.sleep(1000);
            }
            objX.sleep(1000);


            objX.controlSend("[CLASS:Shell_TrayWnd]",
                    "", "[CLASS:ToolbarWindow32; ID:1504]", "{ENTER}",
                    false);

            String activeWintitle = objX
                    .winGetTitle("[ACTIVE]");

            System.out.println("activeWintitle: " + activeWintitle);
            if ("ProgramTitle".equalsIgnoreCase(activeWintitle)) {
                System.out.println("Title Match");
                resultflag = true;

            } else {
                System.out.println("Title Not Matched");
                resultflag = false;
            }

        } else {
            resultflag = false;
        }

        if (resultflag == true) {
            Update_Report("executed");
        } else {
            Update_Report("failed");
        }

    } catch (Exception e) {
        // TODO Auto-generated catch block
        System.out.println(e.getMessage());
        Update_Report("failed", e);
    }

다른 팁

If it's just a left click then ControlCommand with SendCommandId normally works, and would allow you to do it in native AutoIt.

Alternatively, you will have to import the winapi function directly. Most links seem to point to JNA for that. If you are not sure about what functions to use, then look at the source code for GUIToolbar.au3, and usually it can be figured out from that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top