Java 类com.sun.jna.platform.win32.WTypes 实例源码

项目:ui-automation    文件:Ole32Wrapper.java   
/**
 * Creates the wrapper.
 */
private void createWrapper() {
    CANALIZED_OLE32_INSTANCE = Canalizer.canalize(com.sun.jna.platform.win32.Ole32.INSTANCE);

    CANALIZED_OLE32_INSTANCE.CoInitializeEx(Pointer.NULL, Ole32.COINIT_APARTMENTTHREADED);

    PointerByReference pbr = new PointerByReference();

    WinNT.HRESULT hr = CANALIZED_OLE32_INSTANCE.CoCreateInstance(
            IUIAutomation.CLSID,
            null,
            WTypes.CLSCTX_SERVER,
            IUIAutomation.IID,
            pbr);

    COMUtils.checkRC(hr);

    unknown = new Unknown(pbr.getValue());
}
项目:ui-automation    文件:UIAutomationTest.java   
@Test
public void testCreatePropertyCondition() {
    UIAutomation instance = UIAutomation.getInstance();

    Variant.VARIANT.ByValue variant = new Variant.VARIANT.ByValue();
    WTypes.BSTR sysAllocated = OleAuto.INSTANCE.SysAllocString("SOMETHING");
    variant.setValue(Variant.VT_BSTR, sysAllocated);

    try {
        try {
            PointerByReference pCondition = instance.createPropertyCondition(PropertyID.AutomationId.getValue(), variant);

            Unknown unk = new Unknown(pCondition.getValue());

            PointerByReference pUnknown1 = new PointerByReference();

            WinNT.HRESULT result = unk.QueryInterface(new Guid.REFIID(IUIAutomationCondition.IID), pUnknown1);

            assertTrue("CreatePropertyCondition:" + COMUtils.SUCCEEDED(result), COMUtils.SUCCEEDED(result));
        } catch (AutomationException ex) {
            assertTrue("Exception", false);
        }
    } finally {
        OleAuto.INSTANCE.SysFreeString(sysAllocated);
    }
}
项目:ui-automation    文件:AutomationContainer.java   
/**
 * Get a control, based on the class and the name.
 *
 * Experimental and not currently recommended, doesn't seem to work consistently,
 * also not sufficiently generic, and needs converting to use Search builder maybe.
 *
 * @param type Class to return / check for
 * @param controlType The control type to look for
 * @param name Name to be looked for
 * @param <T> The Type of the class
 * @return Found element
 * @throws PatternNotFoundException Expected pattern not found
 * @throws AutomationException Raised from automation library
 */

public <T extends AutomationBase> T get(Class<T> type,
                                        final ControlType controlType,
                                        final String name)
        throws PatternNotFoundException, AutomationException {

    Variant.VARIANT.ByValue variant1 = new Variant.VARIANT.ByValue();
    variant1.setValue(Variant.VT_INT, controlType.getValue());

    Variant.VARIANT.ByValue variant = new Variant.VARIANT.ByValue();
    WTypes.BSTR sysAllocated = OleAuto.INSTANCE.SysAllocString(name);
    variant.setValue(Variant.VT_BSTR, sysAllocated);

    try {
        PointerByReference propertyCondition = this.automation.createPropertyCondition(PropertyID.ControlType.getValue(), variant1);

        PointerByReference nameCondition = this.automation.createPropertyCondition(PropertyID.Name.getValue(), variant);
        PointerByReference condition = this.automation.createAndCondition(nameCondition, propertyCondition);

        AutomationElement elem = this.findFirst(new TreeScope(TreeScope.Descendants), condition);

        /* Not going to work for menus */
        return type.cast(AutomationControlFactory.get(null, controlType, elem));
    } finally {
        OleAuto.INSTANCE.SysFreeString(sysAllocated);
    }
}
项目:ui-automation    文件:UIAutomationTest.java   
@Test
public void testCreateNotCondition() {
    UIAutomation instance = UIAutomation.getInstance();

    Variant.VARIANT.ByValue variant = new Variant.VARIANT.ByValue();
    WTypes.BSTR sysAllocated = OleAuto.INSTANCE.SysAllocString("SOMETHING");
    variant.setValue(Variant.VT_BSTR, sysAllocated);

    try {
        try {
            // Create first condition to use
            PointerByReference pCondition =
                    instance.createPropertyCondition(PropertyID.AutomationId.getValue(), variant);

            // Create the actual condition
            PointerByReference notCondition =
                    instance.createNotCondition(pCondition);

            // Checking
            Unknown unk = new Unknown(notCondition.getValue());

            PointerByReference pUnknown1 = new PointerByReference();

            WinNT.HRESULT result = unk.QueryInterface(new Guid.REFIID(IUIAutomationCondition.IID), pUnknown1);

            assertTrue("CreateNotCondition:" + COMUtils.SUCCEEDED(result), COMUtils.SUCCEEDED(result));
        } catch (AutomationException ex) {
            assertTrue("Exception", false);
        }
    } finally {
        OleAuto.INSTANCE.SysFreeString(sysAllocated);
    }
}
项目:ui-automation    文件:UIAutomationTest.java   
@Test
public void testCreateAndCondition() {
    UIAutomation instance = UIAutomation.getInstance();

    Variant.VARIANT.ByValue variant = new Variant.VARIANT.ByValue();
    WTypes.BSTR sysAllocated = OleAuto.INSTANCE.SysAllocString("SOMETHING");
    variant.setValue(Variant.VT_BSTR, sysAllocated);

    try {
        try {
            // Create first condition to use
            PointerByReference pCondition0 =
                    instance.createPropertyCondition(PropertyID.AutomationId.getValue(), variant);

            // Create first condition to use
            PointerByReference pCondition1 =
                    instance.createPropertyCondition(PropertyID.AutomationId.getValue(), variant);

            // Create the actual condition
            PointerByReference andCondition =
                    instance.createAndCondition(pCondition0, pCondition1);

            // Checking
            Unknown unk = new Unknown(andCondition.getValue());
            PointerByReference pUnk = new PointerByReference();

            PointerByReference pUnknown1 = new PointerByReference();

            WinNT.HRESULT result = unk.QueryInterface(new Guid.REFIID(IUIAutomationCondition.IID), pUnknown1);

            assertTrue("CreateAndCondition:" + COMUtils.SUCCEEDED(result), COMUtils.SUCCEEDED(result));
        } catch (AutomationException ex) {
            assertTrue("Exception", false);
        }
    } finally {
        OleAuto.INSTANCE.SysFreeString(sysAllocated);
    }
}
项目:ui-automation    文件:UIAutomationTest.java   
@Test
public void testCreateOrCondition() {
    UIAutomation instance = UIAutomation.getInstance();

    Variant.VARIANT.ByValue variant = new Variant.VARIANT.ByValue();
    WTypes.BSTR sysAllocated = OleAuto.INSTANCE.SysAllocString("SOMETHING");
    variant.setValue(Variant.VT_BSTR, sysAllocated);

    try {
        try {
            // Create first condition to use
            PointerByReference pCondition0 =
                    instance.createPropertyCondition(PropertyID.AutomationId.getValue(), variant);

            // Create first condition to use
            PointerByReference pCondition1 =
                    instance.createPropertyCondition(PropertyID.AutomationId.getValue(), variant);

            // Create the actual condition
            PointerByReference condition =
                    instance.createOrCondition(pCondition0, pCondition1);

            // Checking
            Unknown unk = new Unknown(condition.getValue());
            PointerByReference pUnk = new PointerByReference();

            PointerByReference pUnknown1 = new PointerByReference();

            WinNT.HRESULT result = unk.QueryInterface(new Guid.REFIID(IUIAutomationCondition.IID), pUnknown1);

            assertTrue("CreateOrCondition:" + COMUtils.SUCCEEDED(result), COMUtils.SUCCEEDED(result));
        } catch (AutomationException ex) {
            assertTrue("Exception", false);
        }
    } finally {
        OleAuto.INSTANCE.SysFreeString(sysAllocated);
    }
}
项目:proxy-vole    文件:WTypes2.java   
/**
 * Gets the LPWSTR from this pointer. In general its a lot more
 * convenient simply to use {@link getString()}.      
 */
public WTypes.LPWSTR getValue() {
    Pointer p = getPointerToString();
    if (p == null) {
        return null;
    }
    WTypes.LPWSTR h = new WTypes.LPWSTR(p);
    return h;
}
项目:jmccs-win    文件:WindowsMonitor.java   
protected WindowsMonitor(PHYSICAL_MONITOR physical_monitor, HMONITOR hmonitor) throws VCPStringFormatException {
    this.physical_monitor = physical_monitor;
    this.hmonitor = hmonitor;

    DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
    DXVA2.GetCapabilitiesStringLength(physical_monitor.hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);

    int capabilitiesStringLengthInCharacters = pdwCapabilitiesStringLengthInCharacters.getValue().intValue();
    if (capabilitiesStringLengthInCharacters <= 0) {
        throw new VCPStringFormatException("Capability string is empty");
    }

    Pointer p = new Memory(capabilitiesStringLengthInCharacters);
    WTypes.LPSTR pszASCIICapabilitiesString = new WTypes.LPSTR(p);

    DXVA2.CapabilitiesRequestAndCapabilitiesReply(physical_monitor.hPhysicalMonitor,
            pszASCIICapabilitiesString,
            pdwCapabilitiesStringLengthInCharacters.getValue());

    String capabilityString = Native.toString(p.getByteArray(0, capabilitiesStringLengthInCharacters));
    if (capabilityString == null || capabilityString.isEmpty()) {
        throw new VCPStringFormatException("Unable to get capabilities string");
    }

    String vcpString = CapabilityStringParser.parse(capabilityString).get("vcp");
    if (vcpString == null || vcpString.isEmpty()) {
        throw new VCPStringFormatException("Capabilities string is missing the supported VCP codes");
    }

    supportedVCPCodes = VCPStringParser.parse(vcpString);
}
项目:ui-automation    文件:IUIAutomationValuePattern.java   
int setValue(WTypes.BSTR sr);