View previous topic :: View next topic |
Author |
Message |
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sat Aug 10, 2002 5:25 pm Post subject: VDS forum - copy, format, and save |
|
|
This one is kind of a plug-in for Internet Explorer. I got a little tired of two things when copying code off
this forum:
First, I got all sorts of page formating drowning the code so I had to pass it through a text editor
before insertion in the VDS editor.
Secondly, all lines ended off with a blank, sometimes keeping the code from running properly
until I had spotted those darn lines that needed a trimming of blanks.
First of all - compile the script to an EXE. Tip: Give it a nice short and descriptive name.
Drag the EXE from Explorer (or any file manager) to your browser's (prolly only works in MSIE) hyperlinks bar.
You should now have a nice browser button with your filename on it. You may rename it (right-click the button)
to fine tune the button text
Operation:
First off - click the button once (with no selection made in your browser) to
choose your preferences:
1. Format and copy to clipboard or 2. Format and save as a VDS script file.
Go on now - surf that VDS forum - select code snippets that you wanna check out and use the
button to make it nice VDS compatible.
Have phun!
Dr. Dread
Code: |
title VDS Code Copier ..by Dr. Dread
option SCALE,96
option DECIMALSEP,"."
%w = @winactive(I)
gosub CheckINI
%%inc = 0
list create,1
rem Flush the clipboard to be able to check if something new is copied to it
clipboard CLEAR
gosub ACQUIRE
rem Check if nothing was copied (no selection in browser window)
:Evaluate
if @null(@text(1))
rem Clipboard was empty - we wait for data (unless we already did)
if @equal(%%wait,%%inc)
goto getdialog
end
wait .2
list paste,1
%%inc = @succ(%%inc)
goto Evaluate
else
goto RunIt
end
:getdialog
dialog CREATE,VDS Code Copier .. by Dr. Dread,-1,0,230,115,SMALLCAP,ONTOP
dialog ADD,STYLE,STYLE1,,,,BLACK,BLACK
dialog ADD,STYLE,STYLE2,Arial,8,B,
dialog ADD,STYLE,STYLE3,,6,,,LTBLUE
dialog ADD,TEXT,text1,3,6,,,No selection currently made in browser,STYLE2
dialog ADD,RADIO,set1,20,2,226,,How to handle selections:,1. Format and copy to clipboard|2. Save selection as .dsc file and open it,%%setradio
dialog ADD,BUTTON,Info,97,4,16,16,?,STYLE2
dialog ADD,BUTTON,Settings,94,188,40,20,Save,DEFAULT
dialog ADD,BUTTON,Cancel,94,140,45,20,Cancel
dialog ADD,TEXT,text2,98,30,,,VDSWORLD Forum,style3,CLICK
dialog ADD,TEXT,text3,76,12,,,Wait for clipboard max (1/5 secs):
dialog ADD,EDIT,wait,75,174,22,16,%%wait
dialog SHOW
:Evloop
wait event
goto @event()
:InfoBUTTON
%h = " How to use:"@cr()@cr()
%h = %h First of all - compile the script to an EXE.@cr()
%h = %h Tip: Give it a nice short and descriptive name like @CHR(34)VDScopy@CHR(34).@cr()
%h = %h Drag the EXE from Explorer (or any file manager) to your browser's Links toolbar.@cr()
%h = %h You should now have a nice browser button with your filename on it@cr()
%h = %h You may rename it (right-click the button) to fine tune the button text@cr()@cr()@cr()
%h = %h Operation:@cr()@cr()
%h = %h First off - click the button once (with no selection made in your browser) to@cr()
%h = %h @tab()choose your preferences: 1. Format and copy to clipboard or 2. Format and@cr()
%h = %h @tab()save as a VDS script file. Set the maximum time to wait for the Clipboard@cr()
%h = %h Go on now - surf that VDS forum - select code snippets that you wanna check out@cr()
%h = %h @tab()and use the button to make it nicely VDS compatible.@cr()
%h = %h If you want to alter the program settings"," then hit the button without making any@cr()
%h = %h @tab()text selection in your browser.@cr()@cr()
%h = %h Greetz@cr()@cr()
%h = %h Dr. Dread@cr()
info %h
dialog focus,Settings
goto evloop
:SettingsBUTTON
rem Save preferences in INI
inifile OPEN,@path(%0)VDScopy.ini
%%radiovalue = @substr(@dlg(set1),1,2)
if @equal(@dlgtext(wait),0)
info The 'Wait for Clipboard' value should be greater than 0
goto evloop
end
if @not(@numeric(@dlgtext(wait)))
info The 'Wait for Clipboard' value must be numeric
goto evloop
end
if @equal(%%radiovalue,1.)
inifile WRITE,Section1,choice1,clipboard
else
inifile WRITE,Section1,choice1,file
end
inifile WRITE,Section1,wait,@dlgtext(wait)
goto CLOSE
:CancelBUTTON
goto CLOSE
:Text2CLICK
shell open,http://www.vdsworld.com/forum/
wait .2
goto CLOSE
:RunIt
list create,2
rem Format lines so trailing spaces are removed
repeat
%%line = @next(1)
list add,2,@strdel(@trim(@strins(%%line,1,¤)),1)
until @equal(@index(1),@count(1))
rem Perform whatever was decided in Settings
if @equal(%%choice1,clipboard)
list copy,2
else
rem Create dummy dialog to get a file dialog
dialog CREATE,VDS save code,-1,0,1,1,ONTOP,NOTITLE,class "Save as"
dialog show
window ACTIVATE,"VDS save code"
%%saveas = @filedlg("Script file (*.dsc)|*.dsc",Save script)
if %%saveas
if @equal(@ext(%%saveas),dsc)
list savefile,2,%%saveas
else
%%saveas = %%saveas"."dsc
list savefile,2,%%saveas
end
end
rem Open resulting file
wait .5
if @file(%%saveas)
shell open,%%saveas
end
end
list close,1
list close,2
:CLOSE
stop
rem ################## SUBs ###################
:ACQUIRE
rem Get selected text from browser
window SEND,%W,@CTRL(C)
wait .5
list paste,1
wait .1
EXIT
:CheckINI
if @file(@path(%0)VDScopy.ini)
inifile OPEN,@path(%0)VDScopy.ini
%%choice1 = @INIREAD(Section1,choice1,clipboard)
%%wait = @INIREAD(Section1,wait,5)
if @null(%%wait)
%%wait = 5
end
else
%%choice1 = clipboard
list create,1
list add,1,[Section1]
list add,1,choice1=clipboard
list add,1,wait=5
list savefile,1,@path(%0)VDScopy.ini
list close,1
end
if @equal(%%choice1,clipboard)
%%setradio = 1. Format and copy to clipboard
else
%%setradio = 2. Save selection as .dsc file and open it
end
EXIT
|
EDIT: A couple of minor adjustments. On the Settings dialog added a Cancel button and a link
to VDSWORLD.
EDIT2: Another few small changes. First and foremost an extra wait loop to check if nothing is actually copied from the browser
or the system just lags a bit.
EDIT3: Added the possibility of adjusting the maximum time (in 1/5 secs) that the app will wait for the clipboard to be filled.
EDIT4: More flexible line trimming - based on a trim-right idea from Tommy.
EDIT5: Check for a Settings value that could put the prog in an endless loop. The 'Wait for Clipboard' part now works better.
EDIT6: Put in some extra checks to protect against users putting illegal values into settings.
EDIT7: Bugfix. If first line in selected text was empty, the program would assume nothing was copied to the Clipboard. _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Mon Feb 17, 2003 1:00 pm; edited 14 times in total |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Aug 10, 2002 7:11 pm Post subject: |
|
|
Excellent! Works fine for me here and I made an icon for it that looks
pretty good when on the toolbar.
http://www.vdsworld.com/~garrett/VDSCopy.ico
As I said, looks fine on the toolbar, but not at full 32x32 viewing like
pictured above, only when it's in it's 16x16 state on the toolbar. |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Aug 11, 2002 9:05 am Post subject: |
|
|
Great! That's a good icon, Garrett. Looks nice sittin' on the toolbar
Made a couple of adjustments to the program
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Aug 11, 2002 12:00 pm Post subject: |
|
|
Nice job Dread,
Unfortunately, I can't drag anything onto my IE4 toolbar,
so I "borrowed" your idea and made a front-end for VDS
instead. Not as fancy as yours though, it only formats the
clipboard info.
This replaces the VDS shortcut on my desktop. It loads
VDS, then runs as a tiny window (48x18) in the upper
left corner of the screen, and closes when VDS does
(or it can be closed separately).
To use it as a front-end, replace the VDS path in the top
line with your own. Otherwise, remove the top line.
Instructions:
1. Copy code from VDSworld.
2. Press the "Clip" button.
3. Paste to the VDS editor.
Code: |
SHELL OPEN, "E:\WINAPPS\VDS30\VDS.exe"
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"VDSworld Copy",0,0,48,18,NOTITLE,ONTOP
DIALOG ADD,BUTTON,Exit,0,30,18,18,"x"
DIALOG ADD,BUTTON,Clip,0,0,30,18
DIALOG SHOW
LIST CREATE, 1
:EVLOOP
WAIT EVENT, 1
goto @event()
:TIMER
if @not(@winexists("Visual DialogScript"))
goto CLOSE
end
goto EVLOOP
:ClipBUTTON
LIST PASTE, 1
WAIT
if @greater(@count(1), 0)
%x = 0
REPEAT
%s = @item(1, %x)
if @equal(@substr(%s, @len(%s)), " ")
LIST PUT, 1, @substr(%s, 1, @pred(@len(%s)))
end
%x = @succ(%x)
UNTIL @equal(%x, @count(1))
LIST COPY, 1
LIST CLEAR, 1
goto EVLOOP
:ExitBUTTON
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Aug 11, 2002 1:15 pm Post subject: |
|
|
Mac wrote: | Unfortunately, I can't drag anything onto my IE4 toolbar,
so I "borrowed" your idea and made a front-end for VDS
instead. |
Hi, Mac!
Yeah, I thought that there might be difficulties in some browsers. I have MSIE 5 + 6, and the toolbar button
works fine there. However, the button can only be placed on the Hyperlinks/Links toolbar, not in the
general toolbar containing the Back/Forward/Home buttons etc. I don't know about MSIE 4.
Actually, the program was at first more like yours - a little resident box dialog, but then I decided for the
"hit and run" approach which is only loaded when needed and then immediately exits.
Greetz
Dr. Dread
PS: I checked out your little app, works fine here. But if someone has placed VDS elsewhere than "E:\WINAPPS\VDS30\VDS.exe" , this might be handy:
Code: |
%%reg = @REGREAD(ROOT,Applications\VDS.EXE\shell\open\command,)
option fieldsep," "
parse "%%VDS;%%var",%%reg
REM Here is VDS.exe:
info %%VDS
|
[/code] _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Aug 11, 2002 1:41 pm Post subject: |
|
|
Hey Dread,
I have the HKEY_CLASS_ROOT\Applications key,
but no VDS subkey... 8O
I thought about trying @regread() for the VDS path,
but assumed it's different for different versions, or
might load the wrong one if someone had both VDS3
and VDS4.
BTW, I mentioned changing the path in my post...
I also compiled a copy without the top line and put it
in the VDS\Tools folder so I can start it from VDS
(without starting VDS again).
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sun Aug 11, 2002 3:55 pm Post subject: |
|
|
Mac wrote: |
I have the HKEY_CLASS_ROOT\Applications key,
but no VDS subkey... 8O |
Hmmm. Sh.t happens. (he-he, you know you cannot write this little sh.. word in full on this board, or you'll have
"Ooops happens" I think our webmaster wants us to be well-behaved and mind our language
Do you have ?:
HKEY_CURRENT_USER\Software\Classes\Applications\VDS.EXE\shell\open\command
Even on different platforms, the VDS installation must have some reg key to determine this.
Mac wrote: | BTW, I mentioned changing the path in my post... |
Yup. I saw it, and even understood it But I just love code that is really portable so I can move it between
different computers without having to change paths and stuff, so I just couldn't help myself.
Mac wrote: | I also compiled a copy without the top line and put it
in the VDS\Tools folder so I can start it from VDS
(without starting VDS again). |
Good thinking. That's portable.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Aug 11, 2002 9:01 pm Post subject: |
|
|
Dread wrote: |
Do you have ?:
HKEY_CURRENT_USER\Software\Classes\Applications\VDS.EXE\shell\open\command
|
Nope... Both VDS2.5 and VDS3 are in the registery under SADE.
VDS 2.5 32-bit shows no path except in previously loaded
scripts (History subkey):
HKEY_CURRENT_USER\Software\SADE\VDS2.5
VDS 3.5:
HKEY_CURRENT_USER\Software\SADE\VDS\3.5 "Path"
Perhaps VDS3 would have put its' info elsewhere if I hadn't
had VDS 2.5? I dunno. Maybe it's just a Win95 thing...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sun Aug 11, 2002 9:07 pm Post subject: |
|
|
The easy way is to create an empty .dsc file somewhere and then use:
Code: |
shell open,dummy.dsc
|
Otherwise this will probably work for you too, Mac:
Code: |
%%filetype = .dsc
%%vds = @regread(root,@regread(root,%%filetype,)\shell\open\command,)
info %%vds
|
You will however, probably have to parse out the "%1" parameter from %%vds, or you
won't be able to actually run it.
Tommy |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Aug 11, 2002 9:25 pm Post subject: |
|
|
Hey Tommy,
This code:
Code: |
%%filetype = .dsc
%%vds = @regread(root,@regread(root,%%filetype,)\shell\open\command,)
info %%vds
|
Returns this in the INFO window:
C:\WIN95\NOTEPAD.EXE %1
Maybe because I have .DSC files associated with Notepad?
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Last edited by Mac on Sun Aug 11, 2002 9:29 pm; edited 1 time in total |
|
Back to top |
|
|
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sun Aug 11, 2002 9:27 pm Post subject: |
|
|
Oh you assigned Notepad to editing VDS scripts?! |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Aug 11, 2002 9:30 pm Post subject: |
|
|
Yep. It takes VDS too long to load just to view a file...
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Mon Aug 12, 2002 1:16 am Post subject: |
|
|
If interested, I think I know how to add buttons to the IE toolbar. Next
to the back forward, ect....I'm going to do a little more research then I'll
post my findings. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Aug 12, 2002 1:58 am Post subject: |
|
|
I'm interested if you do make any progress on adding a button.
-Garrett |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Mon Aug 12, 2002 8:28 am Post subject: |
|
|
Aaaah, this is interesting. In a thread just a few days ago there was a link to a Microsoft page describing the procedure
for adding buttons to MSIE (real toolbar buttons).
This raw piece of code should create the actual button. However, if the user has customized the toolbar, the button will
not appear on the toolbar automatically. Must be added manually. Nothing to do about that. AND the button is blank because
it requires a special type of icon file holding several button images (16x16,20x20,16-color,256-color, greyscale).
More info on this here:
http://msdn.microsoft.com/workshop/browser/ext/overview/toolbar_style.asp
Unfortunately this resource is not very specific on how to construct this type of icon resource, maybe someone here knows?
Greetz
Dread
Code: |
REM This experiment is only possible in MSIE 5 or later
dialog CREATE,MSIE button installer .. by Dr. Dread,-1,0,180,120
dialog ADD,BUTTON,SelDir,10,5,170,,Select EXE file for the button
dialog ADD,BUTTON,SelIco,35,5,170,,Select mouseover ICO file 20x20
dialog ADD,BUTTON,SelIco2,60,5,170,,Select mouseout ICO file 20x20
dialog ADD,BUTTON,Go,90,40,,,Go!
dialog SHOW
:Evloop
wait event
goto @event()
:SelDirBUTTON
%%EXE = @filedlg("Executable file (*.exe)|*.exe",Select file)
goto evloop
:SelIcoBUTTON
%%ICO = @filedlg("Icon file (*.ico)|*.ico",Select file)
goto evloop
:SelIco2BUTTON
%%ICO2 = @filedlg("Icon file (*.ico)|*.ico",Select file)
goto evloop
:GoBUTTON
if @null(%%EXE)
info Select EXE file!
goto evloop
end
if @null(%%ICO)
info Select mouseover ICO file!
goto evloop
end
if @null(%%ICO2)
info Select mouseout ICO file!
goto evloop
end
REM This GUID is generated for this app, so it shouldn't clash with any other button
REM Only use it for 1 button!
%%GUID = {4B4EC1C9-BC9B-40AB-BF9D-4A8AC3C6E0C5}
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions,%%GUID
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions\%%GUID,Default Visible,YES
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions\%%GUID,ButtonText,VDScopy
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions\%%GUID,HotIcon,%%ICO
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions\%%GUID,Icon,%%ICO2
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions\%%GUID,CLSID,{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}
REGISTRY WRITE,LOCAL,Software\Microsoft\Internet Explorer\Extensions\%%GUID,Exec,%%exe
REM If the user has customized the toolbar, the button will not appear on the toolbar automatically.
REM The toolbar button will be added to the choices in the Customize Toolbar dialog box and can be added here.
:close
exit |
EDIT: Update to make it work directly with a couple of 20x20 icons. _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing
Last edited by Dr. Dread on Wed Aug 14, 2002 9:37 pm; edited 2 times in total |
|
Back to top |
|
|
|
|
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
|
|