Hello Guest it is March 28, 2024, 07:36:12 PM

Author Topic: Start VB Script with button wired to input  (Read 725 times)

0 Members and 1 Guest are viewing this topic.

Start VB Script with button wired to input
« on: August 03, 2022, 11:11:33 PM »
Hi there.

  I have a simple VB Script to Auto Zero my spindle.  Can I run this script by pushing a button wired to an input on my machine?  I have buttons wired (start/stop etc) I want to replace one of those with running my script.

Thanks!

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Start VB Script with button wired to input
« Reply #1 on: August 05, 2022, 04:41:11 AM »
basicly OEMTriggers are used like regular input's but they Special functionalty

1st. you can assign in Config->System hotkeys oemcodes to a OEMtrigger witch will be done once if OEMTrigger comes true

2nd. you can define a triggermacro by SetTriggerMacro(number)

normaly done this way.

-add for example in Config->General Config ->Initialisation string  M333, that means every time you reset M333.M1s is called

-within M333.M1s add the VB code SetTriggerMacro(334)

-assign in Config->System hotkeys oemcodes to a OEMtrigger the code 301 witch means run triggermacro

so every time the OEMTrigger Comes True the VB Code within M334.M1S will run once.

hope i was able to explain the Basics of OEMTriggers in my bad bavarian english.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Start VB Script with button wired to input
« Reply #2 on: August 05, 2022, 06:12:41 AM »
Thank you very much. That all made complete sense! Perfect. To push it one step further, what if I had more buttons wired to inputs? With the SetTriggerMacro option, using OEM code 304, this would only allow for one macro after button push. Is there a way to set up other buttons in this way?

Thanks again for your reply it was extremely helpful!!

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Start VB Script with button wired to input
« Reply #3 on: August 05, 2022, 06:16:49 AM »
the oemcode for the triggermacro is allways 301!
in my example it will allway run macro M334.M1S

within this macro you can select the oemtrigger via script:

Code: [Select]
If Oemtrigger(1) Then
     'do code for Oemtrigger1
End If

If Oemtrigger(2) Then
     'do code for Oemtrigger2
End If

'and so on
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Start VB Script with button wired to input
« Reply #4 on: August 05, 2022, 06:19:36 AM »
Perfect, thanks again!