gpt4 book ai didi

c# - cefsharp改变传给网站的参数屏幕的宽高c#

转载 作者:行者123 更新时间:2023-12-05 07:42:30 25 4
gpt4 key购买 nike

你能帮忙吗,你如何改变cefsharp传输的屏幕尺寸?我去 ipleak.net 看到了您的屏幕:1920 x 1080可用屏幕:1920 x 1040

有什么办法可以改变吗?

我试过了,没用

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();

settings.CefCommandLineArgs.Add("Screen-width", "800");
settings.CefCommandLineArgs.Add("Screen-height", "600");

最佳答案

我发现,这可以通过 chrome DevTools 协议(protocol)使用 setDeviceMetrics 实现方法。非常感谢 amaitland!

var client = browser.GetDevToolsClient();
await client.Emulation.SetDeviceMetricsOverrideAsync(1000, 800, 1, true);

在使用此方法之前,您还需要完全初始化 CefSharp 浏览器。

关于c# - cefsharp改变传给网站的参数屏幕的宽高c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44459440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com