Jump to content
Sign in to follow this  
anixon

Keystroke Monitor

Recommended Posts

anixon

The following script has the "Pause" key assigned to the _IsPressed Key function. Can anyone show me how _IsPressed can be assigned to respond

to a two key combination say "Alt + H" . This is would help minimise an event where a single key like the "Pause" assignment could be accidentally

keyed or used for a process unrelated to the script.

Help is always appreciated Ant... :)

CODE
; Notes:

;_IsPressed Key = "Pause"

;Call Routine

;

Keymonitor()

Func KeyMonitor()

$dll = DllOpen("user32.dll")

While 1

Sleep ( 250 )

If _IsPressed("13", $dll) Then

processor()

DllClose($dll)

EndIf

WEnd

EndFunc

;Process the Panic Button

;

Func processor()

$PID = ProcessExists("yourprogram.exe")

If $PID Then ProcessClose($PID)

Run (@ScriptDir&"\yourprogram.exe")

Keymonitor()

EndFunc

;

;End of Script

Share this post


Link to post
Share on other sites
xcal

Can anyone show me how _IsPressed can be assigned to respond to a two key combination say "Alt + H" .

Two ways I can think of.

First...

#include <misc.au3>

HotKeySet('{Esc}', 'quit')

While 1
    If _IsPressed('12') And _IsPressed('48') Then MsgBox(0, '', 'combo pressed')
    Sleep(50)
WEnd

Func quit()
    Exit
EndFunc
oÝ÷ Ø    Ýü¨»§¶Ú¾"ÃëzËu©Ý¶¦Ç»wâæ¥Ú zØ^­«­¢+Ø)!½Ñ-åMÐ ÌäìÌÌí Ìäì°Ìäí±Ñ Ìäì¤)!½Ñ-åMÐ ÌäííÍôÌäì°ÌäíÅÕ¥ÐÌäì¤()1½°ÀÌØíÍÝ¥Ñ ()]¡¥±Ä(%%ÀÌØíÍÝ¥Ñ Q¡¸($%5Í    ½à À°ÌäìÌäì°Ìäí½µ¼ÁÉÍÍÌäì¤($$ÀÌØíÍÝ¥Ñ ô±Í(%¹%(%M±À ÔÀ¤)]¹()Õ¹±Ñ  ¤($ÀÌØíÍÝ¥Ñ ôQÉÕ)¹Õ¹()Õ¹ÅեР¤(%á¥Ð)¹Õ¹

Share this post


Link to post
Share on other sites
anixon

Two ways I can think of.

First...

#include <misc.au3>

HotKeySet('{Esc}', 'quit')

While 1
    If _IsPressed('12') And _IsPressed('48') Then MsgBox(0, '', 'combo pressed')
    Sleep(50)
WEnd

Func quit()
    Exit
EndFunc

Thanks very much for your help. After a bit of testing I have found that this works.

[codebox]
#include <misc.au3>

HotKeySet('{Esc}', 'quit')

Keymonitor()


Func KeyMonitor()
$dll = DllOpen("user32.dll")
While 1
    sleep(50)
    If _IsPressed('14' ,$dll) And _IsPressed('48', $dll) Then 
        msgbox(0, "", "Capslock & H",5 )
    EndIf
    If _IsPressed('14', $dll) And _IsPressed('31', $dll) Then 
        msgbox(0, "", "Capslock & 1",5 )
    EndIf   
WEnd
DllClose($dll)
EndFunc

Func quit()
    Exit
EndFunc
[/codebox]

Thanks again for your help very much appreciated Ant... :mellow: 
oÝ÷ Ø    Ýü¨»§¶Ú¾"ÃëzËu©Ý¶¦Ç»wâæ¥Ú zØ^­«­¢+Ø)!½Ñ-åMÐ ÌäìÌÌí Ìäì°Ìäí±Ñ Ìäì¤)!½Ñ-åMÐ ÌäííÍôÌäì°ÌäíÅÕ¥ÐÌäì¤()1½°ÀÌØíÍÝ¥Ñ ()]¡¥±Ä(%%ÀÌØíÍÝ¥Ñ Q¡¸($%5Í    ½à À°ÌäìÌäì°Ìäí½µ¼ÁÉÍÍÌäì¤($$ÀÌØíÍÝ¥Ñ ô±Í(%¹%(%M±À ÔÀ¤)]¹()Õ¹±Ñ  ¤($ÀÌØíÍÝ¥Ñ ôQÉÕ)¹Õ¹()Õ¹ÅեР¤(%á¥Ð)¹Õ¹

Share this post


Link to post
Share on other sites
anixon

My last post did not get published in the right place. So here it is again.

Thanks for the help I have found after some testing that this code works ok.

Cheers Ant.... :)

CODE

#include <misc.au3>

HotKeySet('{Esc}', 'quit')

Keymonitor()

Func KeyMonitor()

$dll = DllOpen("user32.dll")

While 1

sleep(50)

If _IsPressed('14' ,$dll) And _IsPressed('48', $dll) Then

msgbox(0, "", "Capslock & H",5 )

EndIf

If _IsPressed('14', $dll) And _IsPressed('31', $dll) Then

msgbox(0, "", "Capslock & 1",5 )

EndIf

WEnd

DllClose($dll)

EndFunc

Func quit()

Exit

EndFunc

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.