Sign in to follow this  
Followers 0
Chobyhy

Custom Command Help

7 posts in this topic

I'm trying to make a function so that if you type /exit in a game while the program is running, it would exit the script. Is there anyway that I can make this to work?

Share this post


Link to post
Share on other sites



I'm trying to make a function so that if you type /exit in a game while the program is running, it would exit the script. Is there anyway that I can make this to work?

Yes... You'll want to look at HotKeySet() and or _IsPressed()... the rest is logical manipulation.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I thought HotKeySet is when they press a single button.

_IsPressed() is when they press a single key.

I'm trying to make it so that if they type /exit and enter it into chat, it will exit the script. I still have no idea on what to do. Can you help me out with the logical manipulation. I'm not asking you to write the script for me, I'm just asking how I'm going to make it work

Share this post


Link to post
Share on other sites

I thought HotKeySet is when they press a single button.

_IsPressed() is when they press a single key.

I'm trying to make it so that if they type /exit and enter it into chat, it will exit the script. I still have no idea on what to do. Can you help me out with the logical manipulation. I'm not asking you to write the script for me, I'm just asking how I'm going to make it work

Too close to a key logger for me to help... one of the forum morons will though... just be patient.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

... Is there anyways i can prove its not a key logger?

Share this post


Link to post
Share on other sites

... Is there anyways i can prove its not a key logger?

Well the short of it Chobyhy, is it is a keylogger. You want to capture when someone types the keys /exit, which can only be done by logging what they end user is typing... So regardless of how noble your intentions are, a spade by any other name is still a spade.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This is an example of what you COULD try. This script cannot (as far as I can see) be used as a keylogger, unless you are using a very loose definition of that word. It will react when a sequence of keys is pressed in the right order within a specific time frame, although it would also have the same reaction even if rogue keys are pressed. for example,

exit

eexixt

efpxiht

would all work if typed fast enough, simply because it picks out the letters in bold.

Adaptations of this script can lead you to something that will work as desired.

#include "misc.au3"
;This is not a keylogger!
;This does not "log" what keys are pressed in any way
;Except that it will recognize and/or log when a specific sequence of keys are pressed
Local $Word="exit"
if $CmdLine[0] Then $Word=$CmdLine[1]
Local $KeySequence=StringSplit($Word,"")
Local $SeqPlace=1, $SeqTimer

While 1
    if _IsPressed(Hex(Asc(StringUpper($KeySequence[$SeqPlace])),2)) Then
        ConsoleWrite($KeySequence[$SeqPlace])
        $SeqPlace+=1
        if $SeqPlace>$KeySequence[0] Then Exit
        $SeqTimer=TimerInit()
    ElseIf $SeqPlace>1 Then
        if TimerDiff($SeqTimer)>750 Then $SeqPlace=1
    EndIf
    
    Sleep(50)
WEnd

NOTE: This does not discriminate between lower/upper case letters. Also, certain keys probably cannot be discerned this way (Hex(Asc(StringUpper()))). The "/" is an example, as I do not believe that its ascii value is the same as the value accepted for it by _IsPressed. If you want to discern characters like these, you will need to work around this.

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