In my program I want to be able to use code to run Safari and go to a specific page (e.g. https://world-weather.info/forecast/usa ... arch-2023/) I don't need to read the contents or anything I just want to look at it.
I'm sure I saw this somewhere...
Open web page
Open web page
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Re: Open web page
Code: Select all
RunProgram("open", "https://world-weather.info/forecast/usa/everett/march-2023/", "")
Re: Open web page
Thanks Quin,
Works perfectly! I was playing with RunProgram but couldn't get the right combination.
Works perfectly! I was playing with RunProgram but couldn't get the right combination.
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Re: Open web page
WilliamL wrote: Thu Apr 11, 2024 3:31 am I was playing with RunProgram but couldn't get the right combination.
Code: Select all
#helppath$="/Applications/PureBasic.app/Contents/Resources/help/purebasic/"
Procedure.s sh(search$)
Protected Output$, shell
shell = RunProgram("/bin/sh","","",
#PB_Program_Open|#PB_Program_Write|#PB_Program_Read)
If shell
WriteProgramStringN(shell,search$)
WriteProgramData(shell,#PB_Program_Eof,0)
While ProgramRunning(shell)
If AvailableProgramOutput(shell)
Output$ + ReadProgramString(shell)
EndIf
Wend
CloseProgram(shell)
EndIf
ProcedureReturn Output$
EndProcedure
Procedure pbh(s.s)
s=#helppath$+sh("grep -i '"+s+"' "+#helppath$+~"index.xml | awk -F'\"' '{ print $(NF-1) }' | head -n 1")
if s <> #helppath$
sh( "open -a safari " + URLEncoder(s) )
EndIf
EndProcedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pbh("runprogram") ; PB Help in Safari