Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 107

Hybrid View

  1. #1
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    sir
    i m using Symbian c++ for first time i have to develop an application which can run in background. the application is to send on sms when a long keypressed.
    Is this possible in Symbian c++?

    please help me
    thank you

  2. #2

  3. #3
    Nokia Developer Moderator A.A.M.'s Avatar
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,308
    Also you can check this article - Global Long Key Capture - Capture long presses

  4. #4
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    sir


    please cheack this

    Code:
    // Include Files 
    #ifdef EKA2
    #include <eikstart.h>
    #endif
    
    
    #include "keyPress.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h> // Console
    
    #include <apgwgnam.h> // CApaWindowGroupName
    
    
    // Constants
    // Text strings created by wizard
    _LIT( KTextConsoleTitle, "Console" );
    _LIT( KTextFailed, " failed, leave code = %d" );
    _LIT( KTextPressAnyKey, "\n[press any key to exit]\n" );
    
    // Key to listen to 
    const TUint KKeyCode = EKeyLeftArrow;
    
    // Capture KNumberOfPressesToCapture key presses
    const TInt KNumberOfPressesToCapture = 3;
    
    // Global Variables
    // write all messages to this console
    LOCAL_D CConsoleBase* console; 
    
    
    EXPORT_C CApaApplication* NewApplication()
    {
    return new CkeyPress;
    }
    
    
    
    
    ////////////////////////////////////
    // CGlobalCapturer
    ////////////////////////////////////
    
    // Constructor
    CGlobalCapturer::CGlobalCapturer() :
    CActive( EPriorityNormal )
    {
    // nothing
    }
    
    // Destructor
    CGlobalCapturer::~CGlobalCapturer()
    {
    delete iWindowGroupName;
    delete iWindowGroup;
    iWsSession.Close();
    }
    
    // Cancel listening to key presses
    void CGlobalCapturer::DoCancel()
    {
    iWindowGroup->CancelCaptureLongKey( iCaptureHandle );
    iWindowGroup->CancelCaptureKey( iCaptureHandle );
    }
    
    void CGlobalCapturer::StartCapturingL() 
    {
    // 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 );
    
    // You cannot just call CaptureLongKey for the same key code
    // You MUST call CaptureKey first
    User::LeaveIfError( iCaptureHandle = iWindowGroup->CaptureKey( KKeyCode , 0, 0 ) );
    // And finally capture long key presses
    User::LeaveIfError( iLongCaptureHandle = iWindowGroup->CaptureLongKey( KKeyCode , KKeyCode, 0, 0, 0, 0 ) );
    // Send created window to the background and hide it from the
    // application switcher
    iWindowGroup->SetOrdinalPosition(-1);
    iWindowGroup->EnableReceiptOfFocus( EFalse );
    iWindowGroupName = CApaWindowGroupName::NewL( iWsSession );
    iWindowGroupName->SetHidden(ETrue);
    iWindowGroupName->SetWindowGroupName( *iWindowGroup );
    
    // Tell window server, that we are ready to receive events
    iWsSession.EventReady( &this->iStatus );
    CActiveScheduler::Add( this );
    SetActive();
    }
    
    // Key press happened
    void CGlobalCapturer::RunL()
    {
    if( iStatus == KErrNone ) 
    {
    // EEventKey received
    console->Write( _L( "Captured key press\n" ) );
    TWsEvent we;
    iWsSession.GetEvent( we );
    
    if( we.Key()->iCode == KKeyCode ) 
    {
    if( we.Key()->iRepeats == 0 )
    {
    console->Printf( _L( "Capture %i. Short key press\n" ), ++iCaptureCounter );
    }
    else
    {
    console->Printf( _L( "Capture %i. Long key press\n" ), ++iCaptureCounter );
    }
    }
    else 
    {
    // This should never happen, but just to demonstrate how 
    // it is possible to forward events to the default destination
    TInt foregroundAppId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup( foregroundAppId, we );
    } // if iCode
    if( iCaptureCounter == KNumberOfPressesToCapture ) 
    {
    // exit MainL() inner loop
    CActiveScheduler::Stop();
    }
    else 
    {
    iWsSession.EventReady( &iStatus );
    SetActive();
    } // if captured enough times
    } // if iStatus
    else 
    {
    // Framework notified of some error
    /** @todo Handle error if required */
    }
    }
    
    // Main function. Is TRAPD outside, in Start()
    LOCAL_C void DoStartL()
    {
    // Create active scheduler (to run active objects)
    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    CleanupStack::PushL(scheduler);
    CActiveScheduler::Install(scheduler);
    
    // Call main function with command line
    // Command line is not really needed for this demo, but
    // why not to demonstrate this either?
    /* TBuf<256> cmdLine;
    RProcess().CommandLine( cmdLine );
    MainL( cmdLine );
    */
    // Delete active scheduler
    CleanupStack::PopAndDestroy(scheduler);
    }
    
    // Global Functions
    
    GLDEF_C TInt Start()
    {
    // Create cleanup stack
    __UHEAP_MARK;
    CTrapCleanup* cleanup = CTrapCleanup::New();
    
    // Create output console
    TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
    if (createError)
    return createError;
    
    // Run application code inside TRAP harness, wait keypress when terminated
    TRAPD(mainError, DoStartL());
    if (mainError)
    console->Printf(KTextFailed, mainError);
    console->Printf(KTextPressAnyKey);
    console->Getch();
    
    delete console;
    delete cleanup;
    __UHEAP_MARKEND;
    return KErrNone;
    }
    
    
    // Exported Functions
    
    #ifdef __WINS__
    EXPORT_C TInt WinsMain(TAny* /*aParam*/)
    {
    return Start();
    }
    #else
    GLDEF_C TInt E32Main()
    {
    return Start();
    }
    #endif
    
    #ifndef EKA2
    
    GLDEF_C TInt E32Dll(TDllReason )
    {
    return KErrNone;
    }
    
    #else
    
    GLDEF_C TInt E32Main()
    {
    return EikStart::RunApplication( NewApplication );
    }
    
    #endif
    
    // Local Functions
    LOCAL_C void MainL(const TDesC& /*aArgs*/)
    {
    console->Write( _L( "Starting key capturing\n" ) );
    // Create capturer
    CGlobalCapturer* capturer = new (ELeave) CGlobalCapturer();
    CleanupStack::PushL( capturer );
    // And start capturing
    capturer->StartCapturingL();
    
    // In a real application you should use CActiveSchedulerWait,
    // but in this small demo application we know that there is just
    // a single inner loop and no CActiveSchedulerWait "protection" is
    // needed
    CActiveScheduler::Start();
    // Cleanup. Demo completed
    CleanupStack::PopAndDestroy( capturer );
    }
    
    
    
    
    
    
    // End of file


    I am having an error on this programme. Please retify it an d help me in this critical situation. I have attached the error message below.

    Creation Time Description Resource Path Location Type
    1235440694593 *** missing separator. Stop.[\Symbian\9.2\S60_3rd_FP1_3\EPOC32\BUILD\Symbian\Carbide\workspace3\keyPress\group\KEYPRESS\GCCE\KEYPRESS.GCCE] keyPress line 94 C/C++ Problem

  5. #5
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    sir


    i have one doubt is it possible to import code warrier to carbide c++

  6. #6
    Nokia Developer Champion amitkankani's Avatar
    Join Date
    Oct 2006
    Location
    Bangalore, India
    Posts
    1,572
    if you mean code warrior project to carbide project, why not import the inf file ?
    Amit Kankani
    Nokia Developer Champion

  7. #7
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    sir


    please give me KStandbyScreenAppIdDevice of N80



    thank you

  8. #8
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    Quote Originally Posted by amitkankani View Post
    if you mean code warrior project to carbide project, why not import the inf file ?
    sir
    i have written a program for sending a message when long key pressed. which works on my N95 StandBy Screen App id
    are "const TInt KStandbyScreenAppIdDevice = 0x12;" but is not working my N80 please help me.

  9. #9
    Registered User sumit.rathi's Avatar
    Join Date
    Jun 2008
    Location
    India
    Posts
    1,048
    Quote Originally Posted by arun09 View Post
    sir
    i m using Symbian c++ for first time i have to develop an application which can run in background. the application is to send on sms when a long keypressed.
    Is this possible in Symbian c++?

    please help me
    thank you
    Hi Arun,
    I am Sure it's possible.Try to use RWindowGroup API's function CaptureLongKey .

    Regards,
    Sumit

  10. #10
    Regular Contributor hemrajn's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    55
    Hi arun
    This link will help you to get the solution for captureing the long key
    http://discussion.forum.nokia.com/fo...d.php?t=145116
    Try to create application using active objects.
    Regards,
    Hemraj.

  11. #11
    Regular Contributor neel.soft's Avatar
    Join Date
    Oct 2008
    Posts
    95
    HI,


    FOR CAPTURING A LONG KEY PRESS U NEED TO CAPTURE THAT KEY FIRST AND THEN CAPTURE IT FOR LONG PRESSES.

    1.)// first capture the key

    iWindowGroup->CaptureKey( ); //iWindowGroup : OBJECT OF RWindowGroup class

    2.)
    // And finally capture long key presses
    iWindowGroup->CaptureLongKey( ); //iWindowGroup :OBJECT OF RWindowGroup class

  12. #12
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    Sir
    thank you for your replay. sir i m using Carbide c++ IDE i cannot create .sis file from .pkg file

  13. #13
    Nokia Developer Moderator A.A.M.'s Avatar
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,308
    i m using Carbide c++ IDE i cannot create .sis file from .pkg file
    What errors you are getting?

  14. #14
    Registered User sumit.rathi's Avatar
    Join Date
    Jun 2008
    Location
    India
    Posts
    1,048
    Quote Originally Posted by arun09 View Post
    Sir
    thank you for your replay. sir i m using Carbide c++ IDE i cannot create .sis file from .pkg file
    R u getting any particular message for any particular line in your pkg.

  15. #15
    Regular Contributor arun09's Avatar
    Join Date
    Feb 2009
    Posts
    287
    the error message are:
    Error : Cannot find file : $(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\myproject.exe


    myproject_EKA2.pkg(23) : error: file I/O fault.

Page 1 of 3 123 LastLast

Similar Threads

  1. why program can not run in mobile phone ?
    By luohaibo in forum Symbian Tools & SDKs
    Replies: 9
    Last Post: 2009-03-05, 16:18
  2. Identify program running in background?
    By nire123 in forum Symbian C++
    Replies: 8
    Last Post: 2008-07-13, 07:50
  3. Can not run file manager program
    By agsapt in forum Symbian C++
    Replies: 0
    Last Post: 2002-08-27, 07:37
  4. i cannot run any java program in 9200 SDK
    By chili_fi in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2002-08-12, 23:34
  5. Run HandleSessionEventL() in background
    By chinazou305 in forum Symbian C++
    Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved