0
回答
Android: 用Instrumentation类发送鼠标或按键事件
【寻找人气王】邀新用户免费体验华为云服务,百元话费等你拿!   

模拟鼠标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回/2K+阅
顶部