-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlternador Salvapantallas.au3
58 lines (52 loc) · 1.45 KB
/
Alternador Salvapantallas.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#Region Configuración
#pragma compile(Icon, Icons\au3.ico)
#pragma compile(Out, Alternador Salvapantallas.exe)
#NoTrayIcon
Opt('GUIOnEventMode', 1)
#EndRegion
#Region Variables globales
Global $boton
Global $encendido = True
Global Const $VERDE = 0x008000
Global Const $ROJO = 0xFF0000
Global Const $BLANCO = 0xFFFFFF
#EndRegion
#Region Manejadores de eventos
Func _botonClicked()
$encendido = Not $encendido
AlternarSalvapantallas($encendido)
GUICtrlSetBkColor($boton, $encendido ? $VERDE : $ROJO)
GUICtrlSetData ($boton, $encendido ? 'Encendido' : 'Apagado')
EndFunc
Func _GUI_EVENT_CLOSE()
If ($encendido = False) Then _
AlternarSalvaPantallas(True)
GUIDelete()
Exit
EndFunc
#EndRegion
#Region Funciones
Func AlternarSalvapantallas($encendido)
#cs Habilita o deshabilita el salvapantallas, según el valor booleano pasado
como parámetro.
#ce
DllCall('user32.dll', 'long', 'SystemParametersInfo', _
'long', 17, _
'long', ($encendido ? 1 : 0), _
'long', 0, _
'long', 0)
EndFunc
#EndRegion
#Region Interfaz gráfica
GUICreate('Alternador de Salvapantallas', 120, 40)
GUISetFont(10, Default, Default, 'Liberation Mono')
$boton = GUICtrlCreateButton('Encendido', 10, 10, 100, 20)
GUICtrlSetColor($boton, $BLANCO)
GUICtrlSetBkColor($boton, $VERDE)
GUICtrlSetOnEvent($boton, _botonClicked )
GUISetOnEvent(-3, _GUI_EVENT_CLOSE)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
#EndRegion