Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QProcess trying to open my On-Screen Keyboard (osk.exe)
Forum Updated to NodeBB v4.3 + New Features

Problem with QProcess trying to open my On-Screen Keyboard (osk.exe)

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 5 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @JonexElectronic Does it start if you execute C:/Windows/System32/osk.exe in a terminal?
    If osk.exe prints out errors to stdout/stderr you should also read and print those after you got the error (https://doc.qt.io/qt-6/qprocess.html#readAllStandardError and https://doc.qt.io/qt-6/qprocess.html#readAllStandardOutput). Maybe it will give you more information about the reason for osk.exe not starting.

    J Offline
    J Offline
    JonexElectronic
    wrote on last edited by
    #5

    @jsulm said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

    C:/Windows/System32/osk.exe

    Yes, It is
    d44d6858-7124-4e39-bdf0-aa2dc7a2d3a1-image.png
    I did what you said

    void ProcessController::errorProcess(QProcess::ProcessError error)
    {
        if (error == QProcess::FailedToStart)
        {
            QByteArray errorOutput = process ->readAllStandardError();
            qDebug() << "Error:" << errorOutput;
            QByteArray standarOutput = process ->readAllStandardOutput();
            qDebug() << "Standard:" << standarOutput;
        }
    }
    

    And nothing ..

    Error: ""
    Standard: ""
    
    JonBJ jsulmJ 2 Replies Last reply
    0
    • J JonexElectronic

      @jsulm said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

      C:/Windows/System32/osk.exe

      Yes, It is
      d44d6858-7124-4e39-bdf0-aa2dc7a2d3a1-image.png
      I did what you said

      void ProcessController::errorProcess(QProcess::ProcessError error)
      {
          if (error == QProcess::FailedToStart)
          {
              QByteArray errorOutput = process ->readAllStandardError();
              qDebug() << "Error:" << errorOutput;
              QByteArray standarOutput = process ->readAllStandardOutput();
              qDebug() << "Standard:" << standarOutput;
          }
      }
      

      And nothing ..

      Error: ""
      Standard: ""
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #6

      @JonexElectronic
      This may not be relevant, but are you building a 32- or 64-bit executable?

      J 1 Reply Last reply
      0
      • JonBJ JonB

        @JonexElectronic
        This may not be relevant, but are you building a 32- or 64-bit executable?

        J Offline
        J Offline
        JonexElectronic
        wrote on last edited by JonexElectronic
        #7

        @JonB I am building a 32 bit executable on a 64 bit windows. I said in my first message Qt 5.15.2 compiled with mingw81_32. It must be relevant because If I start a new qt Pro but compiled to 64 bit at least startdetached works but start and execute dont. But any of those methods works in 32 bits

        JonBJ 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #8

          Then maybe a 32 bit app can't start a 64 bit executable with QProcess - try to start other executables - 32 and 64 bit ones to see if this assumption is correct.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          J 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Then maybe a 32 bit app can't start a 64 bit executable with QProcess - try to start other executables - 32 and 64 bit ones to see if this assumption is correct.

            J Offline
            J Offline
            JonexElectronic
            wrote on last edited by
            #9

            @Christian-Ehrlicher so there is no possible solution??

            JonBJ 1 Reply Last reply
            0
            • J JonexElectronic

              @JonB I am building a 32 bit executable on a 64 bit windows. I said in my first message Qt 5.15.2 compiled with mingw81_32. It must be relevant because If I start a new qt Pro but compiled to 64 bit at least startdetached works but start and execute dont. But any of those methods works in 32 bits

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #10

              @JonexElectronic
              @Christian-Ehrlicher has posted the sort of thing I was thinking of. I'm not an expert, but issues with 32- vs 64-bit stuff under Windows. Also I *wonder& whether system32 is an issue here....

              • Start with a QFileInfo::exists() on "C:/Windows/System32/osk.exe" from within the Qt application, what does it say?

              • Try something else there similar, like Notepad.exe, I think that's in system32 too? Does that work?

              start()/execute() require, I think, that it can get something to wait on. I'm not sure whether that works between 32- to 64-bit, might be an issue. startDetached() might be a better choice here/for external GUI programs.

              J 1 Reply Last reply
              0
              • J JonexElectronic

                @Christian-Ehrlicher so there is no possible solution??

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #11

                @JonexElectronic said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                @Christian-Ehrlicher so there is no possible solution??

                Start by doing some more investigations of your own per my previous post before you know where you are going....

                Also one thing to try maybe is

                process->start("cmd.exe", QStringList() << "/c" << "C:\\Windows\\System32\\osk.exe");
                
                1 Reply Last reply
                0
                • J JonexElectronic

                  @jsulm said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                  C:/Windows/System32/osk.exe

                  Yes, It is
                  d44d6858-7124-4e39-bdf0-aa2dc7a2d3a1-image.png
                  I did what you said

                  void ProcessController::errorProcess(QProcess::ProcessError error)
                  {
                      if (error == QProcess::FailedToStart)
                      {
                          QByteArray errorOutput = process ->readAllStandardError();
                          qDebug() << "Error:" << errorOutput;
                          QByteArray standarOutput = process ->readAllStandardOutput();
                          qDebug() << "Standard:" << standarOutput;
                      }
                  }
                  

                  And nothing ..

                  Error: ""
                  Standard: ""
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @JonexElectronic The only idea I have now is to check Windows logs (you can do that using mmc tool) - maybe there are some hints.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • JonBJ JonB

                    @JonexElectronic
                    @Christian-Ehrlicher has posted the sort of thing I was thinking of. I'm not an expert, but issues with 32- vs 64-bit stuff under Windows. Also I *wonder& whether system32 is an issue here....

                    • Start with a QFileInfo::exists() on "C:/Windows/System32/osk.exe" from within the Qt application, what does it say?

                    • Try something else there similar, like Notepad.exe, I think that's in system32 too? Does that work?

                    start()/execute() require, I think, that it can get something to wait on. I'm not sure whether that works between 32- to 64-bit, might be an issue. startDetached() might be a better choice here/for external GUI programs.

                    J Offline
                    J Offline
                    JonexElectronic
                    wrote on last edited by JonexElectronic
                    #13

                    @JonB said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                    Start with a QFileInfo::exists() on "C:/Windows/System32/osk.exe" from within the Qt application, what does it say?

                    qDebug() << "Exist osk?" <<QFileInfo::exists("C:/Windows/System32/osk.exe");
                    

                    It sais false, ¿Why? I check it, and it exist
                    I tried

                    QDir directory("C:/Windows/System32");
                    QFileInfoList info =directory.entryInfoList();
                    

                    it gives me
                    3a31e48f-990e-4f11-8475-dc064c3ba29a-image.png
                    but I have
                    c68ef905-fdc5-4e44-89e1-b44dcd99f2db-image.png
                    any idea why qt omit some files? I didnt find osk.exe on my QFileInfoList info;
                    but yes I found notepad.exe

                    J JonBJ 2 Replies Last reply
                    0
                    • J JonexElectronic

                      @JonB said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                      Start with a QFileInfo::exists() on "C:/Windows/System32/osk.exe" from within the Qt application, what does it say?

                      qDebug() << "Exist osk?" <<QFileInfo::exists("C:/Windows/System32/osk.exe");
                      

                      It sais false, ¿Why? I check it, and it exist
                      I tried

                      QDir directory("C:/Windows/System32");
                      QFileInfoList info =directory.entryInfoList();
                      

                      it gives me
                      3a31e48f-990e-4f11-8475-dc064c3ba29a-image.png
                      but I have
                      c68ef905-fdc5-4e44-89e1-b44dcd99f2db-image.png
                      any idea why qt omit some files? I didnt find osk.exe on my QFileInfoList info;
                      but yes I found notepad.exe

                      J Offline
                      J Offline
                      JonexElectronic
                      wrote on last edited by
                      #14

                      I found anothe osk.exe on my pc that is in

                      C:\Windows\WinSxS\amd64_microsoft-windows-osk_31bf3856ad364e35_10.0.19041.1_none_60ade0eff94c37fc/osk.exe
                      

                      and it works with QProcess::startDetached on my 32 bits app but not with process->start... I need to know when this app is close. Maybe I can use the pid returned on startdetached and set a timer to ask every second, but this method dont looks good...
                      any to detect when this app is closed?

                      1 Reply Last reply
                      0
                      • J JonexElectronic

                        @JonB said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                        Start with a QFileInfo::exists() on "C:/Windows/System32/osk.exe" from within the Qt application, what does it say?

                        qDebug() << "Exist osk?" <<QFileInfo::exists("C:/Windows/System32/osk.exe");
                        

                        It sais false, ¿Why? I check it, and it exist
                        I tried

                        QDir directory("C:/Windows/System32");
                        QFileInfoList info =directory.entryInfoList();
                        

                        it gives me
                        3a31e48f-990e-4f11-8475-dc064c3ba29a-image.png
                        but I have
                        c68ef905-fdc5-4e44-89e1-b44dcd99f2db-image.png
                        any idea why qt omit some files? I didnt find osk.exe on my QFileInfoList info;
                        but yes I found notepad.exe

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #15

                        @JonexElectronic said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                        It sais false, ¿Why? I check it, and it exist

                        This is what I suspected might be the case. Basically because your Qt application is 32-bit. Then C:\Windows\System32 does not contain what you think it contains when you look from a 64-bit application.

                        I believe this is the root of your problem.

                        In a word, if you made your Qt application be 64- instead of 32-bit I think all would be well. Have you considered doing this? 32-bit programs are going out of fashion now....

                        J 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @JonexElectronic said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                          It sais false, ¿Why? I check it, and it exist

                          This is what I suspected might be the case. Basically because your Qt application is 32-bit. Then C:\Windows\System32 does not contain what you think it contains when you look from a 64-bit application.

                          I believe this is the root of your problem.

                          In a word, if you made your Qt application be 64- instead of 32-bit I think all would be well. Have you considered doing this? 32-bit programs are going out of fashion now....

                          J Offline
                          J Offline
                          JonexElectronic
                          wrote on last edited by JonexElectronic
                          #16

                          @JonB Yes, I have considered moving to 64-bit. But I also use other 32-bit libraries in my program and transitioning everything to 64-bit is too much work at the moment. Anyway, I've tried starting osk.exe with the start method in a new Qt project, but it doesn't work. It only works with startDetached.

                          QProcess *process;
                          .....
                          process=new QProcess();
                          process->start("C:/Windows/System32/osk.exe",QStringList());
                          
                          JonBJ 1 Reply Last reply
                          0
                          • J JonexElectronic

                            @JonB Yes, I have considered moving to 64-bit. But I also use other 32-bit libraries in my program and transitioning everything to 64-bit is too much work at the moment. Anyway, I've tried starting osk.exe with the start method in a new Qt project, but it doesn't work. It only works with startDetached.

                            QProcess *process;
                            .....
                            process=new QProcess();
                            process->start("C:/Windows/System32/osk.exe",QStringList());
                            
                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #17

                            @JonexElectronic said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                            It only works with startDetached.

                            That does not particularly surprise me. Again I suspect this is an issue about running a 64-bit application from a 32-bit one. And so long as QFileInfo::exists("C:/Windows/System32/osk.exe") returns false from your 32-bit app I don't know what you expect to work.

                            Do you really care about start() instead of startDetached() anyway?

                            J 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @JonexElectronic said in Problem with QProcess trying to open my On-Screen Keyboard (osk.exe):

                              It only works with startDetached.

                              That does not particularly surprise me. Again I suspect this is an issue about running a 64-bit application from a 32-bit one. And so long as QFileInfo::exists("C:/Windows/System32/osk.exe") returns false from your 32-bit app I don't know what you expect to work.

                              Do you really care about start() instead of startDetached() anyway?

                              J Offline
                              J Offline
                              JonexElectronic
                              wrote on last edited by JonexElectronic
                              #18

                              @JonB Sorry I forgot to say that it happens in a new 64-bit app not in my 32-bit app.
                              And

                              QFileInfo::exists("C:/Windows/System32/osk.exe")
                              

                              returns true

                              And yes I really care about start because I need to know when this process has finished

                              Cobra91151C 1 Reply Last reply
                              0
                              • J JonexElectronic

                                @JonB Sorry I forgot to say that it happens in a new 64-bit app not in my 32-bit app.
                                And

                                QFileInfo::exists("C:/Windows/System32/osk.exe")
                                

                                returns true

                                And yes I really care about start because I need to know when this process has finished

                                Cobra91151C Offline
                                Cobra91151C Offline
                                Cobra91151
                                wrote on last edited by
                                #19

                                @JonexElectronic

                                Hello!

                                As an option, you can try to disable the Wow64EnableWow64FsRedirection function from WinAPI (https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-wow64enablewow64fsredirection), run your C:/Windows/System32/osk.exe process and re-enable it again.
                                Description: This function is useful for 32-bit applications that want to gain access to the native system32 directory. By default, WOW64 file system redirection is enabled.
                                It could work in your case.

                                1 Reply Last reply
                                1

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved