xml
xml
CC#
Created by xml on 2/13/2024 in #help
All Monitor ScreenShot
Even if I have more than one monitor, this code only takes the screenshot of the main monitor, how can I fix this?
public class ScreenCapture
{
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();

[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hWnd);

[DllImport("user32.dll")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);

[DllImport("gdi32.dll")]
public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);

public static Bitmap CaptureDesktop()
{
return CaptureWindow(GetDesktopWindow());
}

public static Bitmap CaptureWindow(IntPtr handle)
{
var rect = new User32.Rect();
User32.GetWindowRect(handle, ref rect);

int width = rect.right - rect.left;
int height = rect.bottom - rect.top;

var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(bmp);
graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);

return bmp;
}
}
public class ScreenCapture
{
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();

[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hWnd);

[DllImport("user32.dll")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);

[DllImport("gdi32.dll")]
public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);

public static Bitmap CaptureDesktop()
{
return CaptureWindow(GetDesktopWindow());
}

public static Bitmap CaptureWindow(IntPtr handle)
{
var rect = new User32.Rect();
User32.GetWindowRect(handle, ref rect);

int width = rect.right - rect.left;
int height = rect.bottom - rect.top;

var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(bmp);
graphics.CopyFromScreen(rect.left, rect.top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);

return bmp;
}
}
29 replies
CC#
Created by xml on 1/30/2024 in #help
Timeslaps and API Requests error
https://hastebin.skyra.pw/ikihibawiq.csharp https://hastebin.skyra.pw/uvujugukid.py my api model
if (existingActivity) {
const updatedActivity = await prismadb.activity.update({
where: { id: existingActivity.id },
data: {
timeslaps: existingActivity.timeslaps + timeslaps,
updatedAt
}
});
return res.status(200).json(updatedActivity);
} else {
const newActivity = await prismadb.activity.create({
data: {
title,
timeslaps,
isProductive,
createdAt,
updatedAt,
user : {
connect : {
macAddress : macAddress
}
}
}
});
return res.status(200).json(newActivity);
if (existingActivity) {
const updatedActivity = await prismadb.activity.update({
where: { id: existingActivity.id },
data: {
timeslaps: existingActivity.timeslaps + timeslaps,
updatedAt
}
});
return res.status(200).json(updatedActivity);
} else {
const newActivity = await prismadb.activity.create({
data: {
title,
timeslaps,
isProductive,
createdAt,
updatedAt,
user : {
connect : {
macAddress : macAddress
}
}
}
});
return res.status(200).json(newActivity);
model Activity { id String @id @default(auto()) @map("_id") @db.ObjectId title String @unique createdAt String? updatedAt String? timeslaps Float isProductive Boolean macAddress String user Employee @relation(fields: [macAddress], references: [macAddress], onDelete: Cascade) } When I first run the code, the popup window still shows 0 seconds when the request is sent, but the counter I set to test is 3 seconds. Also it gives 400 error when requesting the API, I have written the same code before using python and I am trying to write it in C# but there is a problem, what is the reason?
2 replies