forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Using Browser Control (VDS5)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
cnodnarb
Valued Contributor
Valued Contributor


Joined: 11 Sep 2002
Posts: 688
Location: Evansville, IN

PostPosted: Wed Apr 06, 2011 4:05 am    Post subject: Using Browser Control (VDS5) Reply with quote

OK, got to label your HTML with id's.

Then you can access elements in browser control (sorta like DOM in VB)

WARNING @dlgtext(browser) is UNAVAILABLE and will cause your code to hang using this method.

Code:

external .\vdsbrw50.dll
#define command, browser
#define function, browser
Title asdf
  DIALOG CREATE,asdf,-1,0,800,600
  DIALOG ADD,BROWSER,BROWSER1,0,0,800,550,""
  DIALOG ADD,BUTTON,Close,570,441,64,24,Close
  DIALOG SHOW
dialog set,browser1,<html><body><div id='mydiv'>Hello</div><div id='mydiv2'>hi</div></body></html>
rem Set browser element: Requires abstraction to label/gosub/unit
 dialog set,browser1,javascript:document.getElementById('mydiv').innerHTML = 'Blah1234!'; void(0); 
 rem Get browser element: Requires abstraction to label/gosub/unit
 %%clip = @clipbrd() 
   dialog set,browser1,javascript:window.clipboardData.setData('Text'"," document.getElementById('mydiv').innerHTML); void(0);
  %%myvar = @clipbrd()
  clipboard set,%%clip
 info ok %%myvar is contained in variable "%%myvar"
  wait event
Back to top
View user's profile Send private message AIM Address
cnodnarb
Valued Contributor
Valued Contributor


Joined: 11 Sep 2002
Posts: 688
Location: Evansville, IN

PostPosted: Wed Apr 06, 2011 5:20 am    Post subject: A more practical example Reply with quote

Warning: not errortrapped. Only tested in the scenario below.

Click Button1, then Convert, then Button2.

Code:
external .\vdsbrw50.dll
#define command, browser
#define function, browser
Title asdf
  DIALOG CREATE,asdf,-1,0,594,388
  DIALOG ADD,BROWSER,BROWSER1,25,12,250,250,""
  DIALOG ADD,BUTTON,Button1,128,328,75,23,Button1
  dialog add,button,button2,171,328,75,23,Button2
  dialog add,text,text1,266,328,,,Click Button1"," then Convert"," then Button2.
  DIALOG SHOW
  :evloop
  wait event
  goto @event()
 
  :button1button
 dialog set,browser1, "http://www-igprev-opensocial.googleusercontent.com/gadgets/ifr?exp_rpc_js=1&exp_track_js=1&url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fcurrency_converter.xml&container=igprev&view=default&lang=en&country=US&sanitize=0&v=ee828ceba2c044b0&parent=http://www.google.com&libs=core:core.io:core.iglegacy:auth-refresh&synd=igprev&view=default#st=&gadgetId=101048974621201906114&gadgetOwner=105250506097979753968&gadgetViewer=105250506097979753968&rpctoken=-201339433&ifpctok=-201339433&up_currencies=&up_prevTarget=-1&up_prevValue=1&up_prevSource=-1&up_prevSourceCode=&up_prevTargetCode="
  goto evloop
 
  :button2button
 %%clip = @clipbrd() 
   dialog set,browser1,javascript:window.clipboardData.setData('Text'"," document.getElementById('currency-result').innerHTML); void(0);
  %%myvar = @clipbrd()
  clipboard set,%%clip
  dialog set,text1,%%myvar

   dialog set,browser1,javascript:document.getElementById('currency-result').innerHTML = 'Blah!'; void(0); 
   goto evloop
   
  :close
  exit
Back to top
View user's profile Send private message AIM Address
cnodnarb
Valued Contributor
Valued Contributor


Joined: 11 Sep 2002
Posts: 688
Location: Evansville, IN

PostPosted: Wed Apr 06, 2011 11:05 pm    Post subject: Reply with quote

Disable right click.

Wrecks @dlgtext(browser1)

Code:
dialog set,browser1,javascript:function clickIE4(){if (event.button==2){return false;}}function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}document.oncontextmenu=new Function('return false');void(0);
Back to top
View user's profile Send private message AIM Address
cnodnarb
Valued Contributor
Valued Contributor


Joined: 11 Sep 2002
Posts: 688
Location: Evansville, IN

PostPosted: Wed Apr 06, 2011 11:29 pm    Post subject: Reply with quote

Hide scrollbar.

Code:
dialog set,browser1,javascript:document.getElementsByTagName('body')[0].style.overflow = 'hidden';void(0);
Back to top
View user's profile Send private message AIM Address
cnodnarb
Valued Contributor
Valued Contributor


Joined: 11 Sep 2002
Posts: 688
Location: Evansville, IN

PostPosted: Thu Apr 07, 2011 4:24 am    Post subject: Reply with quote

Crude prototype code to return variables WITHOUT using clipboard.

Requires clean up. (also demonstrates zoom)

updated to drop repeat - until, caused error after 7 button2 clicks.

Code:
external .\vdsbrw50.dll
#define command, browser
#define function, browser
  option fieldsep,|
Title asdf
  DIALOG CREATE,asdf,-1,0,594,388
REM *** Modified by Dialog Designer on 4/6/2011 - 22:12 ***
 DIALOG ADD,browser,BROWSER1,25,12,250,250,""
  DIALOG ADD,BUTTON,Button1,128,328,75,23,Button1
  dialog add,button,button2,171,328,75,23,Button2
  dialog add,text,text1,266,328,,,Click Button1"," then Convert"," then Button2.
  DIALOG ADD,TRACKBAR,TRACKBAR1,297,352,180,50,50,,,,BOTH
  DIALOG ADD,TEXT,TEXT2,327,295,,,TEXT2
  DIALOG ADD,TEXT,TEXT3,347,297,,,TEXT3
  DIALOG SHOW
  list create,1
  list create,2
 
   dialog set,browser1, "http://www-igprev-opensocial.googleusercontent.com/gadgets/ifr?exp_rpc_js=1&exp_track_js=1&url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fcurrency_converter.xml&container=igprev&view=default&lang=en&country=US&sanitize=0&v=ee828ceba2c044b0&parent=http://www.google.com&libs=core:core.io:core.iglegacy:auth-refresh&synd=igprev&view=default#st=&gadgetId=101048974621201906114&gadgetOwner=105250506097979753968&gadgetViewer=105250506097979753968&rpctoken=-201339433&ifpctok=-201339433&up_currencies=&up_prevTarget=-1&up_prevValue=1&up_prevSource=-1&up_prevSourceCode=&up_prevTargetCode="
 
  %%cookiepath = @regread(curuser,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,Cookies,0)
 
   :timer
   repeat
  until @null(@browser(browser1,busy))
  if @equal(%%x,0)
  dialog set,trackbar1,1
  end
 
  if @not(@equal(%%x,@dlgtext(trackbar1)))
  dialog set,browser1,javascript:document.body.style.zoom='@fmul(@dlgtext(trackbar1),2)"%"';void(0);
    dialog set,text2,@dlgtext(trackbar1)
    dialog set,text3,@fmul(@dlgtext(trackbar1),2)
  end
 
  :evloop
   %%x = @dlgtext(trackbar1)
  wait event,.1
  goto @event()
 
  :button1button
 dialog set,browser1, "http://www-igprev-opensocial.googleusercontent.com/gadgets/ifr?exp_rpc_js=1&exp_track_js=1&url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fcurrency_converter.xml&container=igprev&view=default&lang=en&country=US&sanitize=0&v=ee828ceba2c044b0&parent=http://www.google.com&libs=core:core.io:core.iglegacy:auth-refresh&synd=igprev&view=default#st=&gadgetId=101048974621201906114&gadgetOwner=105250506097979753968&gadgetViewer=105250506097979753968&rpctoken=-201339433&ifpctok=-201339433&up_currencies=&up_prevTarget=-1&up_prevValue=1&up_prevSource=-1&up_prevSourceCode=&up_prevTargetCode="
  goto evloop

 
 
  :button2button
 %%datetime = @datetime()
 dialog set,browser1,javascript:document.cookie = 'vdsdata=|%%datetime|'+document.getElementById('currency-result').innerHTML+'|;expires=Fri"," 26 Dec 2099 10:00:00 GMT;path=/mydomain';void(0);
list filelist,1,%%cookiepath\*.*


%m = @count(1)
%c = -1

:searchloop
%c = @succ(%c)
list seek,1,%c
if @not(@Equal(%c,%m))
list loadfile,2,@item(1)
%d = 0
%n = @count(2)
:norepeat
 list seek,2,%d
%d = @succ(%d)
parse "%%a;%%b;%%c",@item(2)
if @equal(%%b,%%datetime)
goto endsearch
end
if @equal(%d,%n)
rem do nothing
else
goto norepeat
end
goto searchloop
else
%%c = "Variable Not Found"
end
:endsearch
%%myvar = %%c

  dialog set,text1,%%myvar

   dialog set,browser1,javascript:document.getElementById('currency-result').innerHTML = 'Blah!'; void(0); 
   goto evloop
   
  :close
  exit

Back to top
View user's profile Send private message AIM Address
cnodnarb
Valued Contributor
Valued Contributor


Joined: 11 Sep 2002
Posts: 688
Location: Evansville, IN

PostPosted: Thu Apr 07, 2011 1:13 pm    Post subject: Reply with quote

Not the cleanest code but here's what I'm running with for now (abstracting to gosub) [update, changed list 1 to list 8, list 2 to list 9, renamed variables and labels to avoid reassign in main labels outside of sub)

Code:
external .\vdsbrw50.dll
#define command, browser
#define function, browser
  option fieldsep,|
option decimalsep,.
Title asdf
  DIALOG CREATE,asdf,-1,0,594,388
REM *** Modified by Dialog Designer on 4/6/2011 - 22:12 ***
 DIALOG ADD,browser,BROWSER1,25,12,250,250,""
  DIALOG ADD,BUTTON,Button1,128,328,75,23,Button1
  dialog add,button,button2,171,328,75,23,Button2
  dialog add,text,text1,266,328,,,Click Button1"," then Convert"," then Button2.
  DIALOG ADD,TRACKBAR,TRACKBAR1,297,352,180,50,50,,,,BOTH
  DIALOG ADD,TEXT,TEXT2,327,295,,,TEXT2
  DIALOG ADD,TEXT,TEXT3,347,297,,,TEXT3
  DIALOG SHOW
 
  %%dombrowser = browser1
 
 
   dialog set,browser1, "http://www-igprev-opensocial.googleusercontent.com/gadgets/ifr?exp_rpc_js=1&exp_track_js=1&url=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Fcurrency_converter.xml&container=igprev&view=default&lang=en&country=US&sanitize=0&v=ee828ceba2c044b0&parent=http://www.google.com&libs=core:core.io:core.iglegacy:auth-refresh&synd=igprev&view=default#st=&gadgetId=101048974621201906114&gadgetOwner=105250506097979753968&gadgetViewer=105250506097979753968&rpctoken=-201339433&ifpctok=-201339433&up_currencies=&up_prevTarget=-1&up_prevValue=1&up_prevSource=-1&up_prevSourceCode=&up_prevTargetCode="
 
   :timer
   
   repeat
  until @null(@browser(browser1,busy))
  if @equal(%%x,0)
  dialog set,trackbar1,1
  end
 
  if @not(@equal(%%x,@dlgtext(trackbar1)))
  dialog set,browser1,javascript:document.body.style.zoom='@fmul(@dlgtext(trackbar1),2)"%"';void(0);
    dialog set,text2,@dlgtext(trackbar1)
    dialog set,text3,@fmul(@dlgtext(trackbar1),2)
  end
 
  :evloop
   %%x = @dlgtext(trackbar1)
  wait event,.1
  goto @event()
 
  :button1button
 dialog set,browser1,javascript:document.getElementById('currency-result').innerHTML = 'Blah!'; void(0); 
 gosub domnorclick
 gosub domnoscroll
 goto evloop

     :button2button
  %%domreturn = document.getElementById('currency-result').innerHTML
  gosub getDOMreturn
    dialog set,text1,%%domreturn
   goto evloop

   :getDOMreturn 
   %%cookiepath = @regread(curuser,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,Cookies,0)
   option errortrap,domskiplist
  list create,8
  list create,9
  option errortrap,domerrortrap
  :domskiplist
 %%domdatetime = @datetime()
 dialog set,%%dombrowser,javascript:document.cookie = 'vdsdata=|%%domdatetime|'+%%domreturn+'|;expires=Fri"," 26 Dec 2099 10:00:00 GMT;path=/mydomain';void(0);
list filelist,8,%%cookiepath\*.*
%%domm = @count(8)
%%domc = -1
:domsearchloop
%%domc = @succ(%%domc)
list seek,8,%%domc
if @not(@Equal(%%domc,%%domm))
list loadfile,9,@item(8)
%%domd = 0
%%domn = @count(9)
:domnorepeat
 list seek,9,%%domd
%%domd = @succ(%%domd)
rem parse "%%domaa;%%dombb;%%domcc",@item(9)
parse ";%%dombb;%%domcc",@item(9)
if @equal(%%dombb,%%domdatetime)
goto domendsearch
end
if @equal(%%domd,%%domn)
rem do nothing
else
goto domnorepeat
end
goto domsearchloop
else
%%domcc = "Variable Not Found"
end
:domendsearch
%%domreturn = %%domcc
exit
:domerrortrap
INFO ERROR @ERROR(E) at Line number @ERROR(N)
stop
:domnoscroll
dialog set,%%dombrowser,javascript:document.getElementsByTagName('body')[0].style.overflow = 'hidden';void(0);
exit
:domnorclick
 dialog set,%%dombrowser,javascript:function clickIE4(){if (event.button==2){return false;}}function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}document.oncontextmenu=new Function('return false');void(0);
  exit
   
  :close
  exit
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group