stingjoel Posted November 4, 2004 Share Posted November 4, 2004 When I use HotKeySet, AutoIt show error because AutoIt can't find function...this is the code: $msg = "trying..." HotKeySet("#!c", "MyFunc($msg)") Func MyFunc($msg) MsgBox(4096, "", $msg) EndFunc Can the function at HotkeySet using parameter?? Link to comment Share on other sites More sharing options...
this-is-me Posted November 4, 2004 Share Posted November 4, 2004 Not right now. Who else would I be? Link to comment Share on other sites More sharing options...
scriptkitty Posted November 4, 2004 Share Posted November 4, 2004 I usually just set my Parms as default. You could always call it from a funtion. $msg = "trying..." HotKeySet("#!c", "MyFunc") Func MyFunc() MsgBox(4096, "", $msg) EndFunc $msg = "trying..." HotKeySet("#!c", "Parm") func Parm() MyFunc($msg) endfunc Func MyFunc($msg) MsgBox(4096, "", $msg) EndFunc AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
stingjoel Posted November 4, 2004 Author Share Posted November 4, 2004 I usually just set my Parms as default. You could always call it from a funtion.$msg = "trying..." HotKeySet("#!c", "MyFunc") Func MyFunc() MsgBox(4096, "", $msg) EndFunc$msg = "trying..." HotKeySet("#!c", "Parm") func Parm() MyFunc($msg) endfunc Func MyFunc($msg) MsgBox(4096, "", $msg) EndFunc<{POST_SNAPBACK}>Sorry, I dont' want to do that....I want to do this:1. I detect how many CD-ROM in the computer.2. Then I'll create a hotkey (like WIN+ALT+1, etc)...so If the computer have 2 CD-ROMs (Like I have ), I'll create two hotkey (WIN+ALT+1 and WIN+ALT+2) to eject the CD-ROM.3. So, If the computer have 8 CD-ROMs, I don't want to create too many function for the hotkeys....In my opinion, the easiest way is using function's parameter....but AutoIt can't do that... Link to comment Share on other sites More sharing options...
scriptkitty Posted November 4, 2004 Share Posted November 4, 2004 ok, just for kicks, show me how you would make the hotkey asuming you could use a parm? In practice there is little difference AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scriptkitty Posted November 4, 2004 Share Posted November 4, 2004 (edited) Say you wanted to see how many CDRoms, and have the function use some other source of info? My point is, I could put the function in the hotkey, or it could be dynamic as well. I will grant you there is 3 more lines of code however. HotKeySet("#!c", "Parm") $x=StringSplit("Almost,Hello there, Hiya fred, bob likes juice, sam has 3 CD roms",",") $var = DriveGetDrive( "CDROM" ) While 1 for $i=1 to $x[0] $msg = $x[$i] next wend func Parm() MyFunc($msg) endfunc Func MyFunc($msg) MsgBox(4096, $var[0]& "CDROMS", $msg) EndFunc func Parm() MyFunc($msg) endfunc HotKeySet("#!c", "Parm") is the same as HotKeySet("#!c", "MyFunc($msg)") Edited November 4, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
therks Posted November 4, 2004 Share Posted November 4, 2004 Actually, I think he wants to do something like this. $Drives = DriveGetDrive('CDROM'); For $i = 1 to $Drives[0] HotKeySet('#!' & $i, EjectDrive($Drives[$i])); Next Func EjectDrive($DriveLet) CDTray($DriveLet); EndFunc My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
stingjoel Posted November 4, 2004 Author Share Posted November 4, 2004 No...not like that...sorry I can't explained it in detail, because my english is not good.. this is the sample code and I hope you understand ; ---------------------------------------------------------------------------- ; Set Hotkey for All CD-ROM (WIN+ALT+1 for First CD-ROM...) ; ---------------------------------------------------------------------------- $var = DriveGetDrive( "CDROM" ) If NOT @error Then For $i = 1 to $var[0] $setting = "#!" & $i $DriveLetter = $var[$i] HotKeySet($setting, "OpenCDROM($DriveLetter)") Next EndIf ; ---------------------------------------------------------------------------- Func OpenCDROM($Drive) MsgBox(64, "Try", $Drive) EndFunc so, If I have 10 CD-Roms or 100 CD-Roms, I don't care...the code above can handle it (if AutoIt support function parameter in HotKeySet)... Now, is it clear? bophiyen 1 Link to comment Share on other sites More sharing options...
stingjoel Posted November 4, 2004 Author Share Posted November 4, 2004 YESSSSS...you are right Sorry, I am replying when you reply Actually, I think he wants to do something like this.$Drives = DriveGetDrive('CDROM'); For $i = 1 to $Drives[0] HotKeySet('#!' & $i, EjectDrive($Drives[$i])); Next Func EjectDrive($DriveLet) CDTray($DriveLet); EndFunc<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
scriptkitty Posted November 4, 2004 Share Posted November 4, 2004 Ok, now I remember trying to do something just like this in the past. It will take a bit more thought now. My first thought is to use Larry's trick. Set a hotkeylogger for a sequence of keys. Much like his "Larry" thing. You could have it read the first two keys, and use the third key to be the letter of the drive to open. Dynamically making hotkeys is something I forgot about. Thanks, it is really refreshing. I wish I could dynamically create functions. for $i= 1 to 10; not going to work. Func $i() send($i) endfunc next Well maybe in the morning I might have some insight, but you are right, I couldn't see the forest for the trees that time... AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
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