📄 mguardkeycapture.cpp,v
字号:
head 1.1;access;symbols v1_0:1.1.1.2 xueyw:1.1.1 v111:1.1.1.1 MGuard:1.1.1;locks; strict;comment @// @;1.1date 2007.08.22.11.22.04; author administrator; state Exp;branches 1.1.1.1;next ;deltatype text;permissions 644;commitid aac46cc1c5b385b;kopt kv;filename @MGuardKeyCapture.cpp@;1.1.1.1date 2007.08.22.11.31.31; author administrator; state Exp;branches;next 1.1.1.2;deltatype text;permissions 644;commitid 81046cc1e913f93;kopt kv;filename @MGuardKeyCapture.cpp@;1.1.1.2date 2007.10.05.14.06.53; author administrator; state Exp;branches;next ;deltatype text;permissions 644;commitid 894470644fb2457;kopt kv;filename @MGuardKeyCapture.cpp@;desc@@1.1log@sc take care of the lock/unlock of the screen@text@/** ============================================================================* Name : MGuardKeyCapture.cpp* Part of : MGuard* Created : July 21 by xueyw* Description:* Copyright: * ============================================================================*/// Include Files #include "MGuardKeyCapture.h"#include <e32base.h>#include <e32std.h>#include <apgwgnam.h> // CApaWindowGroupName#include <aknkeylock.h> #include <apacmdln.h>#include <eikdll.h>// Capture KNumberOfPressesToCapture key pressesconst TInt KNumberOfPressesToCapture = 3;////////////////////////////////////// CGuardKeyCapturer////////////////////////////////////// Constructor// CGuardKeyCapturer CGuardKeyCapturer::iKeyCapture;CGuardKeyCapturer::CGuardKeyCapturer() :CActive( EPriorityNormal ){ iCaptureStarted = EFalse; iCapturePending = EFalse; iCaptureHandleCount = 0; // Connect to the window server User::LeaveIfError( iWsSession.Connect() ); // Create an invisible window group. Well, we'll make it invisible later /** @@todo Can ELeave be used with R-classes? */ iWindowGroup = new (ELeave) RWindowGroup ( iWsSession ); // @@see RBlankWindow::Construct iWindowGroup->Construct( (TUint32)iWindowGroup, EFalse );}// DestructorCGuardKeyCapturer::~CGuardKeyCapturer(){ delete iWindowGroupName; delete iWindowGroup; iWsSession.Close();}// Cancel listening to key pressesvoid CGuardKeyCapturer::DoCancel(){ for ( TInt aIndex = 0; aIndex < iCaptureHandleCount; aIndex ++ ) { iWindowGroup->CancelCaptureKey( iCaptureHandle[ aIndex ] ); } RAknKeyLock keyLock; // first step // Lock keyboard User::LeaveIfError(keyLock.Connect()); // second step CleanupClosePushL(keyLock); keyLock.DisableKeyLock(); // third step keyLock.Close(); // fourth step CleanupStack::PopAndDestroy(); // keyLock}void CGuardKeyCapturer::StopCapturingL(){ for ( TInt aIndex = 0; aIndex < iCaptureHandleCount; aIndex ++ ) { iWindowGroup->CancelCaptureKey( iCaptureHandle[ aIndex ] ); } RAknKeyLock keyLock; // first step // Lock keyboard User::LeaveIfError(keyLock.Connect()); // second step CleanupClosePushL(keyLock); keyLock.DisableKeyLock(); // third step keyLock.Close(); // fourth step CleanupStack::PopAndDestroy(); // keyLock iCaptureHandleCount = 0; iCapturePending = ETrue;}void CGuardKeyCapturer::ResumeCapturingL(){ iCaptureHandleCount = 0; User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyLeftArrow , 0, 0 ) ); iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyRightArrow , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyUpArrow , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyDownArrow , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyApplication0, 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyYes , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyNo , 0, 0 ) ); //////iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyNull , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBell , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBackspace , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyTab , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyLineFeed , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyVerticalTab , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyFormFeed , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyEnter , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyEscape , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeySpace , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyBackspace , 0, 0 ) ); //iCaptureHandleCount ++; //User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyDelete , 0, 0 ) ); //iCaptureHandleCount ++; // //for ( TInt aCode = EKeyPrintScreen; aCode < EKeyDecBrightness; aCode ++ ) //{ // User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( aCode , 0, 0 ) ); // iCaptureHandleCount ++; //} iCapturePending = EFalse; RAknKeyLock keyLock; // first step // Start phone app _LIT(KPhoneAppPath, "\\system\\apps\\phone\\phone.app"); { // Open with the default/last known app CApaCommandLine * cmd = CApaCommandLine::NewL(); cmd->SetLibraryNameL( KPhoneAppPath ); cmd->SetCommandL( EApaCommandOpen ); EikDll::StartAppL( *cmd ); delete cmd; } // Lock keyboard User::LeaveIfError(keyLock.Connect()); // second step CleanupClosePushL(keyLock); keyLock.EnableKeyLock(); // third step keyLock.Close(); // fourth step CleanupStack::PopAndDestroy(); // keyLock }void CGuardKeyCapturer::StartCapturingL() { // You cannot just call CaptureLongKey for the same key code // You MUST call CaptureKey first iCaptureHandleCount = 0; User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyLeftArrow , 0, 0 ) ); iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyRightArrow , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyUpArrow , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyDownArrow , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyApplication0 , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyYes , 0, 0 ) ); //////iCaptureHandleCount ++; //////User::LeaveIfError( iCaptureHandle[iCaptureHandleCount] = iWindowGroup->CaptureKey( EKeyNo , 0, 0 ) ); //////iCaptureHandleCount ++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -