08-16-2007, 02:44 AM
Wow...a lot of work, thanks so much -- I'll have to spend some time to follow the complete thread and components. I already see some things that will help out if I keep the below framework.
I took a fairly different approach on this as I mentioned earlier. A "from memory" example is recreated here, went a bit overboard on comments in the macro and the html java script, but maybe it'll help others. The example's pretty bare bones, but you'll get the idea, and possibly give me a gold star for originality? ; )
PS pay no attention to "Fixme"s in the code - just notes to myself so I can search and quickly find things I want to expand upon etc.
read_cookie_mac
read_cookie_diag (note, this is QM's "dialog with browser" quickly adapted for this example - it requires "we3_DocumentComplete" which also came in Samples2)
Zip file contains the above macro and dialogs, plus simple html form and html success message. For this example, be sure to put the folder contained in the zip file in the C:\ root, and of course import the mac and diag files.
Steve
I took a fairly different approach on this as I mentioned earlier. A "from memory" example is recreated here, went a bit overboard on comments in the macro and the html java script, but maybe it'll help others. The example's pretty bare bones, but you'll get the idea, and possibly give me a gold star for originality? ; )
PS pay no attention to "Fixme"s in the code - just notes to myself so I can search and quickly find things I want to expand upon etc.
read_cookie_mac
//set variables
str logon logon_form cookie_dir cookie_text form_data cookie_dir_wildcard cookie_path
//get user logon name
if(rget(logon "Logon User Name" "Software\Microsoft\Windows\CurrentVersion\Explorer"))
//format str "logon_form" for use in filename
logon_form=logon
logon_form.lcase
logon_form.replacerx(" " "_" 1)
//format cookie directory and wildcard search string
cookie_dir.from("C:\Documents and Settings\" logon "\Cookies\")
cookie_dir_wildcard.from(cookie_dir logon_form "*local*.*")
del cookie_dir_wildcard ;;deletes prior cookies created by this process
//open html form in dialog
// FIXME --> nicked from QM "diag w/ browser"
// HELP --> How to resume macro upon HTML submit button press??
str+ site = "c:\formtest\cookie.html"
str controls = "3"
str ax3SHD
if(!ShowDialog("read_cookie_diag" &read_cookie_diag &controls)) ret
//enumerate string match and read file
lpstr cookie_actualname=dir(cookie_dir_wildcard)
rep
if(cookie_actualname = 0) break
cookie_path.from(cookie_dir cookie_actualname)
cookie_text.getfile(cookie_path)
cookie_actualname = dir
form_data=cookie_text
// Process form data
form_data.replacerx("%20" " " 1)
out form_data
// FIXME --> add enumerate/parse data next
read_cookie_diag (note, this is QM's "dialog with browser" quickly adapted for this example - it requires "we3_DocumentComplete" which also came in Samples2)
\read_cookie_mac
function# hDlg message wParam lParam
if(hDlg) goto messages
Web browser control is defined in SHDocWv type library, which is already declared, so we don't have to declare it again.
BEGIN DIALOG
0 "" 0x10CF0A44 0x100 0 0 277 200 "Submit writes a cookie"
3 ActiveX 0x54000000 0x4 12 20 236 154 "SHDocVw.WebBrowser"
1 Button 0x54030001 0x0 104 4 48 14 "OK"
END DIALOG
DIALOG EDITOR: "" 0x202000B "read_cookie_mac" ""
ret
messages
sel message
case WM_INITDIALOG
SHDocVw.WebBrowser we3._getcontrol(id(3 hDlg))
we3._setevents("we3_DWebBrowserEvents2")
we3.Navigate(site)
case WM_SIZE
RECT r; GetClientRect(hDlg &r)
MoveWindow id(3 hDlg) 0 30 r.right r.bottom-30 1
case WM_COMMAND goto messages2
ret
messages2
sel wParam
case [4,5,6,7,8]
err-
we3._getcontrol(id(3 hDlg))
sel wParam
case 4 we3.GoBack
case 5 we3.GoForward
case 6 we3.Stop
case 7 we3.Refresh
case 8 we3.GoHome
err+
case IDOK
case IDCANCEL
ret 1
Zip file contains the above macro and dialogs, plus simple html form and html success message. For this example, be sure to put the folder contained in the zip file in the C:\ root, and of course import the mac and diag files.
Steve