en Ejemplos, GUI, Harbour, Windows

Abrir Aplicaciones Externas

2015-04-04_182346

 

2015-04-04_182326

2015-04-04_183249

 

/*
 * (c)2015 MigSoft Test Execute Functions
 *
 */

#include 'oohg.ch'

FUNCTION Main()
   Public nHdl := 0

   DEFINE WINDOW Form_1 ;
      AT 0, 0 ;
      WIDTH 600 ;
      HEIGHT 500 ;
      TITLE 'Open Applications by MigSoft' ;
      MAIN

      DEFINE STATUSBAR
         STATUSITEM 'OOHG Power !!!'
      END STATUSBAR

      @ 70, 20 BUTTON Button_1 ;
         WIDTH 180 THEMED ;
         CAPTION 'Google Chrome' ;
         ACTION AbreChrome()

      @ 100, 20 BUTTON Button_2 ;
         WIDTH 180 THEMED ;
         CAPTION 'ShellExecute' ;
         ACTION AbreProg()

      @ 130, 20 BUTTON Button_3 ;
         WIDTH 180 THEMED ;
         CAPTION 'Teclado ON' ;
         ACTION Teclado1(1)

      @ 160, 20 BUTTON Button_4 ;
         WIDTH 180 THEMED ;
         CAPTION 'Teclado OFF' ;
         ACTION Teclado1(0)

      @ 190, 20 BUTTON Button_5 ;
         WIDTH 180 THEMED ;
         CAPTION 'Calculadora ON' ;
         ACTION Calculadora(1)

      @ 220, 20 BUTTON Button_6 ;
         WIDTH 180 THEMED ;
         CAPTION 'Calculadora OFF' ;
         ACTION Calculadora(0)

      @ 250, 20 BUTTON Button_7 ;
         WIDTH 180 THEMED ;
         CAPTION 'Word' ;
         ACTION EnviaFile()

      ON KEY ESCAPE ACTION Form_1.Release()

   END WINDOW

   CENTER WINDOW Form_1
   ACTIVATE WINDOW Form_1

RETURN NIL


Function AbreChrome()

   oShell1 := CreateObject('WScript.Shell')
   oShell1:Exec ('C:\Program Files (x86)\Google\Chrome\' + ;
      'Application\chrome.exe -url http:www.mig2soft.com')

Return Nil

Function AbreProg()

   cFileName := 'C:\Program Files (x86)\Google\' + ;
                'Chrome\Application\chrome.exe'
   cParams   := '-url http:www.mig2soft.com'
   cAction   := 'open'   // 'play' , 'properties', 'PrintTo'
   ShellExecute( 0, cAction, cFileName, cParams, '', 1 )

Return Nil

Function EnviaFile()     // Change path and file
    nRes := ShellExecute( 0, 'open', ;
            'c:\Users\Usuario1\Documents\Balance de situacion.rtf')
    If nRes < 33
       MsgInfo('Error en conexión')
    Endif
Return Nil


#define WM_CLOSE                        0x0010

Function Teclado1( nOp )
   LOCAL cKeyboard := GetEnv( 'windir' ) + '\system32\osk.exe'

   If nOp = 1
      ShellExecute( 0, 'open', cKeyboard, , , 1 )
   Endif

   If nOp = 0
      //SendMessage( GetForegroundWindow(), WM_CLOSE )
      SendMessage( FindWindowEx( Nil,Nil,Nil, ;
            'On-Screen Keyboard' ) , WM_CLOSE )
      SendMessage( FindWindowEx( Nil,Nil,Nil, ;
            'Teclado en Pantalla' ), WM_CLOSE )

   Endif

Return Nil

Function Calculadora( nOp )
   If nOp = 1
      ShellExecute( 0, 'open', 'calc' )
   Endif

   If nOp = 0
      SendMessage( FindWindowEx( Nil,Nil,Nil, ;
                  'Calculator' ), WM_CLOSE )
      SendMessage( FindWindowEx( Nil,Nil,Nil, ;
                 'Calculadora' ), WM_CLOSE )
   Endif

Return Nil