Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

esperti di [SCRIPT] vi volete sollazzare cinque minuti?

6 views
Skip to first unread message

brianks®

unread,
Feb 15, 2024, 4:47:27 AMFeb 15
to
allora vado su chatgpt e chiedo un semplice script che spenga lo schermo.

prima risposta in python, gli dico ma che sei scemo? voglio una cosa che
funzioni con un doppio clic

> import subprocess
>
> def spegni_schermo():
> # Console command per spegnere lo schermo su Windows
> command = 'nirrundll32.exe powrprof.dll,SetSuspendState 0,1,0'
> # Console command per spegnere lo schermo su Mac
> # command = 'pmset displaysleepnow'
> # Console command per spegnere lo schermo su Linux
> # command = 'xset dpms force off'
>
> # Esegui il comando per spegnere lo schermo
> subprocess.call(command, shell=True)
>
> spegni_schermo()

seconda risposta

> @echo off
>
> echo Creating VBScript file to turn off display
> echo Set oShell = CreateObject("Wscript.Shell") > %temp%\turnoff.vbs
> echo oShell.SendKeys "^{ESC}" >> %temp%\turnoff.vbs
> echo oShell.SendKeys "{RIGHT}" >> %temp%\turnoff.vbs
> echo oShell.SendKeys "{ENTER}" >> %temp%\turnoff.vbs
>
> echo Running VBScript file to turn off display
> cscript //nologo %temp%\turnoff.vbs
>
> echo Deleting VBScript file
> del %temp%\turnoff.vbs
>
> echo Screen turned off successfully


non funziona :(

terzo tentativo

> @echo off
>
> echo Turning off display...
> powershell.exe (Add-Type '[DllImport("user32.dll")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(0xffff, 0x0112, 0xf170, 2)
>
> echo Display turned off successfully

quarto

> @echo off
>
> echo Creating VBScript file to turn off display
> echo Set oShell = CreateObject("Wscript.Shell") > %temp%\turnoff.vbs
> echo oShell.SendKeys "^{ESC}" >> %temp%\turnoff.vbs
> echo oShell.SendKeys "{RIGHT}" >> %temp%\turnoff.vbs
> echo oShell.SendKeys "{ENTER}" >> %temp%\turnoff.vbs
>
> echo Running VBScript file to turn off display
> cscript //nologo %temp%\turnoff.vbs
>
> echo Deleting VBScript file
> del %temp%\turnoff.vbs
>
> echo Screen turned off successfully

quinto

> @echo off
>
> echo Turning off display...
> powershell.exe (Add-Type '[DllImport("user32.dll")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(0xffff, 0x0112, 0xf170, 2)
>
> echo Display turned off successfully

sesto

> @echo off
> powershell.exe -ExecutionPolicy Unrestricted -Command "(Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1, 0x0112, 0xF170, 2)"

qua non funziona niente, vado su COPILOTA, visto che c'è usiamolo, mi
dice: crea un collegamento con

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command
"(Add-Type '[DllImport(\"user32.dll\")]public static extern int
SendMessage(int hWnd,int hMsg,int wParam,int lParam);' -Name a
-Pas)::SendMessage(-1,0x0112,0xF170,2)"

ed ecco l'unico che ha funzionato.
E bravo Windows (copilota)

Ammammata

unread,
Feb 15, 2024, 8:10:44 AMFeb 15
to
on 15/02/2024, brianks® supposed :
> vado su COPILOTA, visto che c'è usiamolo, mi dice: crea un collegamento con
>
> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "(Add-Type
> '[DllImport(\"user32.dll\")]public static extern int SendMessage(int hWnd,int
> hMsg,int wParam,int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)"
>
> ed ecco l'unico che ha funzionato.

non ti è sufficiente usare [tasto windows] + l (elle) per bloccare lo
schermo? poi ti si spegne da solo in base alle impostazioni di
risparmio energetico

--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........

brianks®

unread,
Feb 17, 2024, 3:48:31 AMFeb 17
to
Ammammata, il 15/02/2024 alle 14:10 ha scritto:

> non ti è sufficiente usare [tasto windows] + l (elle) per bloccare lo
> schermo?

niente blocco schermo

Valerio Vanni

unread,
Feb 17, 2024, 4:53:59 AMFeb 17
to
[Win] + [L] ha sempre funzionato (anche su sistemi precedenti, non è
una novità di 10). Forse c'è qualcosa di strano lì da te.

Però da quello che ho capito non vuoi bloccare lo schermo, lo vuoi
spegnere.

--
Ci sono 10 tipi di persone al mondo: quelle che capiscono il sistema binario
e quelle che non lo capiscono.

brianks®

unread,
Feb 17, 2024, 8:03:41 AMFeb 17
to
Valerio Vanni, il 17/02/2024 alle 10:53 ha scritto:

> [Win] + [L] ha sempre funzionato (anche su sistemi precedenti, non è
> una novità di 10). Forse c'è qualcosa di strano lì da te.

niente di strano infatti

>
> Però da quello che ho capito non vuoi bloccare lo schermo, lo vuoi
> spegnere.
>

esatto, e lo spengo
era semplicemente per testare l'AI

RobertoA

unread,
Feb 17, 2024, 10:11:45 AMFeb 17
to
Ho provato ad usare ChatGpt dando questa richiesta:

-----------------------------------------------
Sistema operativo Windows 10 professional, desidero creare uno script
che sia avviabile con un doppio-click e che consenta di spegnare il
monitor, come fare?
-----------------------------------------------

Mi restituisce:

Puoi creare uno script PowerShell per spegnere il monitor su Windows 10
Professional. Ecco un breve esempio di come fare:

Apri il Blocco Note.
Incolla il seguente codice PowerShell:

powershell

......................................
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
public class Monitor {
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);
}
'
[Monitor]::SendMessage((Get-Process -Id $pid).MainWindowHandle, 0x0112,
0xF170, 2)
......................................

Salva il file con l'estensione .ps1, ad esempio SpegniMonitor.ps1.
Per eseguirlo con un doppio click, puoi creare un collegamento o uno
script batch che esegua il tuo script PowerShell.
-----------------------------------------------

Mi pare molto simile alla risposta che ti ha dato Copilot
Da quanto ho capito finora, moltissimo dipende da come poni la domanda
0 new messages