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