David Poiron Posted September 17, 2021 Share Posted September 17, 2021 (edited) I am trying to direct a script to bring up a different dialog box depending on if the shift or option keys are pressed when the command is invoked. I've tried to use KeyDown but am not clear how it works. There is a Shift and Option function as well but the results are not as expected. I am trying to do this with an IF/THEN statement. Any suggestions are appreciated. Using 2022 for this. Edited September 17, 2021 by David Poiron Quote Link to comment
Pat Stanford Posted September 17, 2021 Share Posted September 17, 2021 This thread has a command script that uses a modifier key to change the behavior and bring up preference dialog boxes. Hopefully it will help with what you need. If not, please ask again. Quote Link to comment
David Poiron Posted September 17, 2021 Author Share Posted September 17, 2021 (edited) This is the code snippet IF Shift THEN CreateDialog1 {full access} ELSE CreateDialog2; {partial access} It does not seem to work - it just goes to CreateDialog2. I've tried Command and Option instead of Shift as well - not working. Is this required to be in a while..do statement to work? Edited September 17, 2021 by David Poiron Quote Link to comment
Pat Stanford Posted September 17, 2021 Share Posted September 17, 2021 Mine is very similar effectively becoming If COMMAND then Dialog Box; With no else. The Vectorscript manual says this about SHIFT (and also Command and Option) Shift returns TRUE if the Shift key was depressed during the last user event. This function operates with the MouseDown, KeyDown, AutoKey, GetPt, GetPtL, GetLine, and GetRect calls. So you might need to include an Autokey or KeyDown ahead of your SHIFT to make sure it is set properly. Quote Link to comment
David Poiron Posted September 17, 2021 Author Share Posted September 17, 2021 I tried this and it seems to work, but I am not clear what the KeyDown is really doing! KeyBool:= KeyDown(modKey); IF Shift=true THEN CreateDialog1 {full access} ELSE CreateDialog2; {partial access} Quote Link to comment
Pat Stanford Posted September 17, 2021 Share Posted September 17, 2021 Keydown is just checking to see if there has been a key pressed. I think the value of SHIFT is stored when KeyDown runs rather than being a continually updated thing. Just a quick hack to make it work. HTH. Quote Link to comment
Julian Carr Posted September 17, 2021 Share Posted September 17, 2021 I have never be able to make modifier keys works reliably with scripts, but all power to you if you manage to crack it. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.