Hello Guest it is March 28, 2024, 05:26:38 AM

Author Topic: Possible to have 1 external button that runs previous VB script that was run?  (Read 4663 times)

0 Members and 1 Guest are viewing this topic.

Offline Tarak

*
  •  229 229
    • View Profile
Yep me again, is it possible to have 1 external button (much the same as a cycle start), that will run the previous VB script that was run?
I have multiple buttons that all have there own script, but I was thinking it would be nice if you could click the correct button on the screen for the first time, then after that the user could just keep pressing this external button, until a different script is needed etc.etc.
Thanks

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
OK,  it is me again..........too.........

Do this, drop an Led next to each of your buttons on the main screen, when ever you push one of the buttons, its associated led turns on, it also turns all others off.

Then in your external button, have your Macro pump monitor it, i.e.

'Macropump.m1s

If IsActive(INPUTx) Then 'this is your external button input pin
   If GetUserLED(1001) Then  'your button fuction 1 LED
   VB Script of that button here......
   End If
       If GetUserLED(1002) Then '2cd button script Led
       VB Script for 2cd button here.....
       End If
           If GetUserLED(1003) Then '3rd button action led
           VB Script for 3rd button here........
           End If
End If

'You could also use a Case Statement if more complex....

Scott
   
fun times

Offline Tarak

*
  •  229 229
    • View Profile
You my friend are a freakin genius, it works great.
BTW in my script I have it turn OFF all LED's at the start e.g
SetUserLED (1001,0)
SetUserLED (1002,0)
etc.etc
I have it do this for 24 individual LED's is there a more efficient way of doing this?
Also how can I enter this into the MacroPump so it will turn OFF all LED's when Mach starts only, rather that making them OFF all the time?
I only ask this because if I estop the sytem when a script is running, my LED's stay on until I run the script again, and it reaches the end of it where I tell the LED's to turn OFF.
......Well my wife's always telling me I'm high maintenance.......

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Genius, not really, that belongs to Art and Brian, and several others here, but, try the below.

BTW: I dont know of a more effeincet way of turning off those 24 leds, other than what you are doing.

To turn them all off with the macro pump only once your going to have to lock them out.
 
Put this piece in your Macro pump some where at the top. Note you will have to also put a "Renew LED" called (1200, or what ever), some where as well.

'add to top of macro pump

x=GetUserDro(1200)

If X=0 then
'put your turn off all led stuff here
x=x+1   'this adds 1 to x, so this script only runs once (unless see below).
End If

If X>0 and GetuserLED(1200) Then   'you have pushed the renew button this will reset X to 0
SetUserDro(1200,0)
End If

'Note: the above renew/reset is really only meant to re-run the off all 24, or to set the DRO
'back to 0, for persistant dros....... The macro pump will re-hit it while running faster
'than you can reset it. It is really just to reset your DRO to Zero.
fun times

Offline Tarak

*
  •  229 229
    • View Profile
Thanks Scott, is it possible to emulate a key being pressed?
I thought it may be easier, it'd save a lot of code in my MacroPump (Lazy I know), something like:

'Macropump.m1s
If IsActive(INPUT1) Then
   If GetUserLED(1001) Then
   Emulate pressing hotkey 110 (example only)
   End If
       If GetUserLED(1002) Then
       Emulate pressing hotkey 111 (example only)       
       End If
End If

Also on another note, I might start a post where you VB guru's can offer tid bits of code e.g Set UserLED(1000,1) with a short description and example.
But mostly for the more complex equations. thoughts?
At least I wouldn't have to bug you guys as much.
« Last Edit: April 25, 2007, 04:53:57 AM by Darc »

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Yes, look in the Mach OEM buttons codes on the wiki.

To emulate a button, put:

DoOEMButton(*********)    (Some people use "DoButton" also, so if the OEM doesnt work use that one).

There is not a range of codes for "User Buttons", you can only emulate OEM codes. NOTE, this does NOT work on Jogs.

Scott
fun times