Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function key_pressed($code) #funcion para capturar teclas presionadas
- {
- if($HOST.UI.RawUI.KeyAvailable)
- {
- $key = $HOST.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
- return $key.VirtualKeyCode -eq $code
- }
- return $false;
- }
- function hora()
- {
- return Get-Date -Format "HH:mm:ss"
- }
- #crear estructura de la tabla en base a la cantidad de campos que se ingresan indefinidamente
- function new_index()
- {
- Add-Type -TypeDefinition @"
- using System;
- using System.Runtime.InteropServices;
- public class Keyboard {
- [DllImport("user32.dll")]
- public static extern short GetAsyncKeyState(int vKey);
- }
- "@
- Write-Host "Nuevo Indice - Presione F1 para finalizar"
- while($true)
- {
- if( [Keyboard]::GetAsyncKeyState(0x70) -ne 0 )
- {
- break
- }
- $output = Read-Host ">"
- Write-Host $output
- }
- Write-Host "Ciclo finalizado"
- }
- function main()
- {
- $Host.UI.RawUI.CursorSize = 1
- while (-not (key_pressed(27))) #mientras no se oprima esc no se cierra el programa
- {
- Write-Host "Hola Emma - Presione Esc para salir"
- Write-Host(hora)
- Start-Sleep -Milliseconds 500
- }
- }
- #main
- new_index
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement