You Are Here:

Community: Developer Discussion Boards

#1 Old 能否建立一个服务,模拟按键事件。 - 2004-12-08, 05:35

Join Date: Jul 2004
Posts: 13
zsnakecn
Offline
Registered User
这个服务在后台每隔一定时间模拟一个按键操作,发送一个按键消息。并且这个消息能够被前台程序接收到。
这个能否实现呢
Reply With Quote

#2 Old 2004-12-09, 02:07

Join Date: Sep 2003
Posts: 694
bluerose's Avatar
bluerose
Offline
Super Contributor
你可以用RWsSession::SimulateKeyEvent()试试,不过能不能成功就不知道了。有人反映用这个不能成功,我没有试过,不知道。

Bluerose
Reply With Quote

#3 Old 2004-12-09, 06:04

Join Date: Sep 2003
Posts: 694
bluerose's Avatar
bluerose
Offline
Super Contributor
查了一下SDK,也可以通过向程序发送消息的方式
具体的可以查看Class TApaTask的说明。希望这两种办法有一个可以帮助你。任务列表可以在我前几天发的贴子里有。


Bluerose
Reply With Quote

#4 Old 2004-12-09, 13:14

Join Date: Feb 2004
Posts: 1,928
r60600
Offline
Super Contributor
也就是Sever/Client架构的通信问题。

r60600
Reply With Quote

#5 Old 用fep实现 - 2004-12-15, 10:32

Join Date: Jul 2004
Posts: 13
zsnakecn
Offline
Registered User
我修改nokia提供的fep例程,达到了模拟的效果,在模拟器上通过运行。我用1来模拟右方向。但到我的手机上就不行了。感觉是和我得系统有冲突。我得系统是 中文12版。准备刷一个英文版试用一下
Reply With Quote

#6 Old 2004-12-16, 01:09

Join Date: Sep 2003
Posts: 694
bluerose's Avatar
bluerose
Offline
Super Contributor
做出来共享一下经验,好让后来的人少走一点弯路。


Bluerose
Reply With Quote

#7 Old 我用TApaTaskList 和TApaTask 做了测试 - 2004-12-16, 01:44

Join Date: Jul 2004
Posts: 13
zsnakecn
Offline
Registered User
我用TApaTaskList 和TApaTask 做了测试
在程序中取得系统的 任务列表 ApaTaskList
然后从中取得最前端的 任务,向任务发送按键。

成功。
如何上传附件
Reply With Quote

#8 Old 这是用TApaTaskList 和TApaTask 实现模拟按键事件的代码 - 2004-12-16, 01:48

Join Date: Jul 2004
Posts: 13
zsnakecn
Offline
Registered User
TKeyResponse CTaskManContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
// See if we have a selection
TInt code = aKeyEvent.iCode;
switch(code)
{
// is navigator button pressed
case EKeyRightArrow:
{
RWsSession rwsSession;//创建Window Server session
rwsSession.Connect();//连接window server
TApaTaskList apaTL(rwsSession);//创建 任务列表任务
TApaTask apaT=apaTL.FindByPos(0);//取得foreground任务
if(apaT.Exists())
{
TKeyEvent KeyEvent;
KeyEvent.iCode=EKeyMenu;
apaT.SendKey(KeyEvent);//发送按键
}
rwsSession.Close();
}
return (EKeyWasConsumed);
break;

default:
// Let Listbox take care of its key handling
return (EKeyWasConsumed);
break;
}
}
Reply With Quote

#9 Old 这是通过FEP来实现模拟按键 - 2004-12-16, 01:58

Join Date: Jul 2004
Posts: 13
zsnakecn
Offline
Registered User
TKeyResponse CExampleFepControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode)
{
TInt keyCode = aKeyEvent.iCode;
/////////////Test KeyConvert/////////////////////
if (keyCode=='1')
{
TKeyResponse response=EKeyWasConsumed;
SimulateKeyEventL(EKeyRightArrow);//模拟右方向键
return response;
}
/////////////Test KeyConvert/////////////////////

TKeyResponse response = EKeyWasNotConsumed;

return response;
}
void CExampleFepControl::SimulateKeyEventL(TUint aKeyCode)
{
CArrayFix<TUint>* simCharArray=new(ELeave) CArrayFixFlat<TUint>(1);
CleanupStack::PushL(simCharArray);
simCharArray->AppendL(aKeyCode);
iFep.SimulateKeyEventsL(simCharArray->Array());
CleanupStack::PopAndDestroy(); // simCharArray
}

訽理:系统运行的程序都会在打开的时候去连接当前输入法的dll文件,例如常见的t9fep.fep和chinifep.fep 这些程序都放在 \System\fep目录下,程序运行时所有的按键都先被这个dll 文件截取,因此利用 nokia 提供的fep例程 在其中添加了模拟按键的测试部分,在模拟器上通过,但在手机上没有成功。感觉是和系统本身的输入法有冲突。为此我已綺拔了 n多次电池。wildskinz也用了 FEP实现界面最下方的图片显示。
Reply With Quote

#10 Old Re: 能否建立一个服务,模拟按键事件。 - 2007-09-29, 05:15

Join Date: Sep 2007
Posts: 2
ttaqt
Offline
Registered User
我是新手呀......我想知道上面那段程序要配起来用,是不是还要加什么进去的。我加了几个.h文件,但是还是 说我 没有定义...
代码:
TApaTaskList apaTL(CCoeEnv::Static()->WsSession());
TApaTask apaT = apaTL.FindByPos(0);
TKeyEvent KeyEvent;
KeyEvent.iCode=EKeyMenu;
apaT.SendKey(KeyEvent);

problem:
Severity and Description Path Resource Location Creation Time Id
Undefined symbol: 'class TApaTask TApaTaskList::FindByPos(int) (?FindByPos@TApaTaskList@@QAE?AVTApaTask@@H@Z)'[] YahooImage Unknown 1191035638644 1411
Undefined symbol: 'TApaTaskList::TApaTaskList(class RWsSession &) (??0TApaTaskList@@QAE@AAVRWsSession@@@Z)'[] YahooImage Unknown 1191035638644 1410
Undefined symbol: 'void TApaTask::SendKey(struct TKeyEvent const &) (?SendKey@TApaTask@@QAEXABUTKeyEvent@@@Z)'[] YahooImage Unknown 1191035638644 1412
Reply With Quote

#11 Old Re: 能否建立一个服务,模拟按键事件。 - 2007-09-29, 06:19

Join Date: Jun 2005
Posts: 5,412
Location: Beijing
beover1984's Avatar
beover1984
Offline
Forum Nokia Champion
Quote:
Originally Posted by ttaqt View Post
我是新手呀......我想知道上面那段程序要配起来用,是不是还要加什么进去的。我加了几个.h文件,但是还是 说我 没有定义...
代码:
TApaTaskList apaTL(CCoeEnv::Static()->WsSession());
TApaTask apaT = apaTL.FindByPos(0);
TKeyEvent KeyEvent;
KeyEvent.iCode=EKeyMenu;
apaT.SendKey(KeyEvent);

problem:
Severity and Description Path Resource Location Creation Time Id
Undefined symbol: 'class TApaTask TApaTaskList::FindByPos(int) (?FindByPos@TApaTaskList@@QAE?AVTApaTask@@H@Z)'[] YahooImage Unknown 1191035638644 1411
Undefined symbol: 'TApaTaskList::TApaTaskList(class RWsSession &) (??0TApaTaskList@@QAE@AAVRWsSession@@@Z)'[] YahooImage Unknown 1191035638644 1410
Undefined symbol: 'void TApaTask::SendKey(struct TKeyEvent const &) (?SendKey@TApaTask@@QAEXABUTKeyEvent@@@Z)'[] YahooImage Unknown 1191035638644 1412
使用TApaTaskList需要添加apgrfx.lib.


Beover1984
-----------
Doing what comes naturally
www.devdiv.net
Reply With Quote

#12 Old Re: 这是通过FEP来实现模拟按键 - 2008-11-05, 01:53

Join Date: Sep 2008
Posts: 31
kongfugen
Offline
Registered User
系统运行的程序都会在打开的时候去连接当前输入法的dll文件,例如t9fep.fep和chinifep.fep 这些程序都放在 \System\fep目录下[/quote]

为什么我在我的系统文件下找不到t9fep.fep和chinifep.fep呢??我的是第三版,这是什么原因呢?
Reply With Quote

#13 Old Re: 这是通过FEP来实现模拟按键 - 2008-11-05, 02:48

Join Date: Jul 2007
Posts: 4,240
Location: ShenZhen, China
Send a message via MSN to qxiaoyuan
qxiaoyuan's Avatar
qxiaoyuan
Offline
Forum Nokia Champion
Quote:
Originally Posted by kongfugen View Post
系统运行的程序都会在打开的时候去连接当前输入法的dll文件,例如t9fep.fep和chinifep.fep 这些程序都放在 \System\fep目录下
为什么我在我的系统文件下找不到t9fep.fep和chinifep.fep呢??我的是第三版,这是什么原因呢?[/quote]

3版里所有的exe, dll必须在/sys/bin目录, 否则不能执行, 所以你见不到.


----------------------------
坚持学习, 坚持编码
http://www.devdiv.net/
qxiaoyuan
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2010 Nokia