Results 1 to 10 of 10

Thread: keystrokes problem

  1. #1
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default keystrokes problem

    Hi Everybody,

    first at all thanks, this is great place to learn, and share.

    my trouble:

    I have to access(i do not know wich other way explain) to a running application and send some keystroke like "ctrl+p" or similar, or just keys like Key_Up

    i was trying with the windos api function like FindWindow, SendMessage and so on, but i got into conversion errors. and i was trying also with QProcces class but there was not result.

    i have looking for a time into the forum before posting redundant question.

    i hope i make myself clear.

    Thanks in advance

    cafu

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: keystrokes problem

    If you're targetting Windows only then using SendMessage (or PostMessage) is the best way. Qt won't help you with that - it has no facilities to send keystroke events to other processes. You'll have to go through the native API (and native structures, of course - you can't send Qt events using SendMessage).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: keystrokes problem

    Thanks for the answer,

    But the problem is i have not been able to use those function i dont know what i am missing,

    I have include the window.h file and still not working. ..... help please

    cafu

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: keystrokes problem

    please share the source code..this is the 73rd time i've said that in this forum

  5. #5
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: keystrokes problem

    this is how i am trying to find the wiindow and in similar way, ia calling the send message but i really i am not sure about the parameters, and i also was trying SendKeys and it saids that is no defined.( And i am adding windows.h in the header). i really i do not know how to use api windows in qt
    Qt Code:
    1. HWND handel=FindWindow(NULL,"Window Title");
    To copy to clipboard, switch view to plain text mode 

    cannot convert `const char*' to `const WCHAR*' for argument `2' to `HWND__* FindWindowW(const WCHAR*, const WCHAR*)'

  6. #6
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: keystrokes problem

    Hi, I know that is a stupid question but i am really stuck in this point, please help

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: keystrokes problem

    But what is the problem? If you can't get your WinAPI code to work then looking for an answer on a forum dedicated to Qt (where probably more than half of the people there don't use WinAPI) is a much worse solution than looking for the answer on sites dedicated to WinAPI (like MSDN).

    The error message suggests you need to cast a regular C string to a wide char string.
    Try this: http://www.codeguru.com/forum/showthread.php?t=231165
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    cafu1007 (20th May 2009)

  9. #8
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: keystrokes problem

    Ok Sorry for the bother, i thougtht that perhaps was related with QT, and i am not using this cause i want..... i have not fiind another way to control a windows wich i am no creating, is a existeing program and i need to give the order to print and select a configuration on print configuration window.

    And Thank all For the answers
    Last edited by cafu1007; 20th May 2009 at 09:18.

  10. #9
    Join Date
    May 2011
    Posts
    16
    Thanks
    4
    Qt products
    Qt4

    Default Re: keystrokes problem

    This is not a perfect solution but working:
    http://www.qtcentre.org/threads/4185...905#post191905

  11. #10
    Join Date
    Aug 2009
    Posts
    52
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: keystrokes problem

    Quote Originally Posted by cafu1007 View Post
    this is how i am trying to find the wiindow and in similar way, ia calling the send message but i really i am not sure about the parameters, and i also was trying SendKeys and it saids that is no defined.( And i am adding windows.h in the header). i really i do not know how to use api windows in qt
    Qt Code:
    1. HWND handel=FindWindow(NULL,"Window Title");
    To copy to clipboard, switch view to plain text mode 

    cannot convert `const char*' to `const WCHAR*' for argument `2' to `HWND__* FindWindowW(const WCHAR*, const WCHAR*)'
    You'd better write:

    HWND handel=FindWindowA(NULL,"Window Title");

    or

    HWND handel=FindWindowW(NULL, L"Window Title");

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2009, 09:05
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.