SHORTCUT KEY for DIALOG BOX BUTTON . . .
2019-10-14-145328
All --
I am translating an IMAGE-PRO PLUS MACRO into an APP for IMAGE-PRO (10).
The customer is used to triggering one of their macro functions by pressing
CONTROL + T
and anther by pressing
F8
I see within the properties of a PUBLIC FUNCTION that is the result of a RECORD MACRO that I can set
SHORTCUT = CTRLT
to trigger the PUBLIC FUNCTION.
It seems that this PUBLIC FUNCTION must be a SIMPLE SCRIPT and that it cannot call another function.
Can you recommend a way that I can link a keyboard shortcut to a at GUI BUTTON or the function triggered by a GUI BUTTON?
Thanks.
-- Matt
0
Best Answer
-
Hi Matt,
No, you cannot use Hello.Shortcut = MediaCy.IQL.Application.mcScriptShortcut.CtrlT with any function as .Shortcut is a property of SimpleScript.
My example should work for anything, just be sure you put the code into "module.vb (not app). First try my function as it is, and if it works, try to modify for your needs.
Yuri
0
Answers
-
Hi Matt,
You can link any GUI button to a a script with calls to any sub or function, which could be executed by a keyboard shortcut.Public Function Hello() As SimpleScript Hello = New SimpleScript Hello.Shortcut = MediaCy.IQL.Application.mcScriptShortcut.CtrlT With Automate.ScriptingCommands.CodeCommand(Hello) If .Run() Then ' User Code Here MsgBox("Hi, you pressed Ctrl-T") End If End With End Function
Will it work for you?
Yuri
0 -
2019-10-15-092816Yuri --Thank you for your response.I tried something like that.I took out the WITH and put a CALL to the SUB that I wanted to execute with the CONTROL + T and the WORKBENCH did not like the FUNCTION.I will try this again with the SUB CALL within the WITH LOOP.Is there a way to use something like the
Hello.Shortcut = MediaCy.IQL.Application.mcScriptShortcut.CtrlT
to directly connect the CONTROL + T to the function that is triggered by the GUI BUTTON?Thanks again.-- Matt0 -
2019-10-15-155003Yuri --I think that might be part of the problem. I may have recorded my version into the APP CODE and then added the SHORTCUT (which I think worked) but then I think I broke it by putting in the call to the SUB connected to the GUI BUTTON.I'll try to wire this in shortly.Thanks again.-- Matt
0 -
2019-10-15-162946Yuri --I implemented your suggestion and the USER can now will trigger the SUB connected to a GUI BUTTON with the CONTROL + T.The CODE connected to the GUI BUTTON is
Public Sub button_CaptureImages_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_CaptureImages.Click .
.
.
.
.
End SubSince the HELLO CODE does not seem to want to connect to the BUTTON CODE above, I created the REMOTE CODE belowPublic Sub Remote_CaptureImages() Call button_CaptureImages_Click(Nothing,Nothing) End Sub
Both of those SUBs are in the APP FILE.The CODE that listens for the CONTROL + T that is currently in the MODULE FILE isPublic Function Hello() As SimpleScript Hello = New SimpleScript Hello.Shortcut = MediaCy.IQL.Application.mcScriptShortcut.CtrlT With Automate.ScriptingCommands.CodeCommand(Hello) If .Run() Then ' User Code Here ' MsgBox("Hi, you pressed Ctrl-T") With Automate.ScriptingCommands.PlayMacro(Hello) .MacroFile = "CSD PROJECT V1B>CSD APP V1B.vb" .MacroName = "Remote_CaptureImages" .Run(Nothing, Nothing) End With End If End With End Function
and it can now access the REMOTE CODE which can access the BUTTON CODE.I tried to have the HELLO CODE call the BUTTON CODE but that did not seem to work.Thank you for your assistance.-- Matt
0 -
Hi Matt,
I actually meant a different implementation:Public Sub button_CaptureImages_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button_CaptureImages.Click 'call Hello Hello End Sub
andPublic Function Hello() As SimpleScript Hello = New SimpleScript Hello.Shortcut = MediaCy.IQL.Application.mcScriptShortcut.CtrlT With Automate.ScriptingCommands.CodeCommand(Hello) If .Run() Then ' Do the acquisition here ' add the code from button_CaptureImages_Click here
So the button click and Ctrl-T will do the same action.
CaptureSomething End If End With End Function
Yuri0 -
2019-10-15-183310Yuri --I see what you are suggesting.I think there would be issues with that though.Thebutton_CaptureImages_ClickCODE contains a loop that is controlled by the contents of a TEXT BOX within the APP GUI.I don't think the HELLO CODE in the MOD FILE would have easy access to the contents of the TEXT BOX in the GUI from the APP FILE.If there is an easy way around that issue, please let me know.Thanks again.-- Matt
0 -
Hi Matt,
One of the ways to handle that is by using events. You can create an object with events in the Module, assign to it in the app (WithEvents), then raise events in the loop of Hello function and update text box in the UpdateControls event handler of the app.
You can use WoundHealing app as an example (http://www.mediacy.com/support/imagepro/appcenter/wound-healing-application-detail): Search for UpdateControls event, which is raised from the Module and handled in the App.
Yuri0 -
2019-10-16-091826Yuri --Thank you for the guidance on this.I will look into the WOUND HEALING APP and the technique you have described that is demonstrated there.I think I could also use GLOBAL VARIABLES and create a mechanism which passes the value of the TEXT BOX to a GLOBAL VARIABLE that could be seen and used by a loop in the MOD FILE but I built the GUI BUTTON CODE first so creating bridges to the GUI from the MOD FILE was easier than creating bridges from the GUI to the MOD FILE.Thanks again.-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions