Sign in to follow this  
Followers 0
oMBRa

hotkey

8 posts in this topic

How to use a word like an hotkey?

if I use HotKeySet("hello", "MyFunction") the function will be called when I press H or E etc... so how to do it?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

here is an exmaple ;)

HotKeySet("x", "OMG")

While 1
Wend

Func OMG()
MsgBox(0, "Working", "HotkeyFunction is Working ")
endfunc

so when you press "X" it will open the function ^^

Edited by Cha0sBG

Have Questions About GUI (Graphical User Interface) ? Post Them Here :GUI Help And Support ForumHave Questions About General AutoIt ? Post Them Here : General Help And Support ForumNew To AutoIt ? Be Shure To Check Out The FaQ's (Frequently Asked Questions) Or FaQ ¹ There You May Find Great Help That Will Guide You True The Wonderful Programming Language AutoItOthere Good Place To Get Some Knolage Of AutoIt Is The Example Script ForumNotice A Bug ? Please Go And Report it At Bug Report Section And Help The Devolepers Of AutoIt Update And Fix The Programming LanguageWant To Thank The People For This Great Forum And Programming Language ? Then DonateWhen You Found The Answer Your Looking For Please Add [Resolved] To The Thread's Name That Will Show Otheres That You Have Found What Your Looking For And They Whount Have To Enter The Thread.

Share this post


Link to post
Share on other sites

the hotkey must be a word not a char... word like "hello"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

How would that even work? Every time you type "Hello" your function would activate? What if you were trying to type up a document?

Anyway, there's no easy way to do something like that, you'll have to devise your own method of doing it with functions like _IsPressed().

*Edit: Or check this out, someone already did this: http://www.autoitscript.com/forum/index.ph...mp;hl=hotstring

Edited by RobSaunders

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Guess you could always get creative if you didn't want to hook the keyboard:

Global $s_hello_last_key
HotKeySet("h", "_Hello")

While 1
    Sleep(10000)
WEnd

Func _Hello()
    Local $f_move_next = False
    Local $s_key = @HotKeyPressed
    If $s_key = "l" And $s_key = $s_hello_last_key Then $f_move_next = True ;double l
    Switch $s_key
        Case "h"
            HotKeySet("e", "_Hello")
        Case "e"
            If $s_hello_last_key <> "h" Then
                HotKeySet("h", "_Hello")
            Else
                HotKeySet("l", "_Hello")
            EndIf
        Case "l"
            If $f_move_next Then
                HotKeySet("o", "_Hello")
            ElseIf $s_hello_last_key <> "e" Then
                HotKeySet("h", "_Hello")
            EndIf
        Case "o"
            If $s_hello_last_key = "l" Then MsgBox(64, "Info", "You typed hello")
            HotKeySet("h", "_Hello")
    EndSwitch
    $s_hello_last_key = $s_key
EndFunc

Edited by SmOke_N

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.

Share this post


Link to post
Share on other sites

SmOke_N with yuor scripts I will cant use the words h e l l o and with manadar udf i get always " C:\Documents and Settings\Fabry\Desktop\autoit scripts\Example.au3 (3) : ==> Error opening the file.: #include <HotString.au3>"

but the file are in the same directory

Share this post


Link to post
Share on other sites

SmOke_N with yuor scripts I will cant use the words h e l l o and with manadar udf i get always " C:\Documents and Settings\Fabry\Desktop\autoit scripts\Example.au3 (3) : ==> Error opening the file.: #include <HotString.au3>"

but the file are in the same directory

I uploaded HotString.au3


When the words fail... music speaks

Share this post


Link to post
Share on other sites

SmOke_N with yuor scripts I will cant use the words h e l l o.

Well... no kidding, I didn't write exceptions for spaces, that's up to you. I only gave a working example of how it could be done without hooking anything.

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.

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