mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
research
This commit is contained in:
parent
8d931e290a
commit
935d26f956
@ -7,6 +7,8 @@ class PyWinAlfred():
|
||||
|
||||
def query(self,key):
|
||||
k = key.split(" ")[1]
|
||||
if not k:
|
||||
return ""
|
||||
r = requests.get('http://movie.douban.com/subject_search?search_text=' + k)
|
||||
bs = BeautifulSoup(r.text)
|
||||
results = []
|
||||
|
@ -23,6 +23,8 @@ char* Exec(char* directory, char* file, char* method, char* para)
|
||||
PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pClass, *pInstance;
|
||||
char *error;
|
||||
|
||||
// 启动子线程前执行,为了释放PyEval_InitThreads获得的全局锁,否则子线程可能无法获取到全局锁。
|
||||
PyEval_ReleaseLock();
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
// Initialise the Python interpreter
|
||||
@ -97,20 +99,19 @@ char* Exec(char* directory, char* file, char* method, char* para)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char* directory = "d:\\github\\WinAlfred\\WinAlfred\\bin\\Debug\\Plugins\\p";
|
||||
char* directory = "d:\\github\\WinAlfred\\Plugins\\WinAlfred.Plugin.DouBan\\";
|
||||
char* file = "main";
|
||||
char* method = "query";
|
||||
char* para1 = "p 1";
|
||||
char* para2 = "p 2";
|
||||
char* para3 = "p 3";
|
||||
char* para4 = "p 4";
|
||||
char* para1 = "movie 1";
|
||||
char* para2 = "movie 2";
|
||||
char* para3 = "movie 3";
|
||||
char* para4 = "movie 4";
|
||||
int i = 0;
|
||||
// ³õʼ»¯
|
||||
Py_Initialize();
|
||||
// ³õʼ»¯Ïß³ÌÖ§³Ö
|
||||
PyEval_InitThreads();
|
||||
PyEval_ReleaseLock();
|
||||
// 启动子线程前执行,为了释放PyEval_InitThreads获得的全局锁,否则子线程可能无法获取到全局锁。
|
||||
|
||||
//std::async(Exec,directory,file,method,para);
|
||||
std::async(Exec,directory,file,method,para1);
|
||||
std::async(Exec,directory,file,method,para2);
|
||||
|
@ -9,7 +9,6 @@ extern "C" __declspec(dllexport) void InitPythonEnv()
|
||||
{
|
||||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
PyEval_ReleaseLock();
|
||||
// 启动子线程前执行,为了释放PyEval_InitThreads获得的全局锁,否则子线程可能无法获取到全局锁。
|
||||
}
|
||||
|
||||
@ -32,8 +31,8 @@ char* Exec(char* directory, char* file, char* method, char* para)
|
||||
PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pClass, *pInstance;
|
||||
char *error;
|
||||
|
||||
PyEval_ReleaseLock();
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
// Build the name object
|
||||
PyObject *path = PySys_GetObject("path");
|
||||
PyList_Append(path, PyString_FromString(directory));
|
||||
@ -91,14 +90,13 @@ char* Exec(char* directory, char* file, char* method, char* para)
|
||||
|
||||
//PyErr_Clear();
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
return str_ret;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) char* ExecPython(char* directory, char* file, char* method, char* para)
|
||||
{
|
||||
//PyEval_ReleaseLock();
|
||||
char* s = Exec(directory,file,method,para);
|
||||
PyGILState_Ensure();
|
||||
return s;
|
||||
//auto future = std::async(Exec,directory,file,method,para);
|
||||
//return future.get();
|
||||
|
@ -104,7 +104,8 @@ Global
|
||||
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
@ -122,7 +123,7 @@ Global
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x64.Build.0 = Release|x64
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.Build.0 = Release|Win32
|
||||
{05D72D92-4010-4F92-A147-906930241573}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{05D72D92-4010-4F92-A147-906930241573}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{05D72D92-4010-4F92-A147-906930241573}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{05D72D92-4010-4F92-A147-906930241573}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{05D72D92-4010-4F92-A147-906930241573}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
|
@ -17,4 +17,4 @@
|
||||
<appender-ref ref="LogFileAppender"/>
|
||||
</root>
|
||||
</log4net>
|
||||
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
||||
|
@ -8,7 +8,6 @@ using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using IWshRuntimeLibrary;
|
||||
using Microsoft.Win32;
|
||||
using WinAlfred.Commands;
|
||||
using WinAlfred.Helper;
|
||||
@ -153,21 +152,21 @@ namespace WinAlfred
|
||||
|
||||
private void SetAutoStart(bool IsAtuoRun)
|
||||
{
|
||||
string LnkPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "//WinAlfred.lnk";
|
||||
if (IsAtuoRun)
|
||||
{
|
||||
WshShell shell = new WshShell();
|
||||
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(LnkPath);
|
||||
shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
shortcut.WorkingDirectory = Environment.CurrentDirectory;
|
||||
shortcut.WindowStyle = 1; //normal window
|
||||
shortcut.Description = "WinAlfred";
|
||||
shortcut.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.IO.File.Delete(LnkPath);
|
||||
}
|
||||
//string LnkPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "//WinAlfred.lnk";
|
||||
//if (IsAtuoRun)
|
||||
//{
|
||||
// WshShell shell = new WshShell();
|
||||
// IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(LnkPath);
|
||||
// shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
// shortcut.WorkingDirectory = Environment.CurrentDirectory;
|
||||
// shortcut.WindowStyle = 1; //normal window
|
||||
// shortcut.Description = "WinAlfred";
|
||||
// shortcut.Save();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// System.IO.File.Delete(LnkPath);
|
||||
//}
|
||||
}
|
||||
|
||||
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||
|
@ -19,7 +19,9 @@ namespace WinAlfred.PluginLoader
|
||||
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
|
||||
{
|
||||
IPlugin plugin1 = plugin;
|
||||
ThreadPool.QueueUserWorkItem(o => plugin1.Init(new PluginInitContext()
|
||||
//ThreadPool.QueueUserWorkItem(o =>);
|
||||
|
||||
plugin1.Init(new PluginInitContext()
|
||||
{
|
||||
Plugins = plugins,
|
||||
ChangeQuery = s => window.ChangeQuery(s),
|
||||
@ -27,7 +29,7 @@ namespace WinAlfred.PluginLoader
|
||||
HideApp = window.HideApp,
|
||||
ShowApp = window.ShowApp,
|
||||
ShowMsg = (title, subTitle, iconPath) => window.ShowMsg(title, subTitle, iconPath)
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WinAlfred</RootNamespace>
|
||||
<AssemblyName>WinAlfred</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -191,17 +191,6 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="app.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="IWshRuntimeLibrary">
|
||||
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<PropertyGroup>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.3" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
|
||||
<package id="log4net" version="2.0.3" targetFramework="net35" requireReinstallation="True" />
|
||||
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" requireReinstallation="True" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user