• 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

    • Well i'll look into a docking station if needed and use that.    Normally i don't usually have all the drives connected at once,  usually once a month to sync the latest files, and then they go back in there storage area   
    • memories! completely forgot about alcohol 120%!!!! man this list just makes me think of all the exciting times! everything's become so sterilized these days. 
    • Salesforce to acquire Fin, formerly Intercom, for over $3 billion by David Uzondu Image via DepositPhotos.com Salesforce today announced that it has reached an agreement with customer support software company Fin to buy the company for around $3.6 billion. Salesforce expects the transaction to close in the fourth quarter of its fiscal year 2027, and the acquisition will not change its financial guidance previously announced on May 27. Marc Benioff, CEO of Salesforce, in its press release, claimed that acquiring the startup gives Salesforce an immediate AI agent that resolves support tickets across email, WhatsApp, SMS, and Slack: You might know Fin by its former name, Intercom. If you have ever been on a website or inside a mobile app and noticed a little chat bubble widget floating in the bottom right corner of your screen, often featuring a friendly face and a message like, "Hi! How can we help you today?" you were almost certainly looking at Intercom. Intercom became Fin just last month, transforming itself into an "AI-first" platform that handles customer issues with little need for humans to intervene. The new name originates from the company's highly successful AI customer service agent, which it launched way back in 2023. This digital assistant supposedly resolves about 76% of customer service volume end-to-end on its own, so the business rebranded to match its primary software tool. Fin's new owners, Salesforce, went on an acquisition spree over the last few years, and some of them you might recognize, like its 2020 $27.7 Billion acquisition of Slack. The last few months saw the enterprise giant buy several startups, including m3ter, Momentum, Cimulate, and Contentful. Salesforce said that when the Fin deal pulls through, customers will "deploy AI agents across" various service operations, which will complement Agentforce, the platform that enables businesses to deploy customizable autonomous digital workers.
  • Recent Achievements

    • 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
    • Conversation Starter
      flexorcist earned a badge
      Conversation Starter
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      +Edouard
      201
    3. 3
      PsYcHoKiLLa
      127
    4. 4
      Steven P.
      82
    5. 5
      ATLien_0
      76
  • Tell a friend

    Love Neowin? Tell a friend!