对于想了解获取MacOSX中当前活动的窗口/文档的标题的读者,本文将提供新的信息,我们将详细介绍mac获取当前文件夹路径,并且为您提供关于AJAX:获取加载的html文档的标题(jquery)、And
对于想了解获取Mac OS X中当前活动的窗口/文档的标题的读者,本文将提供新的信息,我们将详细介绍mac获取当前文件夹路径,并且为您提供关于AJAX:获取加载的html文档的标题(jquery)、Android 6.0:获取当前活动的包名、android – 从当前活动中完成堆栈中的所有先前活动?、android – 有没有办法通过adb获取当前活动的布局和视图?的有价值信息。
本文目录一览:- 获取Mac OS X中当前活动的窗口/文档的标题(mac获取当前文件夹路径)
- AJAX:获取加载的html文档的标题(jquery)
- Android 6.0:获取当前活动的包名
- android – 从当前活动中完成堆栈中的所有先前活动?
- android – 有没有办法通过adb获取当前活动的布局和视图?
获取Mac OS X中当前活动的窗口/文档的标题(mac获取当前文件夹路径)
参考先前提出的问题,我想知道如何获取当前活动文档的标题。
我尝试了上述问题的答案中提到的脚本。这有效,但仅给我应用程序的名称。例如,我正在写这个问题:启动脚本时,它将为我提供应用程序的名称,即“
Firefox”。这很干净,但并没有真正的帮助。我想记录我当前活动文档的标题。看到图像。
Firefox标题http://img.skitch.com/20090126-nq2egknhjr928d1s74i9xixckf.jpg
我正在使用Leopard,因此不需要向后兼容。另外,我正在使用Python的Appkit来访问NSWorkspace类,但是如果您告诉我Objective-
C代码,则可以弄清楚对Python的翻译。
好的,我有一个不是很令人满意的解决方案,这就是为什么我没有标注Koen Bok的答案。至少还没有。
tell application "System Events"set frontApp to name of first application process whose frontmost is trueend telltell application frontAppif the (count of windows) is not 0 then set window_name to name of front windowend ifend tell
另存为脚本,并从外壳中使用osascript调用它。
答案1
小编典典据我所知,最好的选择是包装AppleScript。但是AppleScript对我来说是神奇的,因此我将其作为发问者的练习:-)
这可能会有所帮助:调整前两个窗口大小以填充屏幕的脚本-Mac OS
X提示
AJAX:获取加载的html文档的标题(jquery)
我试过这个,但没有运气:
$.ajax({ url: "test.htm",cache: false,dataType: "html",success: function(html){ $('#main-load').html(html); $('#greeting').append($(html).find('title').text()); } });
我也尝试过其他一些方法,但没有运气.有任何想法吗?
谢谢!
编辑:
test.htm是一个非常简单的文档.
例:
<html> <head> <title>Page Title</title> <style> .... </style> </head> <body> .... </body> </html>
解决方法
var title = html.match("<title>(.*?)</title>")[1];
Android 6.0:获取当前活动的包名
参见英文答案 > Package name of current running application package name Android 6.0 1个
> How to get package name from anywhere? 12个
如何获取当前活动包名称?因为getRunningAppProcesses()在Android 6.0中不起作用.
以下是我的代码:
GrdPhoto.setonItemClickListener(new AdapterView.OnItemClickListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//get package name of current running application.
ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
packageName = mActivityManager.getRunningAppProcesses().get(1).processName;
Log.e("Package name:=========== ", "Package name " + packageName);
}
});
解决方法:
获取包名称:
getApplicationContext().getPackageName();
请参阅此:Get package name.
android – 从当前活动中完成堆栈中的所有先前活动?
如何完成应用程序堆栈中的任何先前活动(在任何级别,我的意思不是直接的父级),从当前活动,如某些特定事件,我想要使此前一个活动无效?有帮助吗?谢谢.
解决方法:
我知道这个答案可能会迟到,但我仍然会发布它以防万一有人正在寻找这样的东西.
我做的是我在ACTIVITY_A中声明了一个静态处理程序
public static Handler h;
在我的ACTIVITY_A的onCreate()方法中,我有
h = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch(msg.what) {
case 0:
finish();
break;
}
}
};
现在,从此之后的任何活动,例如ACTIVITY_B或ACTIVITY_C,我都可以打电话
ACTIVITY_A.h.sendEmptyMessage(0);
然后在ACTIVITY_A和ta-da中调用finish()! ACTIVITY_A由不同的活动完成.
android – 有没有办法通过adb获取当前活动的布局和视图?
出于环境原因,我只能使用adb命令.
有没有办法获得当前的布局属性,如ID,位置,文本等?
与uiautomatorviewer显示的相似.
解决方法:
使用adb shell uiautomator dump命令:
Usage: uiautomator <subcommand> [options]
Available subcommands:
help: displays help message
runtest: executes UI automation tests
runtest <class spec> [options]
<class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> >
<JARS>: a list of jar files containing test classes and dependencies. If
the path is relative, it's assumed to be under /data/local/tmp. Use
absolute path if the file is elsewhere. Multiple files can be
specified, separated by space.
<CLASSES>: a list of test class names to run, separated by comma. To
a single method, use TestClass#testMethod format. The -e or -c option
may be repeated. This option is not required and if not provided then
all the tests in provided jars will be run automatically.
options:
--nohup: trap SIG_HUP, so test won't terminate even if parent process
is terminated, e.g. USB is disconnected.
-e debug [true|false]: wait for debugger to connect before starting.
-e runner [CLASS]: use specified test runner class instead. If
unspecified, framework default runner will be used.
-e <NAME> <VALUE>: other name-value pairs to be passed to test classes.
May be repeated.
-e outputFormat simple | -s: enabled less verbose JUnit style output.
dump: creates an XML dump of current UI hierarchy
dump [--verbose][file]
[--compressed]: dumps compressed layout information.
[file]: the location where the dumped XML should be stored, default is
/storage/emulated/legacy/window_dump.xml
events: prints out accessibility events until terminated
默认情况下,它会将视图层次结构转储到$EXTERNAL_STORAGE / window_dump.xml
adb shell uiautomator dump
UI hierchary dumped to: /sdcard/window_dump.xml
通常,您可能希望将该文件提取到PC进行进一步处理,这将是一个额外的步骤.但是有一个巧妙的技巧,它允许将转储和拉入组合成一个命令.使用/ dev / tty作为转储目标将生成一个命令,将整个转储打印到stdout:
adb exec-out uiautomator dump /dev/tty
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><hierarchy rotation="0"><node ...></node></hierarchy>UI hierchary dumped to: /dev/tty
今天的关于获取Mac OS X中当前活动的窗口/文档的标题和mac获取当前文件夹路径的分享已经结束,谢谢您的关注,如果想了解更多关于AJAX:获取加载的html文档的标题(jquery)、Android 6.0:获取当前活动的包名、android – 从当前活动中完成堆栈中的所有先前活动?、android – 有没有办法通过adb获取当前活动的布局和视图?的相关知识,请在本站进行查询。
本文标签: