this works:
Code: Select all
cAPP := 'c:\Progra~1\Google\Chrome\Application\chrome.exe '
EXECUTE FILE "&cAPP " PARAMETERS 'www.google.com/search?q=what+the'
Moderator: Rathinagiri
Code: Select all
cAPP := 'c:\Progra~1\Google\Chrome\Application\chrome.exe '
EXECUTE FILE "&cAPP " PARAMETERS 'www.google.com/search?q=what+the'
Code: Select all
/*
gsearch.prg
compile : hbmk2 -w3 -es2 gsearch
*/
PROC Main( cSearchFor )
LOCAL nResult := GoogleSearch( hb_DefaultValue( cSearchFor, "Harbour Minigui -facebook" ) )
IF nResult == 0
? "Search string has been sent to your browser!"
ELSE
? "Cannot execute search command! Error code:" + hb_ntos(nResult)
ENDIF
RETURN
FUNCTION GoogleSearch( cSearchFor )
LOCAL cCmd, nResult
IF ! HB_ISSTRING( cSearchFor ) .OR. Empty( cSearchFor )
RETURN -1
ENDIF
cSearchFor := hb_StrReplace( cSearchFor, {'"'=>"", " "=>"+"} )
cCmd := " /Q /C start https://www.google.com/search"+'"?client=gtx&q=' + cSearchFor + '"'
nResult := hb_run( hb_GetEnv( "ComSpec" ) + cCmd )
RETURN nResult
dragancesu wrote: ↑Wed Aug 31, 2022 6:19 am On linux https://www.thegeekstuff.com/2009/08/go ... ne-prompt/
for windows https://stackoverflow.com/questions/147 ... rch-engine
PeteWG wrote: ↑Wed Aug 31, 2022 8:20 am Hello guys,
You might want to try the below code. It's portable and UI independent (can be used on both console and GUI appls).
regards,Code: Select all
/* gsearch.prg compile : hbmk2 -w3 -es2 gsearch */ PROC Main( cSearchFor ) LOCAL nResult := GoogleSearch( hb_DefaultValue( cSearchFor, "Harbour Minigui -facebook" ) ) IF nResult == 0 ? "Search string has been sent to your browser!" ELSE ? "Cannot execute search command! Error code:" + hb_ntos(nResult) ENDIF RETURN FUNCTION GoogleSearch( cSearchFor ) LOCAL cCmd, nResult IF ! HB_ISSTRING( cSearchFor ) .OR. Empty( cSearchFor ) RETURN -1 ENDIF cSearchFor := hb_StrReplace( cSearchFor, {'"'=>"", " "=>"+"} ) cCmd := " /Q /C start https://www.google.com/search"+'"?client=gtx&q=' + cSearchFor + '"' nResult := hb_run( hb_GetEnv( "ComSpec" ) + cCmd ) RETURN nResult
Pete
hansmarc wrote: ↑Wed Aug 31, 2022 10:37 am Hi Pete,
also a nice solution, no temporary html file has to be created but
in your sample a cmd command window appears a fraction of a second before opening the webbrowser.
Suggestion to prevent this with hb_run replace that line with :
ShellExecute(0, "open", "rundll32.exe","url.dll,FileProtocolHandler " + "https://www.google.com/search?q=" + cSearchfor, , 1)
Regards
Hans
serge_girard wrote: ↑Wed Aug 31, 2022 6:29 am HGAut:
this works:
Code: Select all
cAPP := 'c:\Progra~1\Google\Chrome\Application\chrome.exe ' EXECUTE FILE "&cAPP " PARAMETERS 'www.google.com/search?q=what+the'
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