Script request for button

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Script request for button

Post by Irwin of Upton »

This is my first post and am very excited to be with xyplorer! It looks very powerful but intimidating also. Hope this is not over my head.

Until the lay of the land becomes more obvious would someone be kind enough to supply a script for my very first custom toolbar button. Would simply like to click and have the computer go into sleep mode (Windows 7). No options or anything fancy, just that.

If so inclined, please put in as many comments as you wish to start the journey of discovery for the software's scripting aspects.

Thank you in advance!

Irwin

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Script request for button

Post by klownboy »

Hi Irwin,
Welcome to XYplorer club. I remember my first post. Well, not really. If you open the Address Bar (go to the Menu | Window | Show Address Bar) if it's not aready shown and then in the Address Bar type in "::snippet;" without the quotes. Then enter the following (cut and paste) into the resultant dialog.

Code: Select all

Snip: CTB 1
  XYplorer 14.80.0236, 2/28/2015 2:37:06 PM
Action
  NewUserButton
Name
  Sleep
Icon
  :cfi
ScriptL
  run "C:\Windows\System32\rundll32.exe Powrprof.dll,SetSuspendState Sleep";
ScriptR
  
FireClick
  0
That should create a new button for you called, Sleep. You can change the icon if you'd like by ctrl-right clicking on the icon. You can also see the properties for your Customized Toolbar Button or CTB. Take a look a Sammay's FAQ on Toolbar Buttons if you have a problem or ask a follow-up question. http://www.xyplorer.com/xyfc/viewtopic.php?f=10&t=13364
Good luck and welcome,
Ken

Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Re: Script request for button

Post by Irwin of Upton »

To Ken, a.k.a klownboy

Snippet = a device that automatically creates a button and assigns it a script. How cool is that?

With you kind help have started to climb the learning curve. It looks steep but then a journey of a thousand miles begins with a single step.

Thank you.

Here goes ...

Irwin

Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Re: Script request for button

Post by Irwin of Upton »

To klownboy - Your code above has been a great success as my first installed button.

To back it off a couple of notches for a second button can it be modified to initiate the Screen Saver instead of putting the machine to sleep?

Thank again for your assistance.

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Script request for button

Post by binocular222 »

Change the ScriptL field to

Code: Select all

run "%winsysdir%\scrnsave.scr"
btw, XY is a file manager, not a system tweaker.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Re: Script request for button

Post by Irwin of Upton »

btw, XY is a file manager, not a system tweaker.
Sorry if something was done that violated Forum rules or annoyed anybody.

Thought the idea of the buttons was to get the software to do what the used wanted done. No?

Stef123

Re: Script request for button

Post by Stef123 »

You're taking this too literally. I don't think binocular222 meant this as a serious rebuke. More likely in a joking fashion, tongue-in-cheek lightheared tone of voice.

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Script request for button

Post by binocular222 »

I'm fine with helping people. This forum is full of nice & constructive replies. Don't be afraid.
I just meant don't continue asking XYplorer to change Window system because:
1) There is high priority for portability, which means XYplorer should not touch the system at all
2) XYplorer is designed to manage files & folders only => There are better programs to manipulate Windows system
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Re: Script request for button

Post by Irwin of Upton »

As a newbie did not realize that portability is at the very core of the program's existence. In the future will keep this in mind before making any further requests for help.

Live and learn ...

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Script request for button

Post by PeterH »

Please let me overdraw this: if XY is portable - should you change resident files?

I think what was talked about here was something like automation - by not really changing the system, but only it's state, like sleep. I think this is quite OK.
(Think of copying a lot of files, then shutting down.)

Another situation might be to change the system, e.g. the registry, especially for XY use. At least on a system with just portable YX you should think about it twice. (Think about making XY the default file mgr...)

DixieCup48
Posts: 117
Joined: 30 Jan 2018 14:58

Re: Script request for button

Post by DixieCup48 »

How can this be modified for Windows 10? Cannot seem to get the above code to work :?:

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script request for button

Post by highend »

What happens if rundll32.exe Powrprof.dll,SetSuspendState Sleep is put into a command prompt and executed?
One of my scripts helped you out? Please donate via Paypal

DixieCup48
Posts: 117
Joined: 30 Jan 2018 14:58

Re: Script request for button

Post by DixieCup48 »

Result that came back is:
The system cannot find the file specified
:veryconfused:

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script request for button

Post by highend »

It can't find what, rundll32 or powrprof.dll?
One of my scripts helped you out? Please donate via Paypal

DixieCup48
Posts: 117
Joined: 30 Jan 2018 14:58

Re: Script request for button

Post by DixieCup48 »

Thank you for you work here.

But lets it go. It is above my pay-grade.

Post Reply