Announcement

Collapse
No announcement yet.

shell command

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • shell command

    I want to bring up the windows keyboard with
    HTML Code:
    iRet = SHELL("C:\Windows\system32\osk.exe",1)
    It returns "File not found" but the file is there and I can start it by double clicking it from windows, system32 folder.
    Any ideas?

  • #2
    Should work

    iRet has to be defined as DOUBLE

    Are you sure you got the program name correct?- use right click/rename/copy and paste to be sure

    I sometimes change the slash to the forward facing slash?!?!?
    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
    Kerry Farmer

    Comment


    • #3
      I had iRet defined as LONG so I redefined it as DOUBLE but still, file not found.

      Comment


      • #4
        I copied and pasted the file address from the file location... It is correct.

        Comment


        • #5
          Hi Mike, it worked as it should when I tried. with my PB 10.04
          I used :

          Code:
          #COMPILE EXE
          #DIM ALL
          
          FUNCTION PBMAIN () AS LONG
             LOCAL iRet AS DWORD
             iRet = SHELL("C:\Windows\system32\osk.exe",1)
          END FUNCTION

          Comment


          • #6
            I ran your code snipit and although it didn't give the error, It never started the program either. My callback is error trapped. So maybe it has something to do with windows 10 updates.

            Comment


            • #7
              When I step through this program by Mikael T in the debugger,
              HTML Code:
                #COMPILE EXE #DIM ALL  FUNCTION PBMAIN () AS LONG    LOCAL iRet AS DWORD    iRet = SHELL("C:\Windows\system32\osk.exe",1) END FUNCTION
              I do get the error # 53 "file not found" ... but it is there and if you click on it at that location, it fires up.
              Any Ideas?

              Comment


              • #8
                Mike
                This has come up before.
                Search for OSK redirection wow64
                Rgds, Dave

                Comment


                • #9
                  It's normal behaviour under Windows 10, you got to disable redirection.

                  Code:
                  #COMPILE EXE
                  #DIM ALL
                  #INCLUDE "Win32Api.inc"
                  '______________________________________________________________________________
                  
                  FUNCTION PBMAIN() AS LONG
                   LOCAL ShellInfo        AS SHELLEXECUTEINFO
                   LOCAL zSystemDirecrory AS ASCIIZ * %MAX_PATH
                   LOCAL zProgramFile     AS ASCIIZ * %MAX_PATH
                   LOCAL Wow64Value       AS DWORD
                  
                   Wow64DisableWow64FsRedirection(Wow64Value)
                   GetSystemDirectory(zSystemDirecrory, SIZEOF(zSystemDirecrory)) 'Usually C:\WINDOWS\SysWOW64
                   zProgramFile           = zSystemDirecrory & "\osk.exe"
                   ShellInfo.cbSize       = SIZEOF(SHELLEXECUTEINFO)
                   ShellInfo.fMask        = %SEE_MASK_FLAG_NO_UI OR %SEE_MASK_NOCLOSEPROCESS
                   ShellInfo.lpFile       = VARPTR(zProgramFile)
                   ShellInfo.lpParameters = 0
                   ShellInfo.nShow        = %SW_SHOWNORMAL
                   ShellExecuteEx(ShellInfo)
                   Wow64RevertWow64FsRedirection(Wow64Value)
                  
                  END FUNCTION
                  '_____________________________________________________________________________
                  '

                  Comment


                  • #10
                    I will try this in the morning. it is 12:14 am and I must be up at 5am. Thank you so much guys.

                    Comment


                    • #11
                      I set zSystemDirecrory = "C:\Windows\system32" and tried the Pierre Bellisle example, but still I get "The system cannot find the file specified" . But it is there.
                      I think I will give up and just Pin the .exe to the task bar and startup. It must be something to do with WINDOWS 10. Really, I can't figure why
                      iRet = SHELL("C:\Windows\system32\osk.exe",1) works on some systems but not on mine. Makes me worry about older programs that I have used Shell statement on before. Are all of those going to stop working as well? Oh the Joy!

                      Comment


                      • #12
                        Hi Mike,

                        Try this Shell "C:\WINDOWS\SysWOW64\osk.exe"

                        Also read this thread for other options.
                        Last edited by Dave Biggs; 4 Dec 2018, 07:14 AM. Reason: Add link
                        Rgds, Dave

                        Comment


                        • #13
                          This kind of problem sounded familiar from a few months ago. Could not remember last night. The answer is $DQs.
                          Code:
                          #compile exe
                          #dim all
                          
                          function pbmain () as long
                            local iRet as dword
                            iRet = shell($dq + "C:\Windows\System32\osk.exe" + $dq, 1)
                            ? str$(iRet)
                            ? str$(err)
                           ' waitkey$ '<<== in PBCC uncomment waitkey
                          end function
                          Cheers,
                          Dale

                          Comment


                          • #14
                            In either PBWin or PBCC to programatically close the on screen keyboard you'll have to use it's PID (in iRet in demo code) with API which I also can not remember at this time.

                            In PBWin set focus to control you want to receive characters from OSK.

                            In PCCC you'll have to test waitkey$ (or other) returned character in loop to detect which character (like ESC maybe) means exit program.

                            Cheers,
                            Dale

                            Comment


                            • #15
                              Tried all versions above and still err = 53 file not found... It is clearly there where it is supposed to be, I can see it, I can click it to run it. But the shell and redirects just return err = 53 file not found. I don't know.
                              Dale, iRet = 0, Err = 53 file not found
                              I included a screen shot, which is attached, from explorer so all of you can see I am not as crazy as I sound.
                              Attached Files

                              Comment


                              • #16
                                Another strange thing. While I was having the OSK not opening problem I was getting ERR = 75, not 53.
                                Dale

                                Comment


                                • #17
                                  I googled "can't shell osk" and FWIW it looks like VB and Access have the same problem. The workaround in both cases is to use ShellExecute instead of SHELL.
                                  "Not my circus, not my monkeys."

                                  Comment


                                  • #18
                                    Mike, if you run this code as is, what error do you get?

                                    Code:
                                    #COMPILE EXE
                                    #DIM ALL
                                    #INCLUDE "Win32Api.inc"
                                    '______________________________________________________________________________
                                    
                                    FUNCTION WinError$(BYVAL ErrorCode AS DWORD, ID AS LONG) AS STRING
                                     LOCAL pzError  AS ASCIIZ POINTER 'Max is 64K
                                     LOCAL ErrorLen AS DWORD
                                    
                                     ErrorLen = FormatMessage(%FORMAT_MESSAGE_FROM_SYSTEM OR %FORMAT_MESSAGE_ALLOCATE_BUFFER, _
                                                              BYVAL %NULL, ErrorCode, %NULL, BYVAL VARPTR(pzError), %NULL, BYVAL %NULL)
                                     IF ErrorLen THEN
                                        MessageBox(%HWND_DESKTOP, "Error" & STR$(ErrorCode) & _
                                                   " (0x" & HEX$(ErrorCode) & ") : " & @pzError, _
                                                   "OSK" & STR$(ID), %MB_OK OR %MB_TOPMOST)
                                       LocalFree(pzError)
                                     ELSE
                                       MessageBox(%HWND_DESKTOP, "Unknown error" & STR$(ErrorCode) & _
                                                  " (0x" & HEX$(ErrorCode) & ")", "OSK" & STR$(ID), %MB_OK OR %MB_TOPMOST)
                                     END IF
                                    
                                    END FUNCTION
                                    '______________________________________________________________________________
                                    
                                    FUNCTION FileSize(zProgramFile AS ASCIIZ) AS QUAD
                                     LOCAL qFileSize AS QUAD
                                     LOCAL hFile     AS DWORD
                                    
                                     hFile = CreateFile(zProgramFile, %GENERIC_READ, 0, BYVAL %NULL, _
                                                        %OPEN_EXISTING, %FILE_ATTRIBUTE_NORMAL, BYVAL %NULL)
                                     IF hFile <> %INVALID_HANDLE_VALUE THEN
                                       GetFileSizeEx(hFile, qFileSize)
                                       CloseHandle(hFile)
                                     END IF
                                     FUNCTION = qFileSize
                                    
                                    END FUNCTION
                                    '______________________________________________________________________________
                                    
                                    FUNCTION PBMAIN() AS LONG
                                     LOCAL ShellInfo        AS SHELLEXECUTEINFO
                                     LOCAL zSystemDirecrory AS ASCIIZ * %MAX_PATH
                                     LOCAL zProgramFile     AS ASCIIZ * %MAX_PATH
                                     LOCAL Wow64Value       AS DWORD
                                     LOCAL LastError        AS LONG
                                    
                                     'Wow64DisableWow64FsRedirection is useful for 32-bit applications
                                     'that want to gain access to the native system32 directory.
                                     'By default, WOW64 file system redirection is enabled.
                                     Wow64DisableWow64FsRedirection(Wow64Value)
                                     LastError = GetLastError() : IF LastError THEN WinError$(LastError, 1)
                                    
                                     GetSystemDirectory(zSystemDirecrory, SIZEOF(zSystemDirecrory)) 'Usually C:\Windows\System32\
                                     LastError = GetLastError() : IF LastError THEN WinError$(LastError, 2)
                                    
                                     zProgramFile = zSystemDirecrory & "\osk.exe"
                                     MessageBox(%HWND_DESKTOP, zProgramFile & $CRLF & _
                                                               "Size is " & FORMAT$(FileSize(zProgramFile)) & $CRLF & _
                                                               "Attribute is " & HEX$(GetFileAttributes(zProgramFile))& $CRLF & $CRLF & _
                                                               "Now let's run ShellExecuteEx..." & $CRLF, _
                                                               "OSK 3", %MB_OK OR %MB_TOPMOST)
                                    
                                     ShellInfo.cbSize       = SIZEOF(SHELLEXECUTEINFO)
                                     ShellInfo.fMask        = %SEE_MASK_FLAG_NO_UI OR %SEE_MASK_NOCLOSEPROCESS
                                     ShellInfo.lpFile       = VARPTR(zProgramFile)
                                     ShellInfo.lpDirectory  = VARPTR(zSystemDirecrory)
                                     ShellInfo.nShow        = %SW_SHOWNORMAL
                                     ShellInfo.hInstApp     = 0
                                     ShellExecuteEx(ShellInfo)
                                     LastError = GetLastError() : IF LastError THEN WinError$(LastError, 5)
                                     IF ShellInfo.hInstApp <= 32 THEN
                                       MessageBox(%HWND_DESKTOP, "ShellExecuteEx error" & STR$(ShellInfo.hInstApp) & $CRLF, _
                                                                 "OSK 4", %MB_OK OR %MB_TOPMOST)
                                     END IF
                                    
                                     Wow64RevertWow64FsRedirection(Wow64Value)
                                     LastError = GetLastError() : IF LastError THEN WinError$(LastError, 6)
                                    
                                    END FUNCTION
                                    '_____________________________________________________________________________
                                    '

                                    Comment


                                    • #19
                                      This only works in PBEDIT. Won't work when run from disk. Edit 4:12PM CST and reposted fix in thread #24
                                      Use ShellExecute with Wow64DisableWow64FsRedirection(Wow64Value) 'required

                                      Code:
                                      'works here with 64-Bit Windows  --  Thanks Pierre B.
                                      #INCLUDE "win32api.inc"
                                      FUNCTION PBMAIN AS LONG
                                       LOCAL Wow64Value AS DWORD
                                       Wow64DisableWow64FsRedirection(Wow64Value)  'required
                                       SHELL "c:\windows\system32\osk.exe"
                                      
                                       'This requires --> Wow64DisableWow64FsRedirection(Wow64Value)
                                       LOCAL iRet AS DWORD
                                       iRet = SHELL($DQ + "C:\Windows\System32\osk.exe" + $DQ, 1) 'fails without Wow64 code above
                                      
                                      END FUNCTION
                                      Last edited by Mike Doty; 4 Dec 2018, 05:13 PM.
                                      https://www.tesla.com/roadster

                                      Comment


                                      • #20
                                        Hum, does that osk work with touch screens?
                                        p purvis

                                        Comment

                                        Working...
                                        X