How do I drive Konqueror from script?

David Faure faure at kde.org
Mon Sep 20 11:51:13 BST 2010


On Friday 09 July 2010, Krzysztof Żelechowski wrote:
> I am looking for a way to write a script for the SMS feature in
> KAddressBook. The script should go like this (in AppleScript pseudocode)
> 
> const kGateURL = "..."
> 
> on run
> tell Konqueror
> navigate to kGateURL
> tell current document
> tell form 0
> set value of control "receiver" to %N
> set value of control "message" to contents of file %F
> reveal
> end tell
> end tell
> end tell
> end run
> 
> Please give me some hints how I could actually implement this tidbit.

This can be done with the evalJS dbus call.

Here is an excerpt from a script of mine which scripts a webpage too:

url=....
appid=`kstart --service konqueror.desktop --windowclass konqueror --url "$url"`
# kstart ensures konqueror is launched and ready, but not that khtml finished loading
objid=''
while test -z "$objid"; do
   # TODO: timeout?
   sleep 1
   i=1
   objid="/KHTML/$i/widget"
   if test "`qdbus $appid $objid url`" != "$url"; then
     objid=''
   fi
done

# Assume KWallet filled in the login page.

qdbus $appid $objid evalJS 'document.forms[0].submit()'

sleep 1

qdbus $appid $objid evalJS '.....'

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).




More information about the kfm-devel mailing list