cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lwx228
Level VIII

How can simulate mouse operation through JSL?

For example, I want to simulate mouse operation through JSL:


1. Simulate moving cursor: move the cursor to the specified position: for example, x=180;Y = 380;
2. Left click: Left click and click the "Go" button.

 

Thanks!

 

2020-08-07_16-49.png

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: How can simulate mouse operation through JSL?

You can click the button like this:

dt=open("$sample_data/big class.jmp");
p = dt<<Partition(
	Y( :age ),
	X( :height, :weight ),
	Validation Portion( 0.25 ),
	Informative Missing( 1 )
);
(report(p)<<xpath("//ButtonBox[@title = 'Go']"))<<click;

Why do you want to move the mouse cursor? There are things beside buttons you might want to click, but there are probably better ways to automate than writing code to move the mouse. Also, people hate it when the mouse moves by itself.

 

 

Craige

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: How can simulate mouse operation through JSL?

I don't know about getting CPU usage. As far as I know JMP doesn't have any tool do to that directly.

 

However, you don't need to simulate a click on the Go button because JSL already has a Go message for the Partition platform.

 

2020-08-08_19-18-09.380.png

-Jeff

View solution in original post

10 REPLIES 10
lwx228
Level VIII

Re: How can simulate mouse operation through JSL?

VBA

Public Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Const MouseEventf_LeftDown = &H2 Public Const MouseEventf_LeftUp = &H4 Type POINTAPI x As Long y As Long End Type Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub click() SetCursorPos 180, 380 For i = 1 To 1 mouse_event MouseEventf_LeftDown, 0, 0, 0, 0 mouse_event MouseEventf_LeftUp, 0, 0, 0, 0 Next End Sub
Craige_Hales
Super User

Re: How can simulate mouse operation through JSL?

You can click the button like this:

dt=open("$sample_data/big class.jmp");
p = dt<<Partition(
	Y( :age ),
	X( :height, :weight ),
	Validation Portion( 0.25 ),
	Informative Missing( 1 )
);
(report(p)<<xpath("//ButtonBox[@title = 'Go']"))<<click;

Why do you want to move the mouse cursor? There are things beside buttons you might want to click, but there are probably better ways to automate than writing code to move the mouse. Also, people hate it when the mouse moves by itself.

 

 

Craige
lwx228
Level VIII

Re: How can simulate mouse operation through JSL?

Thank Craige!

The original JMP could be implemented this way. I learned new skills.
lwx228
Level VIII

Re: How can simulate mouse operation through JSL?

Continue to ask more unusual questions: I am now using VBA of Excel to realize various loop operations of different files by JMP by monitoring CPU utilization and controlling mouse movement and clicking. My main goal was to get the Split effect of the decision tree by clicking the "go" button, not through JSL's "Split Best(1000)". I now want to do this without VBA and instead use JSL. Now I need to implement JSL to get the CPU usage.
lwx228
Level VIII

Re: How can simulate mouse operation through JSL?

Specifically, all JMP files of a path are divided into decision trees, and the operation time of each file decision tree is different.Let's say the time is between 30 and 60 minutes.

Therefore, JSL should be designed to click the "Go" button for 30 minutes and test the CPU utilization rate every 5 minutes.


If the CPU utilization rate is less than 5%, operation d0<<Run Script("B") should be carried out;
otherwise, the loop should continue for 5 minutes and then test the CPU utilization rate until the decision tree segmentation is completed.

d0 = Current Data Table();
dir = "c:\1\";
Fs = Files In Directory( dir );
For( d = 1, d <= N Items( fs ), d++,
	dt = Open( dir || fs[d] );

	p = dt << Partition(
		Y( :Y ),
		X( :X1, :X2 ),
		Validation Portion( 0.25 ),
		Informative Missing( 1 )
	);
	(Report( p ) << xpath( "//ButtonBox[@title = 'Go']" )) << click;


	For( j = 1, j <= 6, j++,
		cpu = ……;
		If( cpu < 0.05,
			d0 << Run Script( "B" ),
			Wait( 300 )//Does this wait affect the decision tree?
		);
	);
	
);

2020-08-08_22-28.png

lwx228
Level VIII

Re: How can simulate mouse operation through JSL?

  • How can I use JSL to get CPU usage?

  • Thanks!
  • vVBA
  • Set objProc = GetObject("winmgmts:\\.\root\cimv2:win32_processor='cpu0'"): cpu = objProc.LoadPercentage
Jeff_Perkinson
Community Manager Community Manager

Re: How can simulate mouse operation through JSL?

I don't know about getting CPU usage. As far as I know JMP doesn't have any tool do to that directly.

 

However, you don't need to simulate a click on the Go button because JSL already has a Go message for the Partition platform.

 

2020-08-08_19-18-09.380.png

-Jeff
lwx228
Level VIII

Re: How can simulate mouse operation through JSL?

Thank Jeff!

 


My goal is to wait until the decision tree operation is complete before running the following script.
Does JMP have functionality in place for this?

2020-08-09_08-13.png

Craige_Hales
Super User

Re: How can simulate mouse operation through JSL?

I think JMP runs the GO button on the main thread, preventing any other activity on the main thread until the split is finished.  Can you share an example?

Craige