简体   繁体   English

Java / SWT应用程序中的控件ID

[英]Control IDs in Java/SWT application

I have a third-party application and I need to read the values of some controls to use them in my own application developed in Delphi. 我有一个第三方应用程序,我需要阅读一些控件的值才能在我自己的用Delphi开发的应用程序中使用它们。 The other application runs on Windows and is obviously written in Java using the SWT framework. 另一个应用程序在Windows上运行,并且显然是使用SWT框架用Java编写的。 Unfortunately the (control) IDs of the controls where I need to read the values are different everytime I start the third-party application. 不幸的是,每次启动第三方应用程序时,需要读取值的控件的(控件)ID都不相同。 It seems that the Java/SWT framework generates new windows/control IDs each time the UI of the application is created. 似乎每次创建应用程序的UI时,Java / SWT框架都会生成新的窗口/控件ID。 Is there any other identifier I could use? 我还能使用其他标识符吗?

You can use the Windows properties to get an ID which is persistent. 您可以使用Windows属性来获取一个永久的ID。

The name of the property is SWT_OBJECT_INDEX: 该属性的名称为SWT_OBJECT_INDEX:

nProp := GetProp(Handle, 'SWT_OBJECT_INDEX');

The return value of GetProp() is the ID of the window. GetProp()的返回值是窗口的ID。 Handle is the handle to your control. 句柄是您控制的句柄。 However, you need to go through all child windows to find the control with the ID you are looking for. 但是,您需要浏览所有子窗口以找到具有您要查找的ID的控件。 Please note that those IDs could change if the application is updated. 请注意,如果更新应用程序,则这些ID可能会更改。

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

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