Jump to content

HotKeySet and funktions


Aconx
 Share

Recommended Posts

Hi

I have a problem, I have one funktion that I whant to connect avout 6 HotKey to and depending och which one you press I whant it send a Charactar with

this is kind of what i whant to do, but it dose not work

HotKeySet ("c", "funktion("c")")

Func funktion($char)

...code

EndFunc

the obvius problem is that you can't write "HotKeySet ("c", "funktion("c")")" can i do this some how or do i have to make like 6 funktions to the different keys that rund the real one ?

Link to comment
Share on other sites

ok this probly isnt the best way but

While 1
HotKeySet("c","function")
WEnd
func function()
funktion('c')
endfunc
func funktion($char)
;your code here
endfunc

..cant call functions with parameters with HotKeySet()

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

ok this probly isnt the best way but

While 1
HotKeySet("c","function")
WEnd
func function()
funktion('c')
endfunc
func funktion($char)
;your code here
endfunc

..cant call functions with parameters with HotKeySet()

That's definitely how I'd go about doing it, but I want to add this.

A macro, @HotKeyPressed, returns the last hotkey pressed (kinda like the name suggests). So, you can use this in the following way (edited code from above):

While 1
HotKeySet("a","function")
HotKeySet("b","function")
HotKeySet("c","function")
HotKeySet("d","function")
WEnd
func function()
funktion(@HotKeyPressed)
endfunc
func funktion($char)
;your code here
endfunc
Link to comment
Share on other sites

That's definitely how I'd go about doing it, but I want to add this.

A macro, @HotKeyPressed, returns the last hotkey pressed (kinda like the name suggests). So, you can use this in the following way (edited code from above):

While 1
HotKeySet("a","function")
HotKeySet("b","function")
HotKeySet("c","function")
HotKeySet("d","function")
WEnd
func function()
funktion(@HotKeyPressed)
endfunc
func funktion($char)
;your code here
endfunc
closer, but still off... you can access the hotkey from the function being called by the hotkey, so there is no need for the second function. also one thing you both did was loop your hotkey set, so it's going to reset your same hotkeys over and over, and tie up alot of processor time because of the lack of a sleep() statement. Try this...

HotKeySet("a","funktion")
HotKeySet("b","funktion")
HotKeySet("c","funktion")
HotKeySet("d","funktion")
HotKeySet("{F9}","funktion")
while 1
    sleep(100)
WEnd
Func funktion()
    Select
        Case @HotKeyPressed = "{F9}"
        Exit
    Case Else
        MsgBox(0,"Pressed","you pressed: " & @LF & @HotKeyPressed)
    EndSelect
EndFunc
Edited by cameronsdad
Link to comment
Share on other sites

  • Moderators

That's definitely how I'd go about doing it, but I want to add this.

A macro, @HotKeyPressed, returns the last hotkey pressed (kinda like the name suggests). So, you can use this in the following way (edited code from above):

While 1
HotKeySet("a","function")
HotKeySet("b","function")
HotKeySet("c","function")
HotKeySet("d","function")
WEnd
func function()
funktion(@HotKeyPressed)
endfunc
func funktion($char)
;your code here
endfunc
I liked this idea, I'd not thought to centralize my hotkeys like this before:
HotKeySet("a","FuncOne")
HotKeySet("b","FuncOne")
HotKeySet("c","FuncOne")
HotKeySet("d","FuncOne")

While 1
    Sleep(0x7FFFFFFF)
WEnd

Func FuncOne()
    FuncDecipher(@HotKeyPressed)
Endfunc

Func FuncDecipher($char)
    If $char = 'a' Then MsgBox(0, 'A', '"a" was pressed, you could do something here')
    If $char = 'b' Then MsgBox(0, 'B', '"b" was pressed, you could do something here')
    If $char = 'c' Then MsgBox(0, 'C', '"c" was pressed, you could do something here')
    If $char = 'd' Then MsgBox(0, 'D', '"d" was pressed, you could do something here')
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.

Link to comment
Share on other sites

I liked this idea, I'd not thought to centralize my hotkeys like this before:

HotKeySet("a","FuncOne")
HotKeySet("b","FuncOne")
HotKeySet("c","FuncOne")
HotKeySet("d","FuncOne")

While 1
    Sleep(0x7FFFFFFF)
WEnd

Func FuncOne()
    FuncDecipher(@HotKeyPressed)
Endfunc

Func FuncDecipher($char)
    If $char = 'a' Then MsgBox(0, 'A', '"a" was pressed, you could do something here')
    If $char = 'b' Then MsgBox(0, 'B', '"b" was pressed, you could do something here')
    If $char = 'c' Then MsgBox(0, 'C', '"c" was pressed, you could do something here')
    If $char = 'd' Then MsgBox(0, 'D', '"d" was pressed, you could do something here')
Endfunc
slow on the response, AND re-enforcing wasteful habits. nice.
Link to comment
Share on other sites

  • Moderators

slow on the response, AND re-enforcing wasteful habits. nice.

Blah... yeah on the time delay on posting... I was seeing if it was even worth wild before I posted. And Blah at 'wasteful', hell if you think that one extra function that isn't needed is wasteful, then you would have puked ;) at my others.

Leave me alone and fix the code I sent you!! :lmao:

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.

Link to comment
Share on other sites

Blah... yeah on the time delay on posting... I was seeing if it was even worth wild before I posted. And Blah at 'wasteful', hell if you think that one extra function that isn't needed is wasteful, then you would have puked ;) at my others.

Leave me alone and fix the code I sent you!! :lmao:

fix? i thought it was good to go, told you i was having issues following it, so i don't have it anymore... what is the issue you're having? resend via PM, my work day is done, but i'll try to check the forums when i get home.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...