How to embed web-page into my ahk-scripts?
I just need to view some web-page inside my GUI.
Where I can find examples?
Embed web page in ahk's GUI
Embed web page in ahk's GUI
Focusing our efforts on non-productive and non-creative endeavours wastes lives as surely as war.
Jacque Fresco / The best that money can't buy
Jacque Fresco / The best that money can't buy
Re: Embed web page in ahk's GUI
an example
Code: Select all
;EDIT : modified 20180405 , user tank >> "wb.silent := true"
;-------- saved at Mittwoch, 18. Februar 2015 19:45:55 XP netbook
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=6445 -----------
;-- a browser from user 'Soft' and 'Lexikos'
;===========================================================================
f1=https://autohotkey.com/boards/
filename1=Browser SOFT
Gui,2: Add, Edit, w930 r1 vURL,%f1%
Gui,2: Add, Button, x5 y25 gBrB, <
Gui,2: Add, Button, x+1 y25 gBrF, >
Gui,2: Add, Button, x+6 yp w44 Default gA1, Go
;Gui,2: Add, ActiveX, xm w980 h640 vWB, Shell.Explorer
Gui,2: Add, ActiveX, xm w1080 h720 vWB, Mozilla.Browser
wb.silent := true
ComObjConnect(WB, WB_events) ;- Connect WB's events to the WB_events class object.
Gui,2: Show,,%filename1%
gosub,a1
return
a1:
Gui,2: Submit, NoHide
try {WB.Navigate(URL)
}catch e{
xxx:=e.Message
msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
Brb:
try{WB.GoBack()
}catch e{
xxx:=e.Message
;msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
BrF:
try{WB.GoForward()
}catch e{
xxx:=e.Message
;msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
class WB_events
{
NavigateComplete2(wb, NewURL)
{
GuiControl,2:, URL, %NewURL% ;- Update the URL edit control.
}
}
2GuiClose:
ExitApp
Last edited by garry on 05 Apr 2018, 09:44, edited 1 time in total.
Re: Embed web page in ahk's GUI
Thank you garry for a nice example.
The only issue is every web-page navigation gives an error in JavaScript: Do you know how to fix it?
The only issue is every web-page navigation gives an error in JavaScript: Do you know how to fix it?
Focusing our efforts on non-productive and non-creative endeavours wastes lives as surely as war.
Jacque Fresco / The best that money can't buy
Jacque Fresco / The best that money can't buy
Re: Embed web page in ahk's GUI
don't know, try search for other example or someone can help
I have the same problem if I use windows internet explorer , with firefox is OK
for me :
I have the same problem if I use windows internet explorer , with firefox is OK
for me :
Code: Select all
internet explorer > Shell.Explorer = failure
firefox > Mozilla.Browser = OK
Re: Embed web page in ahk's GUI
found another example , user 'jethrow'
https://autohotkey.com/board/topic/5698 ... ntry362159
https://autohotkey.com/board/topic/5698 ... ntry362159
Code: Select all
;-------- saved at Freitag, 27. Februar 2015 20:23:37 --------------
;-------- https://autohotkey.com/board/topic/56987-com-object-reference-autohotkey-v11/page-2#entry362159
;// open Standard Internet Explorer
;xxx=Shell.Explorer ;- Microsoft windows browser
xxx:="InternetExplorer.Application"
;xxx:="Mozilla.Browser" ;- mozilla firefox browser NOK
;xxx:="MozillaExplorer.Application"
wb := ComObjCreate(xxx) ;// create IE
wb.Visible := true ;// show IE
wb.GoHome() ;// Navigate Home
;// the ReadyState will be 4 when the page is loaded
while wb.ReadyState <> 4
continue
;// get the Name & URL of the site
msgbox, 262208, , % "Name: " wb.LocationName
. "`nURL: " wb.LocationURL
. "`n`nLet's Navigate to Autohotkey.com..." ,6
;// get the Document - which is the webpage
document := wb.document
;// Navigate to AutoHotkey.com
wb.Navigate("www.AutoHotkey.com") ;// 2nd param - see NavConstants
;// the Busy property will be true while the page is loading
while wb.Busy
continue
msgbox, 262208, ,Page Loaded...Going Back Now , 8
;// Go Back
wb.GoBack()
while wb.Busy
continue
msgbox, 262208, ,The page is loaded - now we will refresh it... ,8
;// Refresh the page
wb.Refresh()
while wb.Busy
continue
msgbox, 262208, ,Now that the page is Refreshed `, we will Select All (^a)... ,8
;// Execute Commands with ExecWB()
SelectAll := 17 ;// see CMD IDs
wb.ExecWB(SelectAll,0) ;// second param as "0" uses default options
Sleep 2000
msgbox, 262208, ,Now that we are done`, we will exit Internet Explorer ,6
;// Quit Internet Explorer
wb.Quit()
Re: Embed web page in ahk's GUI
It would be news to me that there is a possibility to connect to Firefox via COM. I have never heard about anything like that. IE, sure...Code: Select all
;xxx:="Mozilla.Browser" ;- mozilla firefox browser NOK ;xxx:="MozillaExplorer.Application" wb := ComObjCreate(xxx) ;// create IE
That's probably also the reason why Haswell gets the error message about the not supported method 'getElementsbyClassname'. That doesn't really work for you with mozilla, Gary?
Re: Embed web page in ahk's GUI
@gregster
it was my bad experiments , it works only with 'InternetExplorer.Application'
this works as 'jethrow' wrote :
first example above works for me with mozilla.browser ( ActiveX )
it was my bad experiments , it works only with 'InternetExplorer.Application'
this works as 'jethrow' wrote :
Code: Select all
xxx:="InternetExplorer.Application"
wb := ComObjCreate(xxx) ;// create IE
Code: Select all
;Gui,2: Add, ActiveX, xm w980 h640 vWB, Shell.Explorer ;- failure
Gui,2: Add, ActiveX, xm w1080 h720 vWB, Mozilla.Browser ;- good
ComObjConnect(WB, WB_events) ;- Connect WB's events to the WB_events class object.
Last edited by garry on 05 Apr 2018, 07:34, edited 1 time in total.
Re: Embed web page in ahk's GUI
I still doubt that an ActiveX element can load anything else than something based on the Internet Explorer. I think you are not really loading mozilla with this line above, but still some kind of (functionally watered-down) IE-browser element. That is what ActiveX was made for, while Mozilla has no COM interface to connect to...
Re: Embed web page in ahk's GUI
thank you gregster, I don't know what really happens, but first script works with 'Mozilla.Browser' without failure
Re: Embed web page in ahk's GUI
But for me all ones give this error.
Focusing our efforts on non-productive and non-creative endeavours wastes lives as surely as war.
Jacque Fresco / The best that money can't buy
Jacque Fresco / The best that money can't buy
Re: Embed web page in ahk's GUI
For any object type that is invalid, Shell.Application is loaded. It appears to work but isnt actually using mozilla
What you are missing is WB.Silent := true
What you are missing is WB.Silent := true
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Embed web page in ahk's GUI
Sorry meant Shell.Explorer
any way here is a working script
any way here is a working script
Code: Select all
;-------- saved at Mittwoch, 18. Februar 2015 19:45:55 XP netbook
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=6445 -----------
;-- a browser from user 'Soft' and 'Lexikos'
;===========================================================================
f1=https://autohotkey.com/boards/
filename1=Browser SOFT
Gui Add, Edit, w930 r1 vURL,%f1%
Gui Add, Button, x5 y25 gBrB, <
Gui Add, Button, x+1 y25 gBrF, >
Gui Add, Button, x+6 yp w44 Default gA1, Go
;Gui Add, ActiveX, xm w980 h640 vWB, Shell.Explorer
;~ Gui Add, ActiveX, xm w1080 h720 vWB, Mozilla.Browser
Gui Add, ActiveX, xm w1080 h720 vWB, Shell.Explorer
;~ ComObjConnect(WB, WB_events) ;- Connect WB's events to the WB_events class object.
Gui Show,,%filename1%
Gui Submit, NoHide
wb.silent := true
gosub,a1
return
a1:
Gui Submit, NoHide
WB.Navigate(URL)
return
Brb:
try{WB.GoBack()
}catch e{
xxx:=e.Message
msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
BrF:
try{WB.GoForward()
}catch e{
xxx:=e.Message
msgbox, 262208,ERROR,Error=`n%xxx%`n------------------------------------------`n
return
}
return
class WB_events
{
NavigateComplete2(wb, NewURL)
{
GuiControl, Text, URL, %NewURL% ;- Update the URL edit control.
}
}
GuiClose:
ExitApp
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Embed web page in ahk's GUI
@tank
for me it looks better when I use Mozilla.Browser ( have Firefox as default browser )
EDIT :
in my first script above
when I go Forward > it updates the URL in edit control
when I go Backward > Edit control is empty ( doesn't show the previous URL )
thank you tank , works fine now with both , without failureWhat you are missing is WB.Silent := true
for me it looks better when I use Mozilla.Browser ( have Firefox as default browser )
Code: Select all
;Gui,2: Add, ActiveX, xm w980 h640 vWB, Shell.Explorer ; OK
Gui,2: Add, ActiveX, xm w1080 h720 vWB, Mozilla.Browser ; OK
wb.silent := true
ComObjConnect(WB, WB_events) ;- Connect WB's events to the WB_events class object / should activate this to update the URL edit control ( ? )
in my first script above
when I go Forward > it updates the URL in edit control
when I go Backward > Edit control is empty ( doesn't show the previous URL )
Re: Embed web page in ahk's GUI
Oh yes!
It works now.
It works now.
Focusing our efforts on non-productive and non-creative endeavours wastes lives as surely as war.
Jacque Fresco / The best that money can't buy
Jacque Fresco / The best that money can't buy
Who is online
Users browsing this forum: sanmaodo and 149 guests