AutoHotkey Community

It is currently May 27th, 2012, 1:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: April 4th, 2009, 9:33 pm 
Offline

Joined: April 1st, 2009, 1:12 am
Posts: 16
Location: Netherlands
#c:: ; hotkey, press windowskey C to run this script
FileList=
clipboard= ; clear clipboard just to be sure
Send ^c ; this will copy a selection to the clipboard
Clipwait, 2
SelectFile=File1.txt|File2.txt|File3.txt|File4.txt ; list of files
Loop, Parse, SelectFile, |
Menu, MyMenu, Add, %A_LoopField%, MenuHandler
Menu, MyMenu, Show
MenuHandler:
FileRead, FileList, %A_ThisMenuItem% ; read selected file
Loop, Parse, FileList, `n, `r
{ ; this is called a block http://www.autohotkey.com/docs/commands/Block.htm
If (Clipboard = A_LoopField)
{
MsgBox Already in %A_ThisMenuItem%
Return
}
}
; if we get here we haven't found it so add it
MsgBox, 4100, Ask , %clipboard%`n TO: %A_ThisMenuItem% ?
IfMsgBox, Yes
{
FileAppend, %clipboard%`n, %A_ThisMenuItem%
SoundBeep
}
Return
;OK, stays in foreground now.
;I tried several but
;This beeps if Yes and still comes back one more time with Already in %A_ThisMenuItem%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2009, 8:18 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Move the menuhandler, should work better now. Please use CODE tags when you post.
Code:
#c:: ; hotkey, press windowskey C to run this script
FileList=
clipboard= ; clear clipboard just to be sure
Send ^c ; this will copy a selection to the clipboard
Clipwait, 2
SelectFile=File1.txt|File2.txt|File3.txt|File4.txt ; list of files
Loop, Parse, SelectFile, |
Menu, MyMenu, Add, %A_LoopField%, MenuHandler
Menu, MyMenu, Show
Return

MenuHandler:
FileRead, FileList, %A_ThisMenuItem% ; read selected file
Loop, Parse, FileList, `n, `r
   { ; this is called a block http://www.autohotkey.com/docs/commands/Block.htm
   If (Clipboard = A_LoopField)
      {
      MsgBox Already in %A_ThisMenuItem%
      Return
      }
   }
; if we get here we haven't found it so add it
MsgBox, 4100, Ask , %clipboard%`n TO: %A_ThisMenuItem% ?
IfMsgBox, Yes
   {
   FileAppend, %clipboard%`n, %A_ThisMenuItem%
   SoundBeep
   }
Return

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2009, 10:53 am 
Offline

Joined: April 1st, 2009, 1:12 am
Posts: 16
Location: Netherlands
#c:: ; hotkey, press windowskey C to run this script
FileList=
clipboard= ; clear clipboard just to be sure
Send ^c ; this will copy a selection to the clipboard
Clipwait, 2
SelectFile=File1.txt|File2.txt|File3.txt|File4.txt ; list of files
Loop, Parse, SelectFile, |
Menu, MyMenu, Add, %A_LoopField%, MenuHandler
Menu, MyMenu, Show
Return

MenuHandler:
FileRead, FileList, %A_ThisMenuItem% ; read selected file
Loop, Parse, FileList, `n, `r
{ ; this is called a block http://www.autohotkey.com/docs/commands/Block.htm
If (Clipboard = A_LoopField)
{
MsgBox, 4100,, Already in: %A_ThisMenuItem% ;Sometimes also in taskbar, but this asks yes no :(
Return
}
}
; if we get here we haven't found it so add it
MsgBox, 4100, Ask , %clipboard%`n TO: %A_ThisMenuItem% ?
IfMsgBox, Yes
{
FileAppend, %clipboard%`n, %A_ThisMenuItem%
SoundBeep
}
Return
;The sequence of the msgbox ok
;Mind the 'already in' box (Same taskbar problems.)
;I did the tests on plain text that works well, cannot recall if testeted on url ever from start, doubt.
;From selected url this script receives 'nothing' in the clip. (and suggests to clip nothing, and says 'nothing' exists)
;The browsermenu is open after selection with rightclick
;My second option to select copy url from browser menu after selection provides the same result.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2009, 11:05 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
1 - use code tags
2 - use code tags
3 - use code tags
4 - use code tags

5 - look at the MsgBox documentation to figure what '4100' means (tip: 4+4096) and change accordingly. You have got to learn to read the docs.

6 - I can't help any further I think, I don't know what you mean with browser menu, right click. It is not part of the script so figure that out yourself. Just select any text (doesn't matter if it is URL or not, of course it only works with text, not images, rich text etc.)

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2009, 11:32 am 
Offline

Joined: April 1st, 2009, 1:12 am
Posts: 16
Location: Netherlands
Clicking left on the url opens it, so have to do it right clicking there to select the tekstlabel from the url. I don't deliberately select rich text or images with this, undestand that, but urls its all about from start. However, I also think you helped me enough Hugo you did more than I asked with the filesmenu, so OK and thanks a lot!

I will solve the msgbox problem, think I can lookup that one.

Maybe someone else can help on the url problem, it may seem minor, but I don't know where to start digging on that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2009, 11:40 am 
Offline

Joined: April 1st, 2009, 1:12 am
Posts: 16
Location: Netherlands
Btw, what do you mean by 'use code tags' seems very obvious but I have to confess I don't get it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2009, 12:01 pm 
Offline

Joined: April 1st, 2009, 1:12 am
Posts: 16
Location: Netherlands
Anyone who follows this, I'm sorry I have to deal with a timeout on computertime :) Hope till soon!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2009, 2:01 am 
Offline

Joined: April 1st, 2009, 1:12 am
Posts: 16
Location: Netherlands
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.

============


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, oldbrother and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group