• 0

C# Screen saver?


Question

Recommended Posts

  • 0
The name that appears in the combo-box in the display properties window.

Also, i think exe files can have functions exported, i think i can remember doing it with a linker override thing in vb6

Ok, the screensaver's name is less important to me. If any one else konw a better way to do it please tell me.

  • 0

hijack time. anyone know how to change the context menu links so that when you right click on the desktop and select properties. instead of it pointing to the control panel program it would launch another executable or cpl (but i think cpl is just arenamed exe)

  • 0
hijack time. anyone know how to change the context menu links so that when you right click on the desktop and select properties. instead of it pointing to the control panel program it would launch another executable or cpl (but i think cpl is just arenamed exe)

a cpl file is a dll file with a function called cpl exported. it takes care of telling windows it's name, description and icon, and launching it when it's double-clicked.

  • 0

This is quite stupid... a screen saver should support the /p <hwnd> command line. I've tried everything I could think of to get this to work, including the C-dll to no avail. Maybe there is some obscure/unknown issue with .NET interop and screensavers, though I wouldn't think so.

  • 0

Hello everyone

I am a chinese and I slept away my english lessons for all time that i can't understand English sentence exactly

But could that code can helps you?

using System.Drawing;
.
.
.

IDataObject d=Clipboard.GetDataObject();
if(d.GetDataPresent(DataFormats.Bitmap))
{
Bitmap B=(Bitmap)d.GetData(DataFormats.Bitmap);
}

Now you get a bitmap-type object " B" which contains a picture, namely,The Sreansaver.

  • 0
But how does it get the screen saver ?

Use Print Screen Button!

That's easy.But you must know API Program.

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Then you can press that button "Print Screen Sys Rq"

Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
DoEvents//Must do this or Windows will do nothing on Runtime

Then that button will be pressed really!

This is VB.net style.

You can write it in C# like:

using System.Runtime.InteropServices;
.
.
.
.
[DllImport("user32.dll")]
public static extern void keybd_event (Byte bVk, Byte bScan , Long dwFlags ?, Long dwExtraInfo )

then use that method to press any Keys like "Print Sreen"

Oh!

I forgot it!

VK_SNAPSHOT is a Byte '&H2C'

It's the number of the Key(Print Screen)

Edited by nkorls
  • 0

Oh my Muh!!

I am wrong in the begining..

it looks as I had better study English hard

you can use this

PostMessage(WM_SYSCOMMAND,SC_SCREENSAVE,0);

to act current ScreenSaver

I think you want to get current Screen picture at the begining.

faint~

this is the code;

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
 ? ?Private Const HWND_BROADCAST = &amp;HFFFF&amp;
 ? ?Private Const WM_SYSCOMMAND = &amp;H112
 ? ?Private Const SC_SCREENSAVE = &amp;HF140&amp;

 ? ?Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 ? ? ? ?SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, 0)
 ? ?End Sub

I use VB more than C#.

So this code is in VB style.

Edited by nkorls
  • 0

But this just activates the screensaver. I want to show it as a preview. Like in the screenshot. I don't want to show the screen saver on the full screen but just in a picture box. I want to show the screensaver in preview mode inside the picture box. How can I do it? Please try to write in c#. Otherwise I have to use a special program to conver it to c# :no:

  • 0
But this just activates the screensaver. I want to show it as a preview. Like in the screenshot. I don't want to show the screen saver on the full screen but just in a picture box. I want to show the screensaver in preview mode inside the picture box. How can I do it? Please try to write in c#. Otherwise I have to use a special program to conver it to c#  :no:

So you can use Command Line to run the ScreenSaveer file like this

c:\winnt\system32\mysc.msc /p <HWND>

<HWND> is the window to display the Preview

How to get the HWND?

You can Use this API:

?[DllImport("user32.dll")]
 ?public static extern int FindWindow(String lpClassName,String lpWindowName);

lpClassName is the name of the class

lpWindowName is the name of the title bar

and run it like

System.Diagnostics.Process.Start(@"C:\winnt\system32\ss3dfo.scr /p "+FindWindow(classname,windownname).toString());

Edited by nkorls
  • 0
If I want to show the screensaver in a picturebox, can't I use pictureBox1.Handle.ToString() to find the HWND ?

HWND Must be a handle of a Window

Someone told me that in MSDN.

and the preview window is the Child-Window of the HWND-window.

That is a Chinese article,I am not a translator,I hope you can understand those word

Edited by nkorls
  • 0
OK, so if I have a picture box called picturebox1 - How do I find its HWND?

And what do I have to write in classname and windownname?

Write it like : FindWindow(null, "Form1")

That is.

I don't remember how to find the handle of a control,I am in my Friend's home and there is No .net Framework on her computer now,So you can search the result on google.com or MSDN yourself.

Time to bed now,bye-bye

By the way: how about my English expression?

I Join this English forum is for studing English mostly.

  • 0

Im working on it now, if i can work out what format windows sends the command arguments in i might be able to make it work

Edit: I wrote a program a while ago that only shows the command line arguments passed to it (to work out i problem i was having with Microangelo Studio, fixed now) it says that windows is passing "/p 4720014" (on my system anyway) for the preview window

Edit 2: i told my test program to load my test app (or scr) it told me i was passing /S to it, but this is my code

Process.Start("C:\Windows\system32\Thingy.scr", "/p " &amp; Me.Handle.ToString)

Edited by The_Decryptor
  • 0

The problem with your approach to the window handle is that .net controls are separate, hidden windows, so you can't use this.Handle. I had the same problem trying to use shell_notifyicon. Use this to get the window handle of your picturebox:

Type t = yourPictureBox.GetType();

IntPtr window = ((NativeWindow)t.GetField("window",System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(yourPictureBox)).Handle;

That should get you your handle.

  • 0

I tried this:

Type t = pictureBox1.GetType();
 IntPtr window = ((NativeWindow)t.GetField("window",System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(pictureBox1)).Handle;


 System.Diagnostics.Process.Start(sc , "/p " + window.ToString());

sc is the path to the screen saver.

But it still shows it in full mode.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • "Samsung is shutting down yet another app used by millions" I will fix the clickbait title for you, free-of-charge: "Samsung shutting down it's Max VPN app"
    • Microsoft brings Planner Agent to all Microsoft 365 Copilot users by Ivan Jenic Image: Microsoft Microsoft has announced that Planner Agent in Microsoft 365 Copilot is now generally available to all users with a Microsoft 365 Copilot license. Planner Agent is the latest addition in the string of AI features that Microsoft is implementing across virtually all of its products. The agent lets you manage tasks through natural language prompts directly inside Microsoft 365 Copilot. You can create and update tasks, check priorities, and get insights about current entries without leaving the chat interface. The general availability release comes with a handful of new additions on top of what was available during the initial rollout. A new plan picker lets you search and filter your plans by name, then update task names, statuses, due dates, or priorities through the agent. There's also a goals bucket now, which lets you group tasks under specific goals. This builds on the Goals view, a feature that was introduced as part of the broader Planner refresh that rolled out earlier. Image: Microsoft | Planner Agent in Microsoft 365 Copilot All AI-generated plans and tasks are created in draft mode by default, so you can review and approve changes before anything goes through. This is actually a thoughtful safety feature, because trusting AI to handle all your tasks without a human in the loop is usually a recipe for disaster. Having tasks initially saved as drafts is the best possible middle ground. Microsoft also says that not all tasks are executed equally. Simple tasks get processed quickly, while more complex ones, like building a plan from a Word, Excel, or PowerPoint file, are handed to a more capable model. Microsoft says this approach delivers the best performance, but it could also help with usage management, as you won't have to waste tokens on performing simple tasks. Planner Agent is available now across Teams, Loop, SharePoint, and other Microsoft 365 apps for anyone on a Microsoft 365 Copilot subscription.
    • To be clear I'm anti trump, the bigger point is why review this game at all?
    • Trillion dollar Microsoft has to reduce spending by hurting more people. Good job Microsoft. Good Job Asha.
    • That's a shame. The big Xbox reset when Phil and Sarah left and then Asha came on and brought a new team of executives, and all the layoffs last year and saying that the ABK merger wouldn't result in redundancies I am surprised they are calling for yet another reset and yet more layoffs.
  • Recent Achievements

    • First Post
      Cosminus earned a badge
      First Post
    • One Year In
      ThatGuyOnline earned a badge
      One Year In
    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      500
    2. 2
      +Edouard
      194
    3. 3
      PsYcHoKiLLa
      125
    4. 4
      Steven P.
      87
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!