0
回答
Android: 用Instrumentation类发送鼠标或按键事件
开发十年,就只剩下这套Java开发体系了   

模拟鼠标MotionEvent.ACTION_DOWN:

new Thread () {
					public void run () {
						try {
			 		         Instrumentation inst=new Instrumentation();
			 		         inst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),
			 		        		 SystemClock.uptimeMillis(), 
			 		        		 MotionEvent.ACTION_DOWN, 240, 400, 0));
			 		         inst.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),
			 		        		 SystemClock.uptimeMillis(), 
			 		        		 MotionEvent.ACTION_UP, 240, 400, 0)); 	
						} catch(Exception e) {
							Log.e("Exception when sendPointerSync", e.toString());
						}
					}
				}.start();
 


原文链接:http://blog.csdn.net/zmyde2010/article/details/6204596
<无标签>
举报
长平狐
发帖于6年前 0回/3K+阅
顶部