【C++】AS3調用原生Windows API
此類可以使用AS3透過ANE的接口來調用基本的WINDOWS API
NativeAneManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Theme: FlashAR | |
Compiler: Microsoft Visual Studio 2012 Express | |
Date: 2017/11/10 | |
Author: LeesonHsu | |
Email:leesonhsu@arplanet.com.tw | |
Blog: www.arplanet.com.tw | |
*/ | |
#ifndef NativeAneManager_h | |
#define NativeAneManager_h | |
#include "ExtensionAneConfig.h" | |
//用於控制windows的管理器 | |
class NativeAneManager | |
{ | |
private: | |
FREContext freContext; | |
NativeAneManager(); | |
NativeAneManager(NativeAneManager const&); | |
NativeAneManager& operator = (NativeAneManager const&); | |
~NativeAneManager(); | |
public: | |
static NativeAneManager& getInstance() { | |
static NativeAneManager _instance; | |
return _instance; | |
} | |
//Getter/Setters for FREContext | |
FREContext getFreContext(); | |
void setFreContext(FREContext pFreContext); | |
void setKey(BOOL bState,int keyID); | |
void dispose(); | |
//win window controll | |
FREObject findWindow(FREObject windowname); | |
FREObject closeWindow(FREObject windowname); | |
FREObject showWindow(FREObject windowname,FREObject cmdhwd); | |
FREObject showWindowSync(FREObject windowname,FREObject cmdhwd); | |
FREObject setWindowFocus(FREObject windowname); | |
FREObject setForegroundWindow(FREObject windowname); | |
FREObject setWindowTop(FREObject windowname); | |
FREObject getWindowTop(); | |
//win input controll | |
FREObject sendMouseEventPos(FREObject x,FREObject y); | |
FREObject sendMouseEventClick(FREObject handtype); | |
FREObject sendMouseEventDoubleClick(FREObject handtype); | |
FREObject sendMouseEventDown(FREObject handtype); | |
FREObject sendMouseEventUP(FREObject handtype); | |
FREObject sendKeyBoardEvent(FREObject keycode,FREObject state); | |
//win process fork controll | |
FREObject createProcess(FREObject cmd); | |
FREObject findProcessbyName(FREObject processName); | |
FREObject killProcessbyPid(FREObject pid); | |
FREObject killProcessbyName(FREObject processName); | |
FREObject shellExecute(FREObject path,FREObject cmdhwd,FREObject lpOperation,FREObject lpparameters,FREObject lpDir); | |
void dispatchCreateProcess(const uint8_t* pid); | |
void dispatchOnExitProcess(const uint8_t* pid); | |
}; | |
#endif |
NativeAneManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Theme: FlashAR | |
Compiler: Microsoft Visual Studio 2012 Express | |
Date: 2017/02/13 | |
Author: LeesonHsu | |
Email:leesonhsu@arplanet.com.tw | |
Blog: www.arplanet.com.tw | |
*/ | |
#include "ExtensionAneConfig.h" | |
#include "AneDataConvert.h" | |
NativeAneManager::NativeAneManager() | |
{ | |
} | |
NativeAneManager::~NativeAneManager() | |
{ | |
} | |
NativeAneManager::NativeAneManager(NativeAneManager const&) | |
{ | |
} | |
//Getter/Setters for FREContext | |
FREContext NativeAneManager::getFreContext() | |
{ | |
return freContext; | |
} | |
void NativeAneManager::setFreContext(FREContext pFreContext) | |
{ | |
freContext = pFreContext; | |
} | |
void NativeAneManager::dispose() | |
{ | |
} | |
//win window controll | |
//找尋視窗 | |
FREObject NativeAneManager::findWindow(FREObject windowname) | |
{ | |
//取得程序窗口 | |
bool isHasHwd = false; | |
HWND hwd = FindWindow(NULL,AneDataConvert::ToUTF8_LCPW(windowname)); //window Name | |
if(hwd) | |
{ | |
isHasHwd=true; | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//關閉視窗 | |
FREObject NativeAneManager::closeWindow(FREObject windowname) | |
{ | |
bool isHasHwd = false; | |
//取得程序窗口 | |
HWND hwd = FindWindow( NULL, AneDataConvert::ToUTF8_LCPW(windowname)); //window Name | |
if(hwd) | |
{ | |
SendMessage(hwd, WM_SYSCOMMAND, SC_CLOSE, 0); | |
isHasHwd=true; | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//顯示視窗 | |
FREObject NativeAneManager::showWindow(FREObject windowname,FREObject cmdhwd) | |
{ | |
bool isHasHwd = false; | |
//取得程序窗口 | |
HWND hwd = FindWindow( NULL, AneDataConvert::ToUTF8_LCPW(windowname)); //window Name | |
int cmd = AneDataConvert::ToInt(cmdhwd); | |
if(hwd) | |
{ | |
//控制Windows顯示方式 | |
isHasHwd = ShowWindow(hwd,cmd); | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//顯示視窗 | |
FREObject NativeAneManager::showWindowSync(FREObject windowname,FREObject cmdhwd) | |
{ | |
bool isHasHwd = false; | |
//取得程序窗口 | |
HWND hwd = FindWindow( NULL, AneDataConvert::ToUTF8_LCPW(windowname)); //window Name | |
int cmd = AneDataConvert::ToInt(cmdhwd); | |
if(hwd) | |
{ | |
//控制Windows顯示方式 | |
isHasHwd = ShowWindowAsync(hwd,cmd); | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//強制取得視窗焦點 | |
FREObject NativeAneManager::setWindowFocus(FREObject windowname) | |
{ | |
//取得程序窗口 | |
bool isHasHwd =false; | |
//呼叫WindowsAPP | |
HWND hwd = FindWindow( NULL, AneDataConvert::ToUTF8_LCPW(windowname)); | |
if(hwd) | |
{ | |
//取得焦點 | |
SetFocus(hwd); | |
isHasHwd=true; | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//強制將視窗置前 | |
FREObject NativeAneManager::setForegroundWindow(FREObject windowname) | |
{ | |
//取得程序窗口 | |
bool isHasHwd =false; | |
//呼叫WindowsAPP | |
HWND hwd = FindWindow( NULL, AneDataConvert::ToUTF8_LCPW(windowname)); | |
if(hwd) | |
{ | |
SetForegroundWindow(hwd); | |
isHasHwd=true; | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//取得目前最上層視窗 | |
FREObject NativeAneManager::getWindowTop() | |
{ | |
wchar_t wnd_title[4096]; | |
HWND hwnd = GetForegroundWindow(); // get handle of currently active window | |
if(hwnd) | |
{ | |
GetWindowText(hwnd,wnd_title,sizeof(wnd_title)); | |
} | |
return AneDataConvert::AsUTF8_WCHAR(wnd_title); | |
} | |
//強制置頂 | |
FREObject NativeAneManager::setWindowTop(FREObject windowname) | |
{ | |
//取得程序窗口 | |
bool isHasHwd =false; | |
//呼叫WindowsAPP | |
HWND hwd = FindWindow( NULL, AneDataConvert::ToUTF8_LCPW(windowname)); | |
if(hwd) | |
{ | |
HWND hForeWnd = GetForegroundWindow(); | |
DWORD dwForeID = GetWindowThreadProcessId(hForeWnd, NULL); | |
DWORD dwCurID = GetCurrentThreadId(); | |
AttachThreadInput(dwCurID, dwForeID, TRUE); | |
ShowWindow(hwd, SW_SHOWNORMAL); | |
SetWindowPos(hwd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); | |
SetWindowPos(hwd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); | |
SetForegroundWindow(hwd); | |
AttachThreadInput(dwCurID, dwForeID, FALSE); | |
isHasHwd = true; | |
} | |
return AneDataConvert::AsBool(isHasHwd); | |
} | |
//win input controll | |
//強制移動座標 | |
FREObject NativeAneManager::sendMouseEventPos(FREObject x,FREObject y) | |
{ | |
//設定系統的座標,為Windows.h裡的方法 | |
bool isMove = SetCursorPos(AneDataConvert::ToInt(x),AneDataConvert::ToInt(y)); | |
return AneDataConvert::AsBool(isMove); | |
} | |
//強制滑鼠點擊 | |
FREObject NativeAneManager::sendMouseEventClick(FREObject handtype) | |
{ | |
int32_t hand = AneDataConvert::ToInt(handtype); | |
//觸發滑鼠事件,click事件其實就是mousedown跟mouseup的組合 | |
if(hand==0) | |
{ | |
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); | |
} | |
else if(hand==1) | |
{ | |
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 ); | |
} | |
else if(hand==2) | |
{ | |
mouse_event(MOUSEEVENTF_MIDDLEDOWN | MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0 ); | |
} | |
return AneDataConvert::AsBool(true); | |
} | |
//強制雙擊滑鼠 | |
FREObject NativeAneManager::sendMouseEventDoubleClick(FREObject handtype) | |
{ | |
int32_t hand = AneDataConvert::ToInt(handtype); | |
//觸發滑鼠事件,click事件其實就是mousedown跟mouseup的組合 | |
if(hand==0) | |
{ | |
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); | |
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); | |
} | |
else if(hand==1) | |
{ | |
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 ); | |
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 ); | |
} | |
else if(hand==2) | |
{ | |
mouse_event(MOUSEEVENTF_MIDDLEDOWN | MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0 ); | |
mouse_event(MOUSEEVENTF_MIDDLEDOWN | MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0 ); | |
} | |
return AneDataConvert::AsBool(true); | |
} | |
//滑鼠MouseEventDown | |
FREObject NativeAneManager::sendMouseEventDown(FREObject handtype) | |
{ | |
int32_t hand = AneDataConvert::ToInt(handtype); | |
//觸發滑鼠事件,click事件其實就是mousedown跟mouseup的組合 | |
if(hand==0) | |
{ | |
mouse_event(MOUSEEVENTF_LEFTDOWN , 0, 0, 0, 0 ); | |
} | |
else if(hand==1) | |
{ | |
mouse_event(MOUSEEVENTF_RIGHTDOWN , 0, 0, 0, 0 ); | |
} | |
else if(hand==2) | |
{ | |
mouse_event(MOUSEEVENTF_MIDDLEDOWN , 0, 0, 0, 0 ); | |
} | |
return AneDataConvert::AsBool(true); | |
} | |
//滑鼠MouseEventUP | |
FREObject NativeAneManager::sendMouseEventUP(FREObject handtype) | |
{ | |
int32_t hand = AneDataConvert::ToInt(handtype); | |
//觸發滑鼠事件,click事件其實就是mousedown跟mouseup的組合 | |
if(hand==0) | |
{ | |
mouse_event(MOUSEEVENTF_LEFTUP , 0, 0, 0, 0 ); | |
} | |
else if(hand==1) | |
{ | |
mouse_event(MOUSEEVENTF_RIGHTUP , 0, 0, 0, 0 ); | |
} | |
else if(hand==2) | |
{ | |
mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0 ); | |
} | |
return AneDataConvert::AsBool(true); | |
} | |
//發出鍵盤事件 | |
FREObject NativeAneManager::sendKeyBoardEvent(FREObject keycode,FREObject state) | |
{ | |
int32_t code = AneDataConvert::ToInt(keycode); | |
bool keyStates = AneDataConvert::ToBool(state); | |
//觸發鍵盤事件 | |
// | |
// | |
setKey(keyStates,code); | |
return AneDataConvert::AsBool(true); | |
} | |
//創建程序 | |
FREObject NativeAneManager::createProcess(FREObject commandLine) | |
{ | |
uint32_t len; | |
const uint8_t* str; | |
wchar_t wBuffer[1024]; | |
FREGetObjectAsUTF8(commandLine, &len, &str ); | |
MultiByteToWideChar( CP_UTF8, 0, (const char*)str, -1, wBuffer, 1024); | |
int32_t pid = NativeProcessManager::getInstance().createProcess(wBuffer); | |
return AneDataConvert::AsUint(pid); | |
} | |
//依據程序名稱,查找到PID | |
FREObject NativeAneManager::findProcessbyName(FREObject processName) | |
{ | |
const std::wstring& processNameWs = AneDataConvert::ToUTF8_LCPW(processName); | |
int32_t frocessID = NativeProcessManager::getInstance().findProcessbyName(processNameWs); | |
return AneDataConvert::AsUint(frocessID); | |
} | |
//依據PID刪除程序 | |
FREObject NativeAneManager::killProcessbyPid(FREObject pid) | |
{ | |
bool isKill = false; | |
DWORD processID = AneDataConvert::ToUint(pid); | |
if(processID>0) | |
{ | |
NativeProcessManager::getInstance().killProcessbyPid(processID); | |
isKill=true; | |
} | |
return AneDataConvert::AsBool(isKill); | |
} | |
//依據程序名稱刪除程序 | |
FREObject NativeAneManager::killProcessbyName(FREObject processName) | |
{ | |
const std::wstring& processNameWs = AneDataConvert::ToUTF8_LCPW(processName); | |
NativeProcessManager::getInstance().killProcessbyName(processNameWs); | |
return AneDataConvert::AsBool(true); | |
} | |
//執行特定程式或文件 | |
FREObject NativeAneManager::shellExecute(FREObject path,FREObject cmdhwd,FREObject lpOperation,FREObject lpparameters,FREObject lpDir) | |
{ | |
ShellExecute(NULL,AneDataConvert::ToUTF8_LCPW(lpOperation),AneDataConvert::ToUTF8_LCPW(path),AneDataConvert::ToUTF8_LCPW(lpparameters),AneDataConvert::ToUTF8_LCPW(lpDir), AneDataConvert::ToInt(cmdhwd)); | |
return AneDataConvert::AsBool(true); | |
} | |
//模擬鍵盤事件 | |
void NativeAneManager::setKey( BOOL bState,int keyID ) | |
{ | |
BYTE keyState[256]; | |
GetKeyboardState((LPBYTE)&keyState); | |
if( (bState && !(keyState[keyID] & 1)) || (!bState && (keyState[keyID] & 1)) ) | |
{ | |
// Simulate a key press | |
keybd_event( keyID, | |
0x45, | |
KEYEVENTF_EXTENDEDKEY | 0, | |
0 ); | |
// Simulate a key release | |
keybd_event( keyID, | |
0x45, | |
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, | |
0); | |
} | |
} | |
void NativeAneManager::dispatchCreateProcess(const uint8_t* pid) | |
{ | |
AneDataConvert::dispatchEvent(getFreContext(),(const uint8_t*) "progressOnCreate", pid); | |
} | |
void NativeAneManager::dispatchOnExitProcess(const uint8_t* pid) | |
{ | |
AneDataConvert::dispatchEvent(getFreContext(),(const uint8_t*) "progressOnExit", pid); | |
} |
接口調用方式如下:
NativeApp.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if !defined( NATIVEANE_H ) | |
#define NATIVEANE_H | |
#include "ExtensionAneConfig.h" | |
//用 extern "C"將C++指令轉換成C語言 | |
//原因是防止C++名稱重整器造成函數名稱的錯位 | |
//ane methods | |
#define ANE_FUNCTION(f) FREObject (f)(FREContext context, void *data, uint32_t argc, FREObject argv[]) | |
extern "C" | |
{ | |
//initializer / finalizer | |
__declspec(dllexport) void ExtInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet); | |
__declspec(dllexport) void ExtFinalizer(void* extData); | |
//註冊ANE方法 | |
//原生window窗口 | |
ANE_FUNCTION(findWindow); | |
ANE_FUNCTION(closeWindow); | |
ANE_FUNCTION(showWindow); | |
ANE_FUNCTION(showWindowSync); | |
ANE_FUNCTION(setForegroundWindow); | |
ANE_FUNCTION(setWindowFocus); | |
ANE_FUNCTION(setWindowTop); | |
ANE_FUNCTION(getWindowTop); | |
//原生滑鼠事件 | |
ANE_FUNCTION(sendMouseEventPos); | |
ANE_FUNCTION(sendMouseEventClick); | |
ANE_FUNCTION(sendMouseEventDoubleClick); | |
ANE_FUNCTION(sendMouseEventDown); | |
ANE_FUNCTION(sendMouseEventUP); | |
ANE_FUNCTION(sendKeyBoardEvent); | |
//process | |
ANE_FUNCTION(createProcess); | |
ANE_FUNCTION(findProcessbyName); | |
ANE_FUNCTION(killProcessbyPid); | |
ANE_FUNCTION(killProcessbyName); | |
// | |
ANE_FUNCTION(shellExecute); | |
ANE_FUNCTION(dispose); | |
} | |
#endif |
NativeApp.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Theme: NativeWoinowsAne | |
Compiler: Microsoft Visual Studio 2012 Express | |
Date: 2017/11/09 | |
Author: LeesonHsu | |
Email:leesonhsu@arplanet.com.tw | |
Blog: www.arplanet.com.tw | |
*/ | |
#include "ExtensionAneConfig.h" | |
#include "NativeApp.h" | |
#include "AneDataConvert.h" | |
extern "C" | |
{ | |
//ANE註冊方法 | |
FRENamedFunction _Instance_methods[] = { | |
{ (const uint8_t*) "findWindow", 0, findWindow }, | |
{ (const uint8_t*) "closeWindow", 0, closeWindow }, | |
{ (const uint8_t*) "showWindow", 0, showWindow }, | |
{ (const uint8_t*) "showWindowSync", 0, showWindowSync }, | |
{ (const uint8_t*) "setWindowFocus", 0, setWindowFocus }, | |
{ (const uint8_t*) "setForegroundWindow", 0, setForegroundWindow }, | |
{ (const uint8_t*) "setWindowTop", 0, setWindowTop }, | |
{ (const uint8_t*) "getWindowTop", 0, getWindowTop }, | |
{ (const uint8_t*) "sendMouseEventPos", 0, sendMouseEventPos }, | |
{ (const uint8_t*) "sendMouseEventClick", 0, sendMouseEventClick }, | |
{ (const uint8_t*) "sendMouseEventDoubleClick", 0, sendMouseEventDoubleClick }, | |
{ (const uint8_t*) "sendMouseEventDown", 0, sendMouseEventDown }, | |
{ (const uint8_t*) "sendMouseEventUP", 0, sendMouseEventUP }, | |
{ (const uint8_t*) "sendKeyBoardEvent", 0, sendKeyBoardEvent }, | |
{ (const uint8_t*) "createProcess", 0, createProcess }, | |
{ (const uint8_t*) "findProcessbyName", 0, findProcessbyName }, | |
{ (const uint8_t*) "killProcessbyPid", 0, killProcessbyPid }, | |
{ (const uint8_t*) "killProcessbyName", 0, killProcessbyName }, | |
{ (const uint8_t*) "shellExecute", 0, shellExecute }, | |
{ (const uint8_t*) "dispose", 0, dispose } | |
}; | |
//在初始化時宣告可以被AS3調用的方法 | |
void ContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctions, const FRENamedFunction** functions) | |
{ | |
*numFunctions = sizeof( _Instance_methods ) / sizeof( FRENamedFunction ); | |
*functions = _Instance_methods; | |
} | |
void ContextFinalizer(FREContext ctx) | |
{ | |
return; | |
} | |
//ANE初始化 | |
void ExtInitializer(void** extData, FREContextInitializer* ctxInitializer, FREContextFinalizer* ctxFinalizer) | |
{ | |
*ctxInitializer = &ContextInitializer; | |
*ctxFinalizer = &ContextFinalizer; | |
} | |
//ANE離開 | |
void ExtFinalizer(void* extData) | |
{ | |
return; | |
} | |
//找尋視窗 | |
ANE_FUNCTION(findWindow) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().findWindow(argv[0]); | |
} | |
//關閉視窗 | |
ANE_FUNCTION(closeWindow) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().closeWindow(argv[0]); | |
} | |
//顯示視窗 | |
ANE_FUNCTION(showWindow) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().showWindow(argv[0],argv[1]); | |
} | |
//顯示視窗 | |
ANE_FUNCTION(showWindowSync) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().showWindowSync(argv[0],argv[1]); | |
} | |
//強制取得視窗焦點 | |
ANE_FUNCTION(setWindowFocus) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().setWindowFocus(argv[0]); | |
} | |
//強制取得視窗焦點 | |
ANE_FUNCTION(setForegroundWindow) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().setForegroundWindow(argv[0]); | |
} | |
//取得目前最上層視窗 | |
ANE_FUNCTION(getWindowTop) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().getWindowTop(); | |
} | |
//強制置頂 | |
ANE_FUNCTION(setWindowTop) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().setWindowTop(argv[0]); | |
} | |
//強制移動座標 | |
ANE_FUNCTION(sendMouseEventPos) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().sendMouseEventPos(argv[0],argv[1]); | |
} | |
//強制滑鼠點擊 | |
ANE_FUNCTION(sendMouseEventClick) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().sendMouseEventClick(argv[0]); | |
} | |
//強制雙擊滑鼠 | |
ANE_FUNCTION(sendMouseEventDoubleClick) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().sendMouseEventDoubleClick(argv[0]); | |
} | |
//滑鼠MouseEventDown | |
ANE_FUNCTION(sendMouseEventDown) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().sendMouseEventDown(argv[0]); | |
} | |
//滑鼠MouseEventUP | |
ANE_FUNCTION(sendMouseEventUP) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().sendMouseEventUP(argv[0]); | |
} | |
//發出鍵盤事件 | |
ANE_FUNCTION(sendKeyBoardEvent) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().sendKeyBoardEvent(argv[0],argv[1]); | |
} | |
//創建執行序 | |
ANE_FUNCTION(createProcess) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().createProcess(argv[0]); | |
} | |
//依據程序名稱找到PID | |
ANE_FUNCTION(findProcessbyName) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().findProcessbyName(argv[0]); | |
} | |
//依據程序名稱關掉程序 | |
ANE_FUNCTION(killProcessbyPid) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().killProcessbyPid(argv[0]); | |
} | |
//依據程序名稱關掉程序 | |
ANE_FUNCTION(killProcessbyName) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().killProcessbyName(argv[0]); | |
} | |
//執行特定程式或文件 | |
ANE_FUNCTION(shellExecute) | |
{ | |
//getContext | |
NativeAneManager::getInstance().setFreContext(context); | |
return NativeAneManager::getInstance().shellExecute(argv[0],argv[1],argv[2],argv[3],argv[4]); | |
} | |
//資源銷毀釋放 | |
ANE_FUNCTION(dispose) | |
{ | |
return AneDataConvert::AsBool(true); | |
} | |
} | |
張貼留言