Sign in to follow this  
Followers 0
ASawyer

Determine if specific word is typed in

3 posts in this topic

I would like to know if for example someone types in asdf at any time while in windows, and then do something.

Basically what I'm trying to do is instead of using a hotkey, if the user types a secret code like 3edhe, or something that I have decided, then I want to run a certain function.

I tried searching but I'm sure I'm sure not using the right keywords.

Thanks,

Alan

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I would like to know if for example someone types in asdf at any time while in windows, and then do something.

Basically what I'm trying to do is instead of using a hotkey, if the user types a secret code like 3edhe, or something that I have decided, then I want to run a certain function.

I tried searching but I'm sure I'm sure not using the right keywords.

Thanks,

Alan

There are a few ways it can be done. Here is a fairly simple way using Hot Keys. It isn't foolproof but you can can add hotkeys if required to break a false trigger.

HotKeySet("{ESC}","gone");allow us to quit

Global $code = "subprime";the code to detect
Global $arrayc = StringSplit($code, "")
Global $progress = 0;how many keys in sequence detected
For $n = 1 To $arrayc[0]
    HotKeySet($arrayc[$n], "hcoder")
Next

;add some keys that are not in the code but chosen so it is unlikely 
;that the keys will occur in sequence without one of these being pressed
HotKeySet("{SPACE}","hcoder")
HotKeySet("{ENTER}","hcoder")
;add more if needed.

While 1;hang around while waiting for keys
    Sleep(20)
    
WEnd

Func hcoder()
    HotKeySet(@HotKeyPressed)
    Send(@HotKeyPressed)
    If @HotKeyPressed = $arrayc[$progress + 1] Then
        $progress += 1
        ConsoleWrite("count = " & $progress & @LF)
    Else
        $progress = 0
    EndIf
    If $progress >= StringLen($code) Then
        MsgBox(0, 'hey', "that's my code")
    EndIf

    HotKeySet(@HotKeyPressed, "hcoder")
EndFunc ;==>hcoder

Func gone()
    
    Exit
EndFunc ;==>gone
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I would like to know if for example someone types in asdf at any time while in windows, and then do something.

Basically what I'm trying to do is instead of using a hotkey, if the user types a secret code like 3edhe, or something that I have decided, then I want to run a certain function.

I tried searching but I'm sure I'm sure not using the right keywords.

Thanks,

Alan

Two other approaches:

chris95219's @ http://www.autoitscript.com/forum/index.ph...st&p=361763

and

Manadar's @ http://www.autoitscript.com/forum/index.ph...st&p=247970

Edit: Manadar's require's Larry's hook.dll from here: http://www.autoitscript.com/forum/index.ph...st&p=458286

Edited by ResNullius

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  
Followers 0