Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: when any key is pressed  (Read 15365 times)

0 Members and 1 Guest are viewing this topic.

Blisk

    Topic Starter


    Intermediate

    Thanked: 1
    • Experience: Familiar
    • OS: Windows 7
    when any key is pressed
    « on: October 15, 2019, 02:05:55 PM »
    I need a powershell script which will detect for about 3 minutes if any key on keyboard is pressed. When it is it make a txt file.
    O have this script but it doesn't work I tested it on windows 7 and windows 10
    Any idea about it?
    Code: [Select]
    1..100000 | ForEach-Object {
        "I am at $_"
        if ($Host.UI.RawUI.KeyAvailable)
        {
        New-Item E:\key.txt -ItemType "file" -Force
        break
        }

        Start-Sleep -Seconds 0.3
    }

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: when any key is pressed
    « Reply #1 on: October 15, 2019, 04:42:22 PM »
    On the PC and most other devices, a low level code handles the keyboard.
    You need to re think your idea. Programs to manage a  keyboard are very special.