|
Don't know to be off topic, my question is solved, but as there was some interest, I post this for my level of guys, newbies.
If interested I can post the readme aswell Id better not go on top again so all at once, would be ashamed to post this in the scripts thread. But it does what I meant quite well. The simple version without the menu suits me. Here it is:
; clpbpru is a tiny routine to get a url from clipboard and paste it in pastelistu.txt in its home folder.
; The url is not pasted when it exists in pastelistu.txt. It gets the first url wherever in the clip.
; Thanks to Hugo on AH who was patient to help me. I changed the hotkey from c to u
; to distinguish it from clpbprm maybe.
; Hugo suggested to include a menu to select a destination file from a list.
; An other option would be to have more url's at once and sort out the unknown, but I cannot imagine
; a good goal for that, unless it is possible to get hidden url's from a document selection. In the moment
; I cannot extinguish whether this is possible from AH. Appending from other file, sorting and cleaning from
; double's are possible options. Have to reconcidder the organisation then and do a lot of study.
;
; I suggest to close this post because the outcome now fits to purpose.
; Jos from user tcp800 @ AutoHotkey.
#u:: ;StartMain Hotkey, press windowskey and u to run this script.
File=pastelistu.txt
;clipboard=; clear clipboard just to be sure
;Send ^c ; this will copy a selection to the clipboard. ; instead I like it to start from copied text or url. Well, it
; works that way for now.
Clipwait, 2
clipboard=%clipboard% ; Make it plain text, according clipboard spec. But, this loses original clipboard...
URLSearchstring=%clipboard% ; Maybe just this has the same effect? I'don't know yet.
Gosub, URLSearch
If URLSearchstring =
{
MsgBox 4096,,NO URL FOUND IN CLIP,2 ; + time out for easy use.
Return ;EndMain
}
FileRead,FileList,%File%
Loop,Parse,FileList,`n,`r
{
If (URLSearchstring = A_LoopField)
{
SoundBeep, 420, 200
MsgBox,4096,,URL EXISTS IN %File%,2
Return ;EndMain
}
}
; if we get here we haven't found it so add it
URLSearchstring =%URLSearchstring%`n`r
FileAppend, %URLSearchstring%, %File%
MsgBox,4096,,URL COPIED TO %File%,2
Return ;EndMain
URLSearch:
;See LoopReadFile example to extract all url's from clipboard eventually clipped from html page, modified for
;first appearing url on the URLSearchstring taken from clipboard. I know I could better have left it that way
;and do the modification (retrieve only first url) after this, I am a newbe... It was very instructive to me to do so.
;It also gets a url from a html fragment I think. I did not test this. It might not.
;This only needs URLSearchString and returns it with the first url or with nothing.
; It's done this particular way because some URLs have other URLs embedded inside them:
StringGetPos, URLStart1, URLSearchString, http://
StringGetPos, URLStart2, URLSearchString, ftp://
StringGetPos, URLStart3, URLSearchString, www.
; Find the left-most starting position:
URLStart =%URLStart1% ; Set starting default.
Loop
{
; It helps performance (at least in a script with many variables) to resolve
; "URLStart%A_Index%" only once:
ArrayElement := URLStart%A_Index%
If ArrayElement = ; End of the array has been reached.
Break
If ArrayElement = -1 ; This element is disqualified.
Continue
If URLStart = -1
{
URLStart =%ArrayElement%
}
Else ; URLStart has a valid position in it, so compare it with ArrayElement.
{
If ArrayElement <> -1
If ArrayElement < %URLStart%
URLStart =%ArrayElement%
}
}
if URLStart = -1 ; No URLs exist in URLSearchString.
{
URLSearchstring =
Return ; EndSub
}
; Otherwise, extract this URL:
StringTrimLeft, URL, URLSearchString, %URLStart% ; Omit the beginning/irrelevant part.
Loop, parse, URL, %A_Tab%%A_Space%<> ; Find the first space, tab, or angle (if any).
{
URL =%A_LoopField%
Break ; i.e. perform only one loop iteration to fetch the first "field".
}
; If the above loop had zero iterations because there were no ending characters found,
; leave the contents of the URL var untouched.
; If the URL ends in a double quote, remove it. For now, StringReplace is used, but
; note that it seems that double quotes can legitimately exist inside URLs, so this
; might damage them:
StringReplace, URLCleansed, URL, ",, All
URLSearchstring =%URLCleansed%
Return ; EndSub
clpbpru_readme.txt April 7, 2009.
Files involved:
Clipbpru.txt
Clipbpru.exe
Clipbpru.ahk
Install Clipbpru
Put clpbpru.exe in a directory you have control over, clpbpr in programfiles in a workfolder on your desktop
seems a good place to me. If u have clpbpru.ahk, you put that there aswell.
Start Clipbpru
Start by double clicking on clpbpru.exe.
A trayicon appears in the systemtray. It shows AH from AutoHotkey.
The program is active now and waits for its hotkey to work for you.
Use Clpbpru - Just hit the windowskey followed by 'u' after a copy to the clipboard.
First choose a labeled url in a html document on a site by rightclick, and select copy url from the dropdownmenu. A labeled url shows in the status bar under left when you hover with the cursor over its label.
The label may represent a user name on the site or, a boat, a record, a book, an artists, or whatever you want to control. So the label is not the url. We are interested in the url's here. Because that represents the one and only adress to this label. If you copied the url this way, you should start the Autohotkey feature if you want to safe this url. The sequence for that is the windows-key followed by the u-key.
Clpbpru @work
The program now searches for the url you gave in its pastelistu.txt and if this list does not exist it is made in the folder where you put clpbpru.exe
If the list was there the url is found or pasted in the list.
You will get a message what happened. You will hear a beep when the paste (user, boat, record) was already there. The message times out in short, you may but don't have to answer.
As an option you can choose a a part of a document and it will retrieve the first appearence of a url in it. This is done because you might easily choose spaces or other signs and characters to the url you select that does not belong to it. Clpbpru will clean it to just the url.
Organise Cathagories with pastebpru.txt (Not needed when you go for only one Cathagorie.)
Some things you might think of to follow now. You may already have a list with url's in a textfile. You can paste them in pastelistu.txt to have a quick start. Be sure to paste just the clean url's in it. If you are finished with a job and want to continue with an other cathagory url's copy pastelistu.txt b.e. to Cathagory_x.txt and start from scratch with an other cathagory in pastelistu.txt made by Clpbpru or by quickstart from your renamed Cathagory_y.txt to pastelistu.txt, aso.
============
|
|