Private Sub Command1_Click()
i = i + 1 '计敏山算点了多少次开始
End Sub
Private Sub Command2_Click()
Text1.Text = j / i '计算出点击率
End Sub
Private Sub Form_Load()
i = 0 '初始化所禅汪点桥袭中次数为0
j = 0 '初始化时间为0
End Sub
Private Sub Timer1_Timer()
j = j + 1 '计算出用了多少时间
End Sub
注text1.text为文本框.时间的Interval属性值为1.
给你代码陵碧扰,------------------------------------------------------------------------------------------
import java.awt.MouseInfo
public class App extends JFrame implements KeyListener {
private JLabel lblNewLabel
private String str = ""
public App() {
setDefaultCloseOperation(EXIT_ON_CLOSE)
setLocationRelativeTo(null)
setSize(400, 300)
setResizable(false)
getContentPane().setLayout(null)
lblNewLabel = new JLabel("")
lblNewLabel.setBounds(0, 259, 394, 13)
getContentPane().add(lblNewLabel)
setVisible(true)
new Thread() {
public void run() {
while (true) {
try {
Point mainPoint = getLocation()
Point point = MouseInfo.getPointerInfo().getLocation()
int x = point.x - mainPoint.x
int y = point.y - mainPoint.y
if (x <0 || x >尺旦 400) {
sleep(10)
continue
}
if (y <0 || y >300) {
sleep(10)
continue
}
lblNewLabel.setText(str + "x : " + x + " y : " + y)
sleep(10)
} catch (Exception e) {
}
}
}
}.start()
this.addKeyListener(this)
}
public static void main(String[] args) {
new App()
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
str = "C "
return
}
if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
str = "S "
return
}
str = "慧液D "
}
public void keyReleased(KeyEvent e) {
str = "U "
}
public void keyTyped(KeyEvent e) {
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)