//利用打开软件
var prcs = process( "notepad.exe" )
//上面获取到进程中的id,利用id找到进程的句柄
var handww = winex.findMainWnd(,,prcs.id)
console.dump(handww)
console.dump(prcs)
win.show(handww,false)
但是这样的话,现象是:
桌面突然闪动一下,然后那个界面消失了
后台确实存在了这个进程,功能也实现了,
但是这个闪动一下太恶心人了.
求问这个闪现应该怎么消除????
executeEx = function( file,parameters,operation,showCmd,workdir,hwnd,fMask ){
if(type(file)!="string")error("无效的文件路径",2);
if( parameters === null ) parameters = "";
if( operation === null ) operation = "open";
if( showCmd === null ) showCmd = 5;
if( hwnd === null ) hwnd = 0;
file = ..io.localpath(file) : file;
if( (! #workdir ) ){
workdir = ..io.splitpath(file).dir ;
}
if( type(parameters) == type.table ){ parameters = joinArguments(parameters); }
var shInfo = SHELLEXECUTEINFO();
shInfo.fMask = fMask === null ? ( 0x440 /*SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_NO_UI*/ ) : fMask;
shInfo.hwnd = hwnd;
shInfo.lpVerb = operation;
shInfo.lpFile = file;
shInfo.lpParameters = parameters;
shInfo.lpDirectory = workdir;
shInfo.nShow = showCmd;
shInfo.hInstApp = 0;
shInfo.lpClass ="";
var ret = ::Shell32.ShellExecuteExW(shInfo);
if(!ret) return null,..lasterr();
return shInfo;
}
import console;
import process;
process.execute("notepad.exe", , ,0x0/*_SW_HIDE*/ )
console.pause(true);
隐藏,这样不闪了(废话嘛,都最小化到任务栏了),但是还是有个遗憾: 可以看到任务栏里突然闪了一下一个软件,然后就没了.但是总比整个页面闪一下好.0x2/*_SW_SHOWMINIMIZED*/
win.show(handww,false)
WSTARTUPINFO = class {
INT cb ;
ustring reserved;
ustring desktop;
ustring title;
INT x;
INT y;
INT xSize;
INT ySize;
INT xCountChars;
INT yCountChars;
INT fillAttribute;
INT flags;
WORD showWindow;
WORD cbReserved2;
ustring lpReserved2;
pointer stdInput;
pointer stdOutput;
pointer stdError;
creationFlag = 0;
inheritHandles;
};
console.open()
var startupinfow = WSTARTUPINFO();
startupinfow.reserved = null
startupinfow.x = 0
startupinfow.y = 0
startupinfow.xSize = 0
startupinfow.ySize = 0
startupinfow.xCountChars = 500
startupinfow.yCountChars = 500
startupinfow.title = null
startupinfow.flags = 0x1/*_STARTF_USESHOWWINDOW*/
startupinfow.showWindow = 0x2/*_SW_SHOWMINIMIZED*/;
startupinfow.cbReserved2 = 0
startupinfow.lpReserved2 = null
startupinfow.stdInput = null
startupinfow.stdOutput = null
startupinfow.stdError = null
startupinfow.cb = raw.sizeof( startupinfow);
console.dump(startupinfow)
winform.button.oncommand = function(id,event){
var prcs = process("notepad.exe",,startupinfow)
var handww = winex.findMainWnd(,,prcs.id)
win.show(handww,false)
}