Administrators Jon Posted January 6, 2004 Administrators Share Posted January 6, 2004 Please give this unstable version a test:http://www.hiddensoft.com/autoit3/files/unstable/HotKeySet("key", "function")"key" is in the same format as the Send() function (i'll update filecreateshortcut for this if it works ok). eg. Ctrl+Alt+d:HotKeySet("^!d", "test") Sleep(10000) Func test() MsgBox(0, "Test", "test called") EndFuncUsing a blank function will unset a previous hotkey. Keys are executed in order one at a time and about 64 hotkey presses are buffered. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Developers Jos Posted January 6, 2004 Developers Share Posted January 6, 2004 Works great !!! Put this at the beginning of a large install script that I would like to be able to cancel:HotKeySet("^!x", "Fin")And this at the bottom:Func Fin() MsgBox(0, "Install Stopped", "Installation stopped") exitEndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 I'll have to add a "Pause" function as well so that we can pause/unpause the scripts via keys and that should be that. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 Doesn't appear so. Docs don't specify but you seem to need at least one modifier key (ctrl, alt, win, shift) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
jpm Posted January 6, 2004 Share Posted January 6, 2004 if HotKeySet("^d", "test") = 0 then exit ; Call function test() on ctrl+d Sleep(10000) Func test() global $i $i=$i+1 SplashTextOn("title", $i, 300, 100, 100+10*$i); EndFunc That look great You must check that ^ ! is in the hotkey because no error return an no hotkey either PS I have a AutoItV2toV3 working based on 3.0.84 do you want to test it Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 (edited) Doesn't appear so. Docs don't specify but you seem to need at least one modifier key (ctrl, alt, win, shift)Actually, scratch that - I still had a bit of code that forces ctrl+alt if nothing else is given, works for single keys now.Edit: re-uploaded. Edited January 6, 2004 by Jon Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 That look greatYou must check that ^ ! is in the hotkey because no error return an no hotkey eitherPS I have a AutoItV2toV3 working based on 3.0.84 do you want to test it Thanks, JP Sure, we'll test - send it me and I'll pop it in the /unstable directory Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
scriptkitty Posted January 6, 2004 Share Posted January 6, 2004 (edited) I like it so far, um yea, no single key. Actually better that way I think. Docs should point it out. Testing continues on the TNT version. Oh yea, the new help file still has the ] backwards: FileOpenDialog ( "title", "init dir", "filter", [options[ ) Edited January 6, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Lemures Posted January 6, 2004 Share Posted January 6, 2004 and autoit just keeps on getting better i love it, thanks Jon!! Link to comment Share on other sites More sharing options...
CyberSlug Posted January 6, 2004 Share Posted January 6, 2004 (edited) EDIT: Nevermind! It was because I has set the BIOS to emulate the Fn key on the external keyboard when pressing rightCtrl+rightAlt.I'll leave the post in case anyone else has this problem.============ External keyboard weirdness:I'm using a laptop* with an external PS/2 keyboard. Hotkey presses such as Ctrl+Alt+D do not work if typed on the external keyboard. However, they work on the laptop keyboard.I've noticed a similar problem with BlockInput(1): Ctrl+Alt+Delete only registers if pressed on the laptop's keyboard.It's not a big deal, but I was just wondering *Toshiba Tecra 8000 laptop with Windows XP Pro sp1 Edited January 6, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Somerset Posted January 6, 2004 Share Posted January 6, 2004 ok just for laughs. i had a dell latitiude xpi 166mhz. yeah slug i know what you are saying. it ain't just you. if you play with the laptop keyboard, you maybe suprised what you will find. cause that lap top had a whole bunch of predefined kes from poping out the cd rom to volume mute. but one question before i amke an ass of myself. do it have a fn key on these new laptops? if no them maybe a certain combos will be activated by certain pressings. Link to comment Share on other sites More sharing options...
scriptkitty Posted January 6, 2004 Share Posted January 6, 2004 (edited) A few single key combos seem to work. On winXP, #d still activates show desktop and doesn't pass it to AutoIt, but no other real problems so far. This is vey fun to play around with. I chained a few together. rest $x=1 HotKeySet("r", "test") ; Call function test() while winexists("unstable","") sleep(1000) $x=$x+1 wend Func test() HotKeySet("e", "test1") EndFunc Func test1() HotKeySet("e") HotKeySet("s", "test2") EndFunc Func test2() HotKeySet("s") HotKeySet("t", "test3") EndFunc Func test3() MsgBox(0, "Test", "Test called "&$x) EndFunc Feature or bug: HotKeySet("^r", "test"); sets it HotKeySet("^r"); removes it HotKeySet("^r", ""); crashes Edited January 6, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
cmallett Posted January 6, 2004 Share Posted January 6, 2004 (edited) Doesn't appear so. Docs don't specify but you seem to need at least one modifier key (ctrl, alt, win, shift)Not true, at least under WinXP (and by extension, probably WinNT and Win2k as well). Virtually any hotkey can be activated with RegisterHotkey(), even an unmodified letter key. For example, this works in AutoHotkey:d::MsgBox, yes; This reveals that the hotkey is registered rather than handled by the hook:ListHotkeysreturnYou must check that ^ ! is in the hotkey because no error return an no hotkey eitherCan anyone confirm that this affects Win9x? Because obviously it doesn't apply to WinXP.On winXP, #d still activates show desktop and doesn't pass it to AutoIt, but no other real problems so far.You need a keyboard hook to override Windows-reserved hotkeys on an individual basis (i.e. they're already registered by the Explorer, so another app can't easily "steal" them).A few things that might be problematic with this feature, which I mentioned before:1) Infinite loops. Here is an oversimplified example (real world examples are usually more insidious and happen when you don't even realize you've done it):^!d::Send, ^!d ; Infinite loop, possible computer lock-up or other bad things.Although the above example might not produce a lock-up, a more complex Send that sends more keys could very well do that, or cause your apps to misbehave due to the steady stream of keys being sent to the ever-changing active-window as the user tries to extricate himself from a computer that's seemingly become unresponsive.2) Any hotkey that uses the Send command to Send its own modifiers might produce unexpected results. Another over-simplified example:^!d::Send, {CtrlDown}The above will not work as expected (without additional code to handle it) because when the user physically releases the hotkey, the control key will be back in the up position.3) Minor: Without additional code to handle it, hotkeys that send their own modifiers (e.g. CTRL or ALT) will not be repeatable unless the user releases and presses the modifiers again. This is because the modifiers will be in the up position after the Send() even though the user may still be physically holding them down.There may be a few other issues.Edit: Another issue (Jon, you may have already added code to handle this): Without additional code, the hotkey's own modifiers will affect the keys sent by the send command. Example:^!d::Send, abc ; This might really send ^!a^!b^!c Edited January 6, 2004 by cmallett Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 Feature or bug: HotKeySet("^r", "test"); sets it HotKeySet("^r"); removes it HotKeySet("^r", ""); crashesOops. Bug. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 I'm thinking of leaving it as it is tbh, even if there are a few snags, my goal isn't a hotkey app and the amount of rewrites I imagine are required to fix these snags wouldn't be insignificant. If there are easy fixes though feel free to comment - I'm useless at working stuff out from others' code. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
scriptkitty Posted January 6, 2004 Share Posted January 6, 2004 (edited) infinite loops can be a problem, ex: HotKeySet("!r", "test") sleep(10000) Func test() sleep(1000) send("Repeat!r") EndFunc Single keys will be the real issue, but I think it is a really nice feature as it stands now. I will try to check compatibility and bugs on a few other OSs. Right now I feel like a kid in a candy store also worth noting, at least in the documentation, is not to use caps. HotKeySet("+r", "test") <> HotKeySet("R", "test") Also worth noting, the example above should only work for 10 seconds, but if you start the loop going, it will continue forever. This is a little strange as well. HotKeySet("R", "test") sleep(10000) Func test() sleep(1000) send("Repeat") EndFunc Edit...Oh, if I didn't express more clearly, I really like this, even exactly how it is. I think all that is really needed is a warning label Edited January 6, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
cmallett Posted January 6, 2004 Share Posted January 6, 2004 Relatively minor issue: user physically releasing the hotkey modifiers in the middle of a Send operation might mess up the send. Example: ^!d::Send, ^{Left 15} If the user physically releases the hotkey modifiers during the send, some of the left-arrows probably won't be properly modified by the Control key. But this is probably an easy fix because AutoIt just needs to check the state of the modifiers before every keystroke rather than before every new symbol (which it may already do, I'm not sure). (and in case you didn't see my edit above) Another issue (Jon, you may have already added code to handle this): Without additional code, the hotkey's own modifiers will affect the keys sent by Send(). Example: ^!d::Send, abc ; This might really send ^!a^!b^!c because the user is physically holding down the keys Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 Oops. Bug. On seconds thoughts, I thought you meant windows crash, not AutoIt error message, so feature. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 6, 2004 Author Administrators Share Posted January 6, 2004 Relatively minor issue: user physically releasing the hotkey modifiers in the middle of a Send operation might mess up the send. Example:^!d::Send, ^{Left 15}If the user physically releases the hotkey modifiers during the send, some of the left-arrows probably won't be properly modified by the Control key. But this is probably an easy fix because AutoIt just needs to check the state of the modifiers before every keystroke rather than before every new symbol (which it may already do, I'm not sure).(and in case you didn't see my edit above)Another issue (Jon, you may have already added code to handle this): Without additional code, the hotkey's own modifiers will affect the keys sent by Send(). Example:^!d::Send, abc ; This might really send ^!a^!b^!c because the user is physically holding down the keysHmmm, IIRC it assumes no modifiers are already pressed and the only checking is for the {ALTDOWN} type situations. A few GetKeyState() littered around may work. Thanks. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
cmallett Posted January 8, 2004 Share Posted January 8, 2004 I'm surprised no one said a word about this, so I'll post it again because I think it's relevant:Doesn't appear so. Docs don't specify but you seem to need at least one modifier key (ctrl, alt, win, shift)You must check that ^ ! is in the hotkey because no error return an no hotkey eitherNot true, at least under WinXP (and by extension, probably WinNT and Win2k as well). Virtually any hotkey can be activated with RegisterHotkey(), even an unmodified letter key.I know Win9x is slightly more limited in which hotkeys can be registered. But even in that OS, I'm under the impression that just about any key can be registered. 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