71
Mach4 General Discussion / Re: Z home before cycle start
« on: March 06, 2022, 03:46:08 AM »
What are you trying to do?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
scr.GetActiveWindowText()
local windowText = scr.GetActiveWindowText() --Get the window title text
local find = string.find(windowText, "Mach 4") --Search for "Mach 4" in the window title.
local hKeyboardOutput = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
local keyboardOutputState = mc.mcSignalGetState(hKeyboardOutput)
if find ~= nil then
--"Mach 4" was found i.e. Window is active
if (keyboardOutputState == mc.MC_OFF) then --Only turn on the output if it is off
mc.mcSignalSetState(hKeyboardOutput, mc.MC_ON)
end
else
--"Mach 4" was not found i.e. window minimised or lost focus
if (keyboardOutputState == mc.MC_ON) then--Only turn off the output if it is on
mc.mcSignalSetState(hKeyboardOutput, mc.MC_OFF)
end
end