How to execute a google/yahoo/duckduck search from command line, or Harbour?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

HGAutomator
Posts: 197
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by HGAutomator »

No. No. That's one of the things that I'm trying to say, Serge. It really doesn't work.

First,

EXECUTE FILE isn't understood by the compiler. _HB_FUN__EXECUTE is reported as an unresolved external, when the application is compiled as a console app.

In fact, I can't even find EXECUTE FILE defined anywhere. I did a global search through all the .CH files, and it's nowhere in the Minigui distribution.


Second,

Yesterday I was able to include ShellExecute (although I don't recall how). However, when the application is run, the text mode/console menu doesn't display.

Right now, I can't figure out how to include ShellExecute. It's reported as undefined.


At any rate, Pete's solution worked perfectly. It uses standard HB_RUN().

https://drive.google.com/file/d/126Z-Kf ... sp=sharing


serge_girard wrote: Wed Aug 31, 2022 3:26 pm HGAut

What is text-mode app? You mean DOS screen? Then this works:

Code: Select all

FUNCTION Main
REQUEST HB_GT_WIN_DEFAULT
cAPP := 'c:\Progra~1\Google\Chrome\Application\chrome.exe ' 
EXECUTE FILE "&cAPP "  PARAMETERS 'www.google.com/search?q=what+the'   
return
hansmarc
Posts: 40
Joined: Thu Jun 23, 2016 5:38 am
Location: Belgium

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by hansmarc »

Hi hmg'ers,

some information concerning 'Execute File' and 'ShellExecute' for those who are interested.

'Execute file' is translated by \minigui\include\i_exec.ch to 'WaitRunTerm' or '_Execute'.
The source of '_Execute' can be found in \minigui\source\h_winapimisc.prg.
And '_Execute' calls 'ShellExecute' that you can find in \minigui\source\c_winapimisc.c

This function is compiled in \minigui\harbour\lib\hbwin.lib.
If you want to use 'Execute file' or 'ShellExecute' include this lib when you compile your program.

Regards
Hans
HGAutomator
Posts: 197
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by HGAutomator »

I see it, thanks Hans. It's defined as 'EXECUTE' with a 'FILE' parameter.

Unfortunately, I already tried linking in the hbwin library. After that compiles, the application runs but it doesn't display anything.

I'll look closer at it, in the debugger. Maybe there's something else that's happening, prior to displaying the menu.


Thanks and regards,


hansmarc wrote: Wed Aug 31, 2022 6:36 pm Hi hmg'ers,

some information concerning 'Execute File' and 'ShellExecute' for those who are interested.

'Execute file' is translated by \minigui\include\i_exec.ch to 'WaitRunTerm' or '_Execute'.
The source of '_Execute' can be found in \minigui\source\h_winapimisc.prg.
And '_Execute' calls 'ShellExecute' that you can find in \minigui\source\c_winapimisc.c

This function is compiled in \minigui\harbour\lib\hbwin.lib.
If you want to use 'Execute file' or 'ShellExecute' include this lib when you compile your program.

Regards
Hans
User avatar
AUGE_OHR
Posts: 2094
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by AUGE_OHR »

hi,

i´m not a Internet Guru but i "think" you are using "ShellExecuteA()" wrong.

"normal" Files are assassinate with App so it will call EGDE, FireFox or Chrome when got a "http" or "https"
so you need "only" to call URL

---

this is a Sample how to get "Location" of a Adresse using Google Maps

Code: Select all

PROCEDURE ShowMap( cTab )
//  http://maps.google.com/maps?q=Helstorfer%20Str.%207%2030625%20Hannover
LOCAL cURL := "http://maps.google.com/maps?q="

   cURL += STRTRAN( ( TRIM( XPPTEL->STRASSE ) ), " ", "%20" ) + "%20"
   cURL += STRTRAN( ( TRIM( XPPTEL->PLZ ) ), " ", "%20" ) + "%20"
   cURL += STRTRAN( ( TRIM( XPPTEL->STADT ) ), " ", "%20" )

   SHELLOPENFILE( cURL )
RETURN
here my ""ShellExecuteA()" Function using DllCall

Code: Select all

STATIC FUNCTION SHELLOPENFILE( cCmd, cParameter )
LOCAL lSuccess
LOCAL Retvar   := .F.

   IF EMPTY( cCmd )
      RETURN .F.
   ENDIF

   lSuccess := DllCall( "SHELL32.DLL", DLL_STDCALL, ;
                        "ShellExecuteA",;
                         0,;
                         "open",;
                         cCmd, ;
                         cParameter,;
                         CURDIR(),;
                         SW_NORMAL )                    // SW_MAXIMIZE

   DO CASE

      CASE lSuccess > 32                                              // Aufruf erfolgreich
         Retvar := .T.

      CASE lSuccess = SE_ERR_NOASSOC                                  // Keine verknpfte Anwendung

         // Falls ShowOpenWithDialog = True, wird der Dialog
         // "™ffnen mit" fr diese Datei angezeigt:
         // Shell "RunDLL32 shell32.dll,OpenAs_RunDLL " & Filename

         DllCall( "SHELL32.DLL", DLL_STDCALL, ;
                  "OpenAs_RunDLL", 0, NIL, cCmd, ;
                  NIL, CURDIR(), SW_NORMAL )                          // SW_MAXIMIZE

         //  Die Auswahlm”glichkeit wird als Erfolg gewertet:
         Retvar := .T.
      OTHERWISE
         // ShellExecute war erfolglos.
         // Boolean-Standardwert False zurckgeben

         Retvar := .F.
   ENDCASE

RETURN Retvar
have fun
Jimmy
User avatar
serge_girard
Posts: 3312
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by serge_girard »

Jimmy,

Where is DllCall ?
Compile complains....

Serge
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2094
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by AUGE_OHR »

serge_girard wrote: Thu Sep 01, 2022 5:49 am Where is DllCall ?
oh, sorry ... Xbase++ Syntax

use this for HMG

Code: Select all

#xtranslate DllCall => HMG_CallDLL
and DLL_STDCALL -> DLL_OSAPI
have fun
Jimmy
User avatar
serge_girard
Posts: 3312
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by serge_girard »

Thanks, and this "DLL_STDCALL -> DLL_OSAPI"?
Serge
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2094
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by AUGE_OHR »

serge_girard wrote: Thu Sep 01, 2022 6:11 am and this "DLL_STDCALL -> DLL_OSAPI"?
i´m getting old ...

it is from c:\hmg.3.4.4\HARBOUR\contrib\hbxpp\dll.ch to use Xbase++ Code under harbour

Code: Select all

#define DLL_STDCALL                 0x20
#define DLL_SYSTEM                  0x04
#if defined( __PLATFORM__WINDOWS )
#define DLL_OSAPI                   DLL_STDCALL
#elif defined( __PLATFORM__OS2 )
#define DLL_OSAPI                   DLL_SYSTEM
#else
#define DLL_OSAPI                   DLL_CDECL
#endif
have fun
Jimmy
User avatar
serge_girard
Posts: 3312
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by serge_girard »

Great, now it works!

Serge
There's nothing you can do that can't be done...
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: How to execute a google/yahoo/duckduck search from command line, or Harbour?

Post by Claudio Ricardo »

Hello, I just saw this thread and I want to comment that I have been able to pass parameters like this:
Execute File "Update_C.exe" Parameters "t"
To run it from the command line I would write:
Update_C /t
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
Post Reply