本文整理汇总了Java中com.sun.jna.platform.win32.WinDef.RECT类的典型用法代码示例。如果您正苦于以下问题:Java RECT类的具体用法?Java RECT怎么用?Java RECT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RECT类属于com.sun.jna.platform.win32.WinDef包,在下文中一共展示了RECT类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: capture
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
public BufferedImage capture(final HWND hWnd) {
final HDC hdcWindow = User32.INSTANCE.GetDC(hWnd);
final HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow);
final RECT bounds = new RECT();
User32Extra.INSTANCE.GetClientRect(hWnd, bounds);
final int width = bounds.right - bounds.left;
final int height = bounds.bottom - bounds.top;
if (width * height <= 0) { return null; }
final HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcWindow, width, height);
final HANDLE hOld = GDI32.INSTANCE.SelectObject(hdcMemDC, hBitmap);
GDI32Extra.INSTANCE.BitBlt(hdcMemDC, 0, 0, width, height, hdcWindow, 0, 0, WinGDIExtra.SRCCOPY);
GDI32.INSTANCE.SelectObject(hdcMemDC, hOld);
GDI32.INSTANCE.DeleteDC(hdcMemDC);
final BITMAPINFO bmi = new BITMAPINFO();
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
final Memory buffer = new Memory(width * height * 4);
GDI32.INSTANCE.GetDIBits(hdcWindow, hBitmap, 0, height, buffer, bmi, WinGDI.DIB_RGB_COLORS);
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
image.setRGB(0, 0, width, height, buffer.getIntArray(0, width * height), 0, width);
GDI32.INSTANCE.DeleteObject(hBitmap);
User32.INSTANCE.ReleaseDC(hWnd, hdcWindow);
return image;
}
开发者ID:friedlwo,项目名称:AppWoksUtils,代码行数:39,代码来源:Paint.java
示例2: getWindowRect
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
public static Rectangle getWindowRect(Pointer hWnd) throws JnaUtilException {
if (hWnd == null) {
throw new JnaUtilException(
"Failed to getWindowRect since Pointer hWnd is null");
}
Rectangle result = null;
RECT rect = new RECT();
boolean rectOK = user32.GetWindowRect(hWnd, rect);
if (rectOK) {
int x = rect.left;
int y = rect.top;
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
result = new Rectangle(x, y, width, height);
}
return result;
}
开发者ID:HearthStats,项目名称:HearthStats.net-Uploader,代码行数:19,代码来源:JnaUtil.java
示例3: main
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* @param args (ignored)
*/
public static void main(String[] args)
{
System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS));
User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {
@Override
public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
{
enumerate(hMonitor);
return 1;
}
}, new LPARAM(0));
}
开发者ID:msteiger,项目名称:MonitorBrightness,代码行数:20,代码来源:MonitorInfoDemo.java
示例4: MonitorControllerJna
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
public MonitorControllerJna()
{
System.out.println("Monitors: " + User32.INSTANCE.GetSystemMetrics(User32.SM_CMONITORS));
User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {
@Override
public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
{
System.out.println("Monitor handle: " + hMonitor);
MONITORINFOEX info = new MONITORINFOEX();
User32.INSTANCE.GetMonitorInfo(hMonitor, info);
System.out.println(info.rcMonitor);
DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors);
int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();
System.out.println("Physical monitors for " + hMonitor + ": " + monitorCount);
PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);
for (PHYSICAL_MONITOR mon : physMons)
{
String desc = new String(mon.szPhysicalMonitorDescription);
monitors.add(new MonitorJna(mon.hPhysicalMonitor, desc));
}
return 1;
}
}, new LPARAM(0));
}
开发者ID:msteiger,项目名称:MonitorBrightness,代码行数:35,代码来源:MonitorControllerJna.java
示例5: WindowHolder
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
public WindowHolder(HWND parentWindow, RECT rect) {
super();
this.parentWindow = parentWindow;
this.rect = rect;
}
开发者ID:frolovm,项目名称:poker-bot,代码行数:6,代码来源:WindowHolder.java
示例6: update
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
@Override
public void update(float delta) {
compWin.update(delta, window);
if (run) {
if (thumbnail.getValue() != 0)
DWMapiExt.INSTANCE.DwmUnregisterThumbnail(new INT_PTR(thumbnail.getValue()));
DWMapiExt.INSTANCE.DwmRegisterThumbnail(local, hwndWin, thumbnail);
SIZE size = new SIZE();
DWMapiExt.INSTANCE.DwmQueryThumbnailSourceSize(new INT_PTR(thumbnail.getValue()), size);
size.read();
float aspectX = (float) size.cx / (float) size.cy;
float aspectY = (float) size.cy / (float) size.cx;
DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();
props.dwFlags = DWM_TNP.DWM_TNP_VISIBLE | DWM_TNP.DWM_TNP_RECTDESTINATION | DWM_TNP.DWM_TNP_OPACITY;
props.fVisible = true;
props.opacity = (byte) 0xFF;
props.rcDestination = new RECT();
if (size.cx > size.cy) {
props.rcDestination.left = 5;
props.rcDestination.top = 100 - (int) (190 / aspectX / 2);
props.rcDestination.right = props.rcDestination.left + 190;
props.rcDestination.bottom = props.rcDestination.top + (int) (190 / aspectX);
} else {
props.rcDestination.left = 100 - (int) (190 / aspectY / 2);
props.rcDestination.top = 5;
props.rcDestination.right = props.rcDestination.left + (int) (190 / aspectY);
props.rcDestination.bottom = props.rcDestination.top + 190;
}
props.write();
DWMapiExt.INSTANCE.DwmUpdateThumbnailProperties(new INT_PTR(thumbnail.getValue()), props);
//DWMapiExt.INSTANCE.InvokeAeroPeek(true, hwndWin, local, 3, new INT_PTR(32), 0x3244);
//DWMapiExt.INSTANCE.DwmpActivateLivePreview(1, hwndWin, local, 1);
TaskManager.addTask(() -> window.setVisible(true));
run = false;
}
}
开发者ID:Guerra24,项目名称:NanoUI,代码行数:42,代码来源:WindowPreview.java
示例7: search
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Searches a rectangle of pixels for the pixel color provided.
*
* @param left
* left coordinate of rectangle.
* @param top
* top coordinate of rectangle.
* @param right
* right coordinate of rectangle.
* @param bottom
* bottom coordinate of rectangle.
* @param color
* Colour value of pixel to find (in decimal or hex).
* @param shadeVariation
* A number between 0 and 255 to indicate the allowed number of
* shades of variation of the red, green, and blue components of
* the colour. Default is 0 (exact match).
* @param step
* Instead of searching each pixel use a value larger than 1 to
* skip pixels (for speed). E.g. A value of 2 will only check
* every other pixel. Default is 1.
* @return Return a 2 element array containing the pixel's coordinates if
* success, return null if color is not found.
*/
public static int[] search(final int left, final int top, final int right,
final int bottom, final int color, Integer shadeVariation,
Integer step) {
final POINT point = new POINT();
if ((shadeVariation == null) || (shadeVariation < 0)
|| (shadeVariation > 255)) {
shadeVariation = 0;
}
if ((step == null) || (step <= 0)) {
step = DEFAULT_STEP;
}
RECT rect = new RECT();
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
autoItX.AU3_PixelSearch(rect, color, shadeVariation, step, point);
return hasError() ? null : new int[] { point.x, point.y };
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:47,代码来源:Pixel.java
示例8: getHSWindowBounds
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
public Rectangle getHSWindowBounds() {
RECT bounds = new RECT();
User32Extra.INSTANCE.GetWindowRect(windowHandle, bounds);
return bounds.toRectangle();
}
开发者ID:HearthStats,项目名称:HearthStats.net-Uploader,代码行数:6,代码来源:ProgramHelperWindows.java
示例9: getClientSize
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the size of a given window's client area.
*
* If the window is minimized, the returned height is null. However,
* getClientSize works correctly on (non-minimized) hidden windows. If the
* window title "Program Manager" is used, the function will return the size
* of the desktop. getClientSize("") matches the active window. If multiple
* windows match the criteria, the most recently active window is used.
*
* @param title
* The title of the window to read.
* @param text
* The text of the window to read.
* @return Returns the size of the window's client area if success, returns
* null if windows is not found or window is minimized.
*/
public static int[] getClientSize(final String title, final String text) {
int[] clientSize = null;
if (!minimized(title, text)) {
RECT rect = new RECT();
autoItX.AU3_WinGetClientSize(stringToWString(defaultString(title)),
stringToWString(text), rect);
if (!hasError()) {
clientSize = new int[] { rect.right - rect.left,
rect.bottom - rect.top };
}
}
return clientSize;
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:30,代码来源:Win.java
示例10: getPos
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the position of a given window.
*
* getPos returns null for minimized windows, but works fine with
* (non-minimized) hidden windows. If the window title "Program Manager" is
* used, the function will return [0, 0]. If multiple windows match the
* criteria, the most recently active window is used.
*
* @param title
* The title of the window to read.
* @param text
* The text of the window to read.
* @return Returns the position of the window if success, return null if
* windows is not found or window is minimized.
*/
public static int[] getPos(final String title, final String text) {
int[] pos = null;
if (!Win.minimized(title, text)) {
RECT rect = new RECT();
autoItX.AU3_WinGetPos(stringToWString(defaultString(title)),
stringToWString(text), rect);
if (!hasError()) {
pos = new int[] { rect.left, rect.top };
}
}
return pos;
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:29,代码来源:Win.java
示例11: getSize
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the size of a given window.
*
* getSize returns null for minimized windows, but works fine with
* (non-minimized) hidden windows. If the window title "Program Manager" is
* used, the function will return the size of the desktop. If multiple
* windows match the criteria, the most recently active window is used.
*
* @param title
* The title of the window to read.
* @param text
* The text of the window to read.
* @return Returns the size of the window if success, returns null if
* windows is not found or window is minimized.
*/
public static int[] getSize(final String title, final String text) {
int[] size = null;
if (!minimized(title, text)) {
RECT rect = new RECT();
autoItX.AU3_WinGetPos(stringToWString(defaultString(title)),
stringToWString(text), rect);
if (!hasError()) {
size = new int[] { rect.right - rect.left,
rect.bottom - rect.top };
}
}
return size;
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:29,代码来源:Win.java
示例12: checksum
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Generates a checksum for a region of pixels.
*
* Performing a checksum of a region is very time consuming, so use the
* smallest region you are able to reduce CPU load. On some machines a
* checksum of the whole screen could take many seconds!
*
* A checksum only allows you to see if "something" has changed in a region
* - it does not tell you exactly what has changed.
*
* When using a step value greater than 1 you must bear in mind that the
* checksumming becomes less reliable for small changes as not every pixel
* is checked.
*
* @param left
* left coordinate of rectangle.
* @param top
* top coordinate of rectangle.
* @param right
* right coordinate of rectangle.
* @param bottom
* bottom coordinate of rectangle.
* @param step
* Instead of checksumming each pixel use a value larger than 1
* to skip pixels (for speed). E.g. A value of 2 will only check
* every other pixel. Default is 1.
* @return Returns the checksum value of the region.
*/
public static int checksum(final int left, final int top, final int right,
final int bottom, Integer step) {
if ((step == null) || (step <= 0)) {
step = DEFAULT_STEP;
}
RECT rect = new RECT();
rect.left = left;
rect.top = top;
rect.right = right;
rect.bottom = bottom;
return autoItX.AU3_PixelChecksum(rect, step);
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:41,代码来源:Pixel.java
示例13: getPos
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the position of a control relative to it's window.
*
* When using a control name in the Control functions, you need to add a
* number to the end of the name to indicate which control. For example, if
* there two controls listed called "MDIClient", you would refer to these as
* "MDIClient1" and "MDIClient2".
*
* @param title
* The title of the window to access.
* @param text
* The text of the window to access.
* @param control
* The control to interact with.
* @return Returns the position of the control if success, returns null if
* failed.
*/
public static int[] getPos(final String title, final String text,
final String control) {
RECT rect = new RECT();
autoItX.AU3_ControlGetPos(stringToWString(defaultString(title)),
stringToWString(text), stringToWString(defaultString(control)),
rect);
return hasError() ? null : new int[] { rect.left, rect.top };
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:27,代码来源:Control.java
示例14: getSize
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the size of a control.
*
* When using a control name in the Control functions, you need to add a
* number to the end of the name to indicate which control. For example, if
* there two controls listed called "MDIClient", you would refer to these as
* "MDIClient1" and "MDIClient2".
*
* @param title
* The title of the window to access.
* @param text
* The text of the window to access.
* @param control
* The control to interact with.
* @return Returns the size of the control if success, returns null if
* failed.
*/
public static int[] getSize(final String title, final String text,
final String control) {
RECT rect = new RECT();
autoItX.AU3_ControlGetPos(stringToWString(defaultString(title)),
stringToWString(text), stringToWString(defaultString(control)),
rect);
return hasError() ? null : new int[] { rect.right - rect.left,
rect.bottom - rect.top };
}
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:28,代码来源:Control.java
示例15: capture
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
private static BufferedImage capture(HWND hWnd) throws WindowNotFoundException {
HDC hdcWindow = User32.INSTANCE.GetDC(hWnd);
HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow);
RECT bounds = new RECT();
User32Extra.INSTANCE.GetClientRect(hWnd, bounds);
int width = bounds.right - bounds.left;
int height = bounds.bottom - bounds.top;
if(width == 0 || height == 0) throw new peeknick.errormanager.WindowNotFoundException();
HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcWindow, width, height);
HANDLE hOld = GDI32.INSTANCE.SelectObject(hdcMemDC, hBitmap);
GDI32Extra.INSTANCE.BitBlt(hdcMemDC, 0, 0, width, height, hdcWindow, 0, 0, WinGDIExtra.SRCCOPY);
GDI32.INSTANCE.SelectObject(hdcMemDC, hOld);
GDI32.INSTANCE.DeleteDC(hdcMemDC);
BITMAPINFO bmi = new BITMAPINFO();
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
Memory buffer = new Memory(width * height * 4);
GDI32.INSTANCE.GetDIBits(hdcWindow, hBitmap, 0, height, buffer, bmi, WinGDI.DIB_RGB_COLORS);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
image.setRGB(0, 0, width, height, buffer.getIntArray(0, width * height), 0, width);
GDI32.INSTANCE.DeleteObject(hBitmap);
User32.INSTANCE.ReleaseDC(hWnd, hdcWindow);
return image;
}
开发者ID:jardiacaj,项目名称:peeknick,代码行数:41,代码来源:Paint.java
示例16: AU3_ControlGetPos
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the position and size of a control relative to it's window.
*
* When using a control name in the Control functions, you need to add a
* number to the end of the name to indicate which control. For example,
* if there two controls listed called "MDIClient", you would refer to
* these as "MDIClient1" and "MDIClient2".
*
* @param title
* The title of the window to access.
* @param text
* The text of the window to access.
* @param control
* The control to interact with.
* @param rect
*/
public void AU3_ControlGetPos(final WString title, final WString text,
final WString control, final RECT rect);
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:19,代码来源:AutoItX.java
示例17: AU3_PixelChecksum
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Generates a checksum for a region of pixels.
*
* Performing a checksum of a region is very time consuming, so use the
* smallest region you are able to reduce CPU load. On some machines a
* checksum of the whole screen could take many seconds!
*
* A checksum only allows you to see if "something" has changed in a
* region - it does not tell you exactly what has changed.
*
* When using a step value greater than 1 you must bear in mind that the
* checksumming becomes less reliable for small changes as not every
* pixel is checked.
*
* @param rect
* position and size of rectangle
* @param step
* Instead of checksumming each pixel use a value larger than
* 1 to skip pixels (for speed). E.g. A value of 2 will only
* check every other pixel. Default is 1.
* @return Returns the checksum value of the region.
*/
public int AU3_PixelChecksum(final RECT rect, final Integer step);
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:24,代码来源:AutoItX.java
示例18: AU3_PixelSearch
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Searches a rectangle of pixels for the pixel color provided.
*
* @param rect
* position and size of rectangle.
* @param color
* Colour value of pixel to find (in decimal or hex).
* @param shadeVariation
* A number between 0 and 255 to indicate the allowed number
* of shades of variation of the red, green, and blue
* components of the colour. Default is 0 (exact match).
* @param step
* Instead of searching each pixel use a value larger than 1
* to skip pixels (for speed). E.g. A value of 2 will only
* check every other pixel. Default is 1.
* @param point
* Return the pixel's coordinates if success, sets
* oAutoIt.error to 1 if color is not found.
*/
public void AU3_PixelSearch(RECT rect, int color,
Integer shadeVariation, Integer step, POINT point);
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:22,代码来源:AutoItX.java
示例19: AU3_WinGetClientSize
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the size of a given window's client area.
*
* If the window is minimized, the returned width and height values are
* both zero. However, WinGetClientSize works correctly on
* (non-minimized) hidden windows. If the window title "Program Manager"
* is used, the function will return the size of the desktop.
* WinGetClientSize("") matches the active window. If multiple windows
* match the criteria, the most recently active window is used.
*
* @param title
* The title of the window to read.
* @param text
* The text of the window to read.
* @param rect
*/
public void AU3_WinGetClientSize(final WString title,
final WString text, RECT rect);
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:19,代码来源:AutoItX.java
示例20: AU3_WinGetPos
import com.sun.jna.platform.win32.WinDef.RECT; //导入依赖的package包/类
/**
* Retrieves the position and size of a given window.
*
* WinGetPos returns negative numbers such as -32000 for minimized
* windows, but works fine with (non-minimized) hidden windows. If the
* window title "Program Manager" is used, the function will return the
* size of the desktop. If multiple windows match the criteria, the most
* recently active window is used.
*
* @param title
* The title of the window to read.
* @param text
* The text of the window to read.
* @param rect
*/
public void AU3_WinGetPos(final WString title, final WString text,
RECT rect);
开发者ID:wangzhengbo,项目名称:JAutoItX,代码行数:18,代码来源:AutoItX.java
注:本文中的com.sun.jna.platform.win32.WinDef.RECT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论