Ruby Hotkeys Plugin?
-
I mean another thing.
It does not matter which plug-in to execute. Maybe "Weld", maybe "Beld" or maybe "Weld-Beld". Does Ruby ability to perform the command associated with the "hotkeys" assigned to Sketchup?
I don't want to know the name of the method, which plugin defines. I only know one thing - "hotkeys", which I defined in Sketchup, the plugin can be arbitrary. -
Then no. At least not without this: http://code.google.com/p/eventrelay/
-
Thank you. I'll try it
-
Is there a theoretical possibility to write the text of Ruby-script, which emulated a pressing hotkeys defined in the SketchUp by the user?
-
@sergey2402 said:
Is there a theoretical possibility to write the text of Ruby-script, which emulated a pressing hotkeys defined in the SketchUp by the user?
On a PC you can use Wscript.shell to simulate specific keystrokes... BUT why would you want to do this ??
-
use the Sketchup.send_action method.
-
@dan rathbun said:
use the Sketchup.send_action method.
I know some of numeric values applied to “Sketchup.send_action( )"
For example, some of them:
10527: "Shift+Ctrl+E"
10526: "Shift+Ctrl+W"
-7892: "Ctrl+Y"
21101: "Ctrl+A"
21065: "A"
21096: "C"
21019: "E"
21074: "B"And so on…
But I don’t know the numeric values for the key combination, for example, "Shift+Ctrl+A" or "Shift+Ctrl+B" or "Shift+Ctrl+C", etc.
Where can I find numeric values for these (and similar) key combination?
-
@tig said:
BUT why would you want to do this ??
I will answer your question. But, with my “excellent knowledge of English”, I'll be a long time to formulate my ideas.
-
@sergey2402 said:
Where can I find numeric values for these (and similar) key combination?
Numeric arguments only work on Windows, not on Apple Mac.
Concentrate on the command (not the key combos,) and use the string arguments for send_action.
Example: Ctrl+Shift+W = Camera Zoom Window, so:
Sketchup.send_action("selectZoomWindowTool:")
Any user can change the shortcut key combos for commands.
-
@dan rathbun said:
Numeric arguments only work on Windows, not on Apple Mac.
Concentrate on the command (not the key combos,) and use the string arguments for send_action.
Example: Ctrl+Shift+W = Camera Zoom Window, so:
Sketchup.send_action("selectZoomWindowTool:")
Any user can change the shortcut key combos for commands.
Thank you very much for you paid me attention. But my question is different.
Where can I find numeric values for these ("Shift+Ctrl+A" or "Shift+Ctrl+B" or "Shift+Ctrl+C") key combination? -
@sergey2402 said:
In a nutshell - the ultimate goal to create a Ruby script called "hotkeys buttons on the toolbar"
I mean, hotkeys are not built into SketchUp. I mean user-defined any hotkeys for any plugins.?
You can define hotkeys for any menu or toolbar element - that include those the belongs to ruby scripts? -
@thomthom said:
?
You can define hotkeys for any menu or toolbar element - that include those the belongs to ruby scripts?Sorry, I do not understand. That was the question? Or was it your help?
Of course, my English is "excellent", but I understand it is very bad. -
@tig said:
BUT why would you want to do this ??
In a nutshell - the ultimate goal to create a Ruby script called "hotkeys buttons (or icons) on the toolbar"
I mean, hotkeys are not built into SketchUp. I mean user-defined any hotkeys for any plugins. -
Window > Preferences > Shortcuts
Filter for the tool/ruby required.
Set shortcut key[s] to it.
Note that some items only appear in the list if there is a suitable selection - e.g. to shortcut to 'Reverse' face as seen in the context-menu, you must first select a face then open Preferences - if no face is selected then the 'Reverse' doesn't appear in the available items to shortcut to...
Provided your plugin has some sort of menu presence you can shortcut to it by 'name'... -
Serge, you are talking about Windows Automation with Ruby.
The "Ruby Way" is to use the Ruby Win32ole library. (Search Ruby Gems about using Ruby libraries in SketchUp-Ruby.)
Alternative to win32ole, some plugins use the WShell.SendKeys() from a .vbs script to do the automation. (I use this in Save as Previous Version.) Windows Powershell can also use the SendKeys function to automate Windows.
There is no "perfect" solution.
-
@jim said:
Serge, you are talking about Windows Automation with Ruby.
Unfortunately, for me it is too difficult. I'm just a civil engineer, not a programmer. I really like SketchUp and I found it very useful. I just want a little to tweak it for me...
-
In the menu Window > Preferences > Shortcuts I redefined the letter "H" from the “Camera/Pan” to plugin “Pipe Along Path”.
I drew the lines, selected them and pressed on the keyboard the letter “H”.
Plugin “Pipe Along Path” been executed. BINGO!I drew the lines again, selected them and run Window > Ruby Console.
In the Ruby console I wrote a string “Sketchup.send_action 10523” and pressed Enter
(I know - the value of 10 523 corresponds to the letter “H”)And what I see as a result?
I see a HAND (Camera/Pan)!!!
What nonsense is going on?
-
What makes you think that 'Sketchup.send_action 10523' is an 'H' ???
10523 == 'Moves the camera viewpoint while maintaining view direction' [PC only!!]
Remapping a shortcut key has no connection whatsoever with that key's previously linked command ???
You've simply changed 'H' to be the shortcut key for 'PipeAlongPath'...
The 'send_action' still calls the fixed linked-command!
IF you want to use the 'H' to execute its linked-command use a Wscript or similar key-emulator BUT, oh BUT, why are you trying to do this weirdness ?????
Why not simply invoke PipeAlongPath directly ??? -
Yes. You are right. Just I have not checked the information given to me
-
I know about the key-emulators.
But I want to achieve this result by means Ruby and Sketchup. Is it not possible?
Advertisement