Custom Actions Doesn't Work in Recorder

Hi, I am trying to generate a “beep” sound in the middle of my script.
The following codes can work in bot task but never work in recorder.

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
<robotics-flow>
<robot driver="universal" close-on-completion="true" start-in-private="true">
<capability name="SEARCH_ALL_WINDOWS" value="true" />
 <script><![CDATA[
          
                import java.awt.Toolkit;
                import com.workfusion.studio.rpa.recorder.api.internal.representation.*
                import com.workfusion.studio.rpa.recorder.api.*
                import com.workfusion.studio.rpa.recorder.api.types.*
                import com.workfusion.studio.rpa.recorder.api.custom.*
                import static com.workfusion.studio.rpa.recorder.api.RandomValues.CharacterSet.*

			@CustomScriptAction()

			def customScript() 
			{	
				Toolkit.getDefaultToolkit().beep();
				sleep(3000);
					
				Toolkit.getDefaultToolkit().beep();
				sleep(3000);

				Toolkit.getDefaultToolkit().beep()
			}

]]></script>
</robot>
</robotics-flow>
<export include-original-data="true"/>
</config>

And this is what I put in the recorder:

@CustomScriptAction()

def customScript() 
{
	Toolkit.getDefaultToolkit().beep();
	sleep(3000);
					
	Toolkit.getDefaultToolkit().beep();
	sleep(3000);

	Toolkit.getDefaultToolkit().beep()
}
1 Like

@Chan_JL you need to import the library in the Custom action

import java.awt.Toolkit;

@CustomScriptAction()

			def customScript() 
			{	
				Toolkit.getDefaultToolkit().beep();
				sleep(3000);
					
				Toolkit.getDefaultToolkit().beep();
				sleep(3000);

				Toolkit.getDefaultToolkit().beep()
			} 
2 Likes

Ya!!! It works!!
Thank you so muchhh :heart:

2 Likes