Jump to content

How to make Script to be always active


Recommended Posts

I have a small script which will load a black screen saver when Shift+d key is enabled, how do i make this always running in windows10 machine.

and always respond to the hotkey.

New to auatoit, please excuse me for any brevity.

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


HotKeySet("+d", "ShowMessage")  ;Shift+d


While 1
    Sleep(100)
WEnd


Func ShowMessage()

Run("C:\Windows\System32\scrnsave.scr /s")

EndFunc
 

Link to comment
Share on other sites

Looks correct to me. Do you get any error messages? What doesn't work?

BTW: Why don't you use the Windows way and set a shortcut to directly run the Screesaver as described here?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

There might be a redirection issue as he is playing in the system32 folder.  And you do not have any error handling.   Make sure you can run this file from your script by capturing both pid and @error after run function.

 

Edited by Nine
Link to comment
Share on other sites

Only change i did was the hotkey to F2 and it works fine.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

On 4/30/2020 at 5:40 PM, water said:

Looks correct to me. Do you get any error messages? What doesn't work?

BTW: Why don't you use the Windows way and set a shortcut to directly run the Screesaver as described here?

Hey thanks for the link will try it. I will try it since within corp we are not allowed any external downloaded exe file (but the link has some easy steps to make it work) so decided to use the autoit script.

The problem it works but only once not on demand, I need to make it run always and respond to the hotkey each time.

Link to comment
Share on other sites

On 4/30/2020 at 5:58 PM, careca said:

Only change i did was the hotkey to F2 and it works fine.

It works once, i need to ensure it works on demand and responds to the hotkey each time.

Link to comment
Share on other sites

On 4/30/2020 at 5:50 PM, Nine said:

There might be a redirection issue as he is playing in the system32 folder.  And you do not have any error handling.   Make sure you can run this file from your script by capturing both pid and @error after run function.

 

I will give it a try, do have some examples of your suggestion. i am new to autoit.

I need it to work on demand and respond to the hotkey.

Link to comment
Share on other sites

No idea what you mean, because for me it works on demand, many times.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F2}", "ShowMessage")

While 1
    Sleep(100)
WEnd

Func ShowMessage()
Run("C:\Windows\System32\scrnsave.scr /s")
EndFunc

What could be happening is the keys getting sticked, shift alt and control are notorious for that.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

On 5/2/2020 at 3:14 PM, careca said:

No idea what you mean, because for me it works on demand, many times.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F2}", "ShowMessage")

While 1
    Sleep(100)
WEnd

Func ShowMessage()
Run("C:\Windows\System32\scrnsave.scr /s")
EndFunc

What could be happening is the keys getting sticked, shift alt and control are notorious for that.

Thank you, Yes it was the issue with keys getting sticked.

Link to comment
Share on other sites

On 5/2/2020 at 3:14 PM, careca said:

No idea what you mean, because for me it works on demand, many times.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F2}", "ShowMessage")

While 1
    Sleep(100)
WEnd

Func ShowMessage()
Run("C:\Windows\System32\scrnsave.scr /s")
EndFunc

What could be happening is the keys getting sticked, shift alt and control are notorious for that.

Ok, It works on my laptop, but if  the same script on Windows 10 pc it get "Script Paused". What could be causing it and how to over come.

Link to comment
Share on other sites

Or you can add this line to the top:

Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Maybe I miss your intention, but if you just want a hotkey to activate the windows screensaver to LOCK your windows logon session, then simply use the Windows build in hotkey, that's "WIN" + l ("LOWERCASE L", L like "lock")

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

5 hours ago, careca said:

Or you can add this line to the top:

Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause

 

Ok, I made the changes, This should work will let you guys know.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause

HotKeySet("{F2}", "ShowMessage")

While 1
    Sleep(100)
WEnd

Func ShowMessage()
Run("C:\Windows\System32\scrnsave.scr /s")
EndFunc

 

Link to comment
Share on other sites

40 minutes ago, rudi said:

Maybe I miss your intention, but if you just want a hotkey to activate the windows screensaver to LOCK your windows logon session, then simply use the Windows build in hotkey, that's "WIN" + l ("LOWERCASE L", L like "lock")

 

Regards, Rudi.

No, I cant use that since the test bench (machine) is connected to a display and runs continuously  with multi user interaction. Had to go for this solution to have black mute display on demand when not in use.

Edited by WindIt
Link to comment
Share on other sites

beside the already mentioned Opt("TrayAutoPause",0) use Opt("TrayIconHide",1), then there is no systray icon at all some fool could click around with.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...