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!
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.
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.
VBA
Public Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long<BR />Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long<BR />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
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? ); ); );
How can I use JSL to get CPU usage?
</CODE></LI><LI><CODE class=" language-jsl">vVBA
Set objProc = GetObject("winmgmts:\\.\root\cimv2:win32_processor='cpu0'"): cpu = objProc.LoadPercentage
</CODE></LI><LI><CODE class=" language-jsl">