[英]Cefsharp change the parameter passed to the site the width and height of the screen c#
can you help, how you can change the screen size, which cefsharp transmits ?你能帮忙吗,如何改变cefsharp传输的屏幕尺寸? I go to ipleak.net and saw Your screen: 1920 x 1080 Available screen: 1920 x 1040我去 ipleak.net 看到你的屏幕:1920 x 1080 可用屏幕:1920 x 1040
Is there any way to change it ?有什么办法可以改变它吗?
I tried that, but it didnt work我试过了,但没有用
DllImport("user32.dll", EntryPoint = "SetWindowPos")]
static extern bool SetWindowPos(
int hWnd, // window handle
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
protected delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
[DllImport("user32.dll")]
protected static extern bool EnumWindows(EnumWindowsProc enumProc, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
protected static extern int GetWindowText(IntPtr hWnd, StringBuilder strText, int maxCount);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
protected static extern int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32.dll")]
protected static extern bool IsWindowVisible(IntPtr hWnd);
public static IntPtr m_hwndForm;
protected static bool EnumTheWindows(IntPtr hWnd, IntPtr lParam)
{
int size = GetWindowTextLength(hWnd);
if (size++ > 0 && IsWindowVisible(hWnd))
{
StringBuilder sb = new StringBuilder(size);
GetWindowText(hWnd, sb, size);
string strName = sb.ToString();
if (strName.Contains("Form111111"))
m_hwndForm = hWnd;
}
return true;
}
...
EnumWindows(new EnumWindowsProc(EnumTheWindows), IntPtr.Zero);
SetWindowPos(m_hwndForm.ToInt32(), 0, 10, 20, 600, 800, 0x0040);
InitializeChromium();
or或
settings.CefCommandLineArgs.Add("Screen-width", "800");
settings.CefCommandLineArgs.Add("Screen-height", "600");
I've found, that's possible through chrome DevTools protocol using setDeviceMetrics method.我发现,这可以通过使用setDeviceMetrics方法的 chrome DevTools 协议实现。 Many thanks to amaitland!非常感谢amaitland!
var client = browser.GetDevToolsClient();
await client.Emulation.SetDeviceMetricsOverrideAsync(1000, 800, 1, true);
You also need to fully initialize CefSharp browser before use this method.在使用此方法之前,您还需要完全初始化 CefSharp 浏览器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.