darkshadow791 Posted November 15, 2006 Posted November 15, 2006 (edited) I was bored today so I've been trying to make a function that could write another function based on input. Here is what I want to do: Func pressed() $i += 1 Do $g=$i Sleep($PushTime) Until $g==$i Switch $i Case 1 put(1) Case 2 put(2) Case 3 put(3) Case 4 Exit (0) EndSwitch $i = 0 EndFunc Func _CreateMultiKey($key, $cases, $sleep, $return);key to bind, number of options, sleep time between each, return value For $x = 0 To $cases Step 1 Next Return $returnit EndFunc I want to take the multi-hotkey code (not from me... someone here wrote it) and be able to make a func of it (_CreateMultiKey) Basically I want to be able to do something like: $key = _CreateMultiKey("a", 3, 100, key1) Which will (hopefully) make a function (while running a script) that binds "a" (hotkeyset) to a function called "key1" with 3 options and 100ms sleep time between each. Then, I want to be able to modify what each option does based on an array stored in "$key" (i.e. if I have 3 options I want it to be like $key[1] $key[2] and $key[3] will control what each does.) I was thinking of using a for loop and having it read the case number and key and whatever... Anyway the reason behind this is to put it in an include file and just call it like... #include <MultiKeys.au3> $var = _CreateMultiKey("z",3,100,key1) $var[1] = Sleep(100) $var[2] = Send("a") $var[3] = Send("b") Then when I run the script if I press z once it executes whatever $var[1] is, 2 times for $var[2], etc. I don't know if this is possible but I would appreciate it if anyone can help me with it. Thanks. (Another reason is that I want to be able to make multiple options of multikey binds when the script is run, based on a GUI or user input or something similar. I.E. Someone uses a GUI to create customizable binds for multiple keys, etc.) Edit: Or possibly have it read a global var for number of functions and have that as the number of options, then when you call it you list what functions you want each to do...? Edited November 15, 2006 by darkshadow791 Note Taker Lite - a note taking / converting tool.
lod3n Posted November 15, 2006 Posted November 15, 2006 (edited) AutoIt doesn't support anonymous functions, which is what you're describing. What you could do though, is generate a new .au3 file with FileWriteLine, and then execute it. Good luck. Edited November 15, 2006 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
darkshadow791 Posted November 16, 2006 Author Posted November 16, 2006 Well no I was thinking of ... hrm well nvm I just thought of something, oh well. Note Taker Lite - a note taking / converting tool.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now