我想用Java模拟一个自然的鼠标移动(从这里到像素逐行).要做到这一点,我需要知道起始坐标.
我找到了方法event.getX()和event.getY()但我需要一个事件......
如何在不做任何事情(或不可见的事情)的情况下知道这些职位?
谢谢
我想将一个String转换为KeyEvent来做这样的事情:
writeKeyboard(myBot,"abcd");
public void writeKeyboard(Robot bot, String st){
char[] arr = arr.toCharArray();
int i = arr.length();
int j = 0;
int keycode;
while (j<i) {
keycode = arr[j].something;
bot.keyPress(keycode);
bot.keyRelease(keycode);
j++;
}
}
Run Code Online (Sandbox Code Playgroud) 我的应用程序旨在仅作为服务运行(没有接口,只在后台运行).我的AndroidManifest.xml中没有提到任何活动,但是在电话启动时放置了一个接收器来启动应用程序.
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service
android:enabled="true"
android:name=".MyAppService">
<intent-filter>
<action
android:name = "me.myapp.MyAppService">
</action>
</intent-filter>
</service>
<receiver
android:enabled="true"
android:name=".BootReceiver">
<intent-filter>
<action android:name = "android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
Run Code Online (Sandbox Code Playgroud)
问题是,当我正在开发(使用Eclipse)应用程序时,我需要经常测试我的更改.当我运行应用程序(我的手机在调试模式下连接)时,我收到了一条消息
[2011-12-14 00:18:40 - MyApp] Android Launch!
[2011-12-14 00:18:40 - MyApp] adb is running normally.
[2011-12-14 00:18:40 - MyApp] No Launcher activity found!
[2011-12-14 00:18:40 - MyApp] The launch will only sync the application package on the device!
[2011-12-14 00:18:40 - MyApp] Performing sync
Run Code Online (Sandbox Code Playgroud)
如何在运行时启动应用程序,而不必每次都重新启动它?
Android 3.1或更高版本不再可以编辑此功能.资源
我在python 3中编写了一个需要加密函数的程序(至少是aes和rsa).我发现PyCrypto似乎只适用于2.x版本.
是否有任何好的工具可用于python 3或者我应该开始翻译我的程序以兼容python 2(或任何其他解决方案)?
谢谢
更新如下所述,PyCrypto现在可以在py3k上使用
如何在Python中控制鼠标和键盘?
我们的想法与Java中的Robot()类相同.能够说:将鼠标从这里移动到这里,点击那里,写出屏幕上的任何内容.
对于Windows,有win32api,但我主要使用的是Linux.
对于Linux有Xlib,但它也适用于键盘吗?(仅发现鼠标的参考)
有跨平台的解决方案吗?(Linux,Windows甚至OS X都会很棒.)
在我的程序中,我需要检查是否已经在一组2.5*10 ^ 9中生成了一个值.我希望生成大约一半的集合,并需要快速检查和更新它.在我看来,bitset是一个好主意,因为它不需要太多内存(每个值1位)并且速度很快.
问题是,当我在我的课程中定义我的设置时,我得到一个segmentation fault因为尺寸太大(它适用于较小的尺寸).
private:
std::bitset<2500000000UL> cover; // not working
std::bitset<25000UL> cover; // working
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
谢谢
PS:如果可能,我宁愿不使用外部库.我已经在使用GMP,但我不认为他们对大数字有一点设置.
我搜索了很多,但我的django网站仍然存在静态文件(css,image,...)的问题.
我在archlinux 64bits上使用带有apache的mod_wsgi
我在http.conf中添加了它:
LoadModule wsgi_module modules/mod_wsgi.so
<VirtualHost *:80>
WSGIDaemonProcess mart.localhost user=mart group=users processes=2 threads=25
WSGIProcessGroup mart.localhost
LogLevel debug
Alias /media /home/mart/programmation/python/django/martfiles/media/
<Directory /home/mart/programmation/python/django/martfiles/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /srv/http/wsgi-scripts/django.wsgi
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我试图在我的主文件夹中使用django.wsgi,但它不起作用(permission denied to access /)(奇怪的是,如果我使用此处给出的测试脚本,它可以工作)
所有目录和内容(apache文件夹,wsgi-script,martfiles)都775 root:devusers拥有组devusers 的权限,包括我的用户,http和root
在我的模板base.html中,我用这种方式调用css:
<html> <head>
<link rel="stylesheet" href="/media/css/style.css" />
Run Code Online (Sandbox Code Playgroud)
以及/var/log/http/error.log中的错误
[Sat Jan 16 13:22:21 2010] [error] [client 127.0.0.1] (13)Permission denied: access to /media/css/style.css denied, referer: http://localhost/
[Sat Jan 16 13:22:21 2010] [info] mod_wsgi (pid=14783): …Run Code Online (Sandbox Code Playgroud) 我想知道我目前在Android上的手机信号塔的信号强度.经过一些研究后我发现,我应该使用一个PhoneStateListener监听更新来获取价值(陌生的方式来做恕我直言).
所以我想在得到信号后立即得到信号,然后停止听众.这是我使用的代码:
// object containing the information about the cell
MyGSMCell myGSMCell = new MyGSMCell(cid,lac);
// object listening for the signal strength
new GetGsmSignalStrength(myGSMCell, context);
...
public class GetGsmSignalStrength {
private MyGSMCell callback;
private TelephonyManager telMan;
private MyPhoneStateListener myListener;
public GetGsmSignalStrength(MyGSMCell callback, Context context) {
this.callback = callback;
this.myListener = new MyPhoneStateListener();
this.telMan = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
this.telMan.listen(this.myListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
private class MyPhoneStateListener extends PhoneStateListener
{
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
// get the strength
super.onSignalStrengthsChanged(signalStrength);
// return it …Run Code Online (Sandbox Code Playgroud) 我试图在python 3中创建一个Twitter和StatusNet客户端,但我遇到了问题,我找到的所有示例都使用OAuth库.有一些例子只使用curl或简单的身份验证,但它是非常基本的.
你知道Python 3的端口是否为OAuth(1或2)?
谢谢
更新:可能缺少端口是由于缺乏良好的python 2实现?
我需要发送一个python脚本的编译版本,并能够证明(使用哈希)编译文件确实与原始文件相同.
到目前为止我们使用的是一个简单的:
find . -name "*.py" -print0 | xargs -0 python2 -m py_compile
Run Code Online (Sandbox Code Playgroud)
问题是这是不可重复的(不确定是什么波动的因素,但是2次执行不会给同一个python文件提供相同的.pyc)并迫使我们总是运送相同的编译版本而不是只能给出构建脚本给任何人生成一个新的编译版本.
有没有办法实现这一目标?
谢谢