I'm doing a little mini-project. It is a visual URL collector. I know there are much better browser extensions. I do it just as a challenge and to entertain myself. In addition, a personal application and on the computer itself, you create it to your liking and it is totally under your control.
My goal is to use it for when there is a situation where the browser is being saturated with tabs. I copy part of them, quickly, with this utility, and I close them from the browser.
I have encountered the problem that I have put a pseudo-button in the GUI to delete the URLs, but having the transparent property, the routine programmed in the control below (URL/Thumbnail) is switched at the same time. I've been searching and haven't found the solution. At the moment I have left the button displaced so that it is almost outside the Thumbnail. It even looks elegant and gives it a style!
(For just 219 lines of code, that's not bad.)
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory
#Include Lib\ViewHtml.ahk
;#include Lib\ImagePut.ahk
#include Lib\ImagePut (for v1).ahk
Menu, Tray, Icon, Resources\1609.ico
if FileExist("Data\Image_1.jpg")
Loop, Data\Image_Lite_*.jpg
ImgData:= A_Index
^F3::
NotifyTrayClick_207:
Gui, DroIt: Destroy
Settimer, RetriveText, 250
Gui, DroIt: -border -caption +toolwindow +LastFound +alwaysontop
hI := DllCall( "LoadLibrary", Str,"RichEd20.dll" ), Gui1 := WinExist(), W:=500, H:=30
RE1 := RichE( Gui1, 15, 15, 50, 50, hI )
Gui, DroIt: Add, Pic, w50 h50 gRetriveText vDroIt GuiMove, Resources\ArrowDown.png
xSp:= A_ScreenWidth-180
ySp:= A_ScreenHeight-180
Gui, DroIt: Show, x%xSp% y%ySp% ; w800 h640
Return
RetriveText:
Gui +OwnDialogs
ControlGetText, RET1,, ahk_id %RE1%
If (RET1 !="")
{
Settimer, RetriveText, off
ImgData++
URLName:= "Data\URL_" ImgData ".txt"
FileAppend, %RET1%, %URLName%
IfNotInString, RET1, youtube
{
browserId := WinExist("ahk_exe chrome.exe")
WinActivate, ahk_exe chrome.exe
Sleep, 300
ControlGetPos, x, y, w, h, Chrome_RenderWidgetHostHWND1, ahk_id %browserId%
WinGetPos, wx, wy, ww, wh, ahk_id %browserId%
XPos:= wx+ww-w-11
YPos:= wy+wh-h-11
Ww:=w-40
Hh:=h-40
ImagePutFile([XPos, YPos, Ww, Hh], "Image_" ImgData ".jpg")
}
GetTitle:= UrlDownloadToVar2(RET1)
Document:= ComObjCreate("HTMLfile")
Document.Write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
Document.DesignMode := "on"
Gettitle:= RegExReplace(gettitle, "iframe","")
Document.Write(gettitle)
Result:= % document.title
NameData:= "Data\Name_" ImgData ".txt"
FileAppend, %Result%, %NameData%
ImgName:= "Image_" ImgData ".jpg"
IfInString, RET1, youtube
{
vVideoID := SubStr(RET1, InStr(RET1, "?v=")+3, 11)
ImgVideo:="http://img.youtube.com/vi/" vVideoID "/maxresdefault.jpg"
UrlDownloadToFile, %ImgVideo%, %ImgName%
}
Percent:="30%"
LiteImg:= "Image_Lite_" ImgData ".jpg"
RunWait, %A_WorkingDir%\Addons\magick.exe -quiet %ImgName% -bordercolor "#2d2d2d" -border 10x10 -resize %Percent% %LiteImg%,,hide
FileMove, %ImgName%, %A_WorkingDir%\Data\%ImgName%
FileMove, %LiteImg%, %A_WorkingDir%\Data\%LiteImg%
TrayTip
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1500
Gosub, NotifyTrayClick_207
}
Return
HideTrayTip:
TrayTip
Return
^F6::
NotifyTrayClick_201:
gui,2: Destroy
Gui, ColletorIMG: Destroy
Gui, DroIt: Destroy
if FileExist("Data\Image_1.jpg")
Loop, Data\Image_Lite_*.jpg
ImgData:= A_Index
Gui, ColletorIMG: +alwaysontop +ToolWindow ; +0x400000 +hWndhMainWnd +Owner -Caption
CSV_Load("Table.csv","data")
Loop %ImgData%
{
XPos:=CSV_ReadCell("data",A_index,1)
C_XPos:= XPos
YPos:=CSV_ReadCell("data",A_index,2)
C_YPos:= YPos
Gui, ColletorIMG: Add, Pic, w313 h236 x%XPos% y%YPos% gGoURL vDateURL%A_Index%, Data\Image_Lite_%A_index%.jpg
FileText:="Data\Name_" A_Index ".txt"
Fileread, TempText, %FileText%
YPos:=CSV_ReadCell("data",A_index,3)
Gui, ColletorIMG: Font, S9 Bold, Verdana
Gui, ColletorIMG: Add, Text, w313 h20 x%XPos% y%YPos% center +BackgroundTrans, %TempText%
XPos:= C_XPos+295 ;278
YPos:= C_YPos-12 ;+5
Gui, ColletorIMG: Add, Pic, w28 h28 x%XPos% y%YPos% +BackgroundTrans gDeleteImg vDeleteURL%A_Index%, Resources\Close_Red.png
}
Gui, ColletorIMG: Show, AutoSize, URL'S Collector
Gui, ColletorIMG: Add, Pic, x0 y0 w2400 , Resources\Abstracto_azul.jpg
Return
GoURL:
Gui, ColletorIMG: Submit
StringTrimLeft, URLCopy, a_guicontrol, 7
FileURL:="Data\URL_" URLCopy ".txt"
Fileread, TempURL, %FileURL%
Run, %TempURL%
Return
DeleteImg:
Gui, ColletorIMG: Submit
StringTrimLeft, DelImg, a_guicontrol, 9
MsgBox, 0x1034,, Do you want to delete the %DelImg%st entrance of the Colletor?
IfMsgBox Yes
{
Gui, 4: Destroy
Gui, ContextClip: Destroy
FileDelete, Data\Image_%DelImg%.jpg
FileDelete, Data\Image_Lite_%DelImg%.jpg
FileDelete, Data\Name_%DelImg%.txt
FileDelete, Data\URL_%DelImg%.txt
Loop, %ImgData%
if !FileExist("image_Lite_" A_Index ".jpg")
{
NumberFile := A_Index
FileSup := NumberFile+1
Sup := "Data\Image_" Filesup ".jpg"
NumF:= "Data\Image_" NumberFile ".jpg"
Filemove, %Sup%, %NumF%
Sup := "Data\Image_Lite_" Filesup ".jpg"
NumF:= "Data\Image_Lite_" NumberFile ".jpg"
Filemove, %Sup%, %NumF%
Sup := "Data\Name_" Filesup ".txt"
NumF:= "Data\Name_" NumberFile ".txt"
Filemove, %Sup%, %NumF%
Sup := "Data\URL_" Filesup ".txt"
NumF:= "Data\URL_" NumberFile ".txt"
Filemove, %Sup%, %NumF%
}
Gosub, NotifyTrayClick_201
}
Else
Gosub, NotifyTrayClick_201
Return
;---------------------------
RichE( hW, X,Y,W,H, hI ) { ; Thanks corrupt www.autohotkey.com/forum/viewtopic.php?t=19421
Return DllCall( "CreateWindowEx", UInt,0x200, Str,"RichEdit20A", Str,Null, UInt,0x50000004
,Int,X, Int,Y, Int,W, Int,H, UInt,hW, UInt,0, UInt,hI, UInt,0 )
}
;-----------------------------------------
GetTitleFromUrl(url) {
http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
http.Open("GET", "https://www.youtube.com/oembed?url=" url "&format=json", true)
http.Send()
http.WaitForResponse()
if (RegExMatch(http.ResponseText,"\x22title\x22:\x22([^\x22]+)",title)) { ;could use a json library but this should work just as well
return title1
}
return ""
}
;-----------------------------------------
UrlDownloadToVar2(URL) {
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
try WebRequest.Open("GET", url, false)
catch error
return error.Message
WebRequest.Send()
Return WebRequest.ResponseText
}
;-----------------------------------------
NotifyTrayClick(P*) { ; v0.41 by SKAN on D39E/D39N @ tiny.cc/notifytrayclick
Static Msg, Fun:="NotifyTrayClick", NM:=OnMessage(0x404,Func(Fun),-1), Chk,T:=-250,Clk:=1
If ( (NM := Format(Fun . "_{:03X}", Msg := P[2])) && P.Count()<4 )
Return ( T := Max(-5000, 0-(P[1] ? Abs(P[1]) : 250)) )
Critical
If ( ( Msg<0x201 || Msg>0x209 ) || ( IsFunc(NM) || Islabel(NM) )=0 )
Return
Chk := (Fun . "_" . (Msg<=0x203 ? "203" : Msg<=0x206 ? "206" : Msg<=0x209 ? "209" : ""))
SetTimer, %NM%, % (Msg==0x203 || Msg==0x206 || Msg==0x209)
? (-1, Clk:=2) : ( Clk=2 ? ("Off", Clk:=1) : ( IsFunc(Chk) || IsLabel(Chk) ? T : -1) )
Return True
}
;-----------------------------------------
uiMove:
PostMessage, 0xA1, 2,,, A
Return
/*
Miniatura de baja calidad:
http://img.youtube.com/vi/<YouTube_Video_ID_HERE>/sddefault.jpg
Miniatura de calidad media:
http://img.youtube.com/vi/<YouTube_Video_ID_HERE>/mqdefault.jpg
Miniatura de alta calidad:
http://img.youtube.com/vi/<YouTube_Video_ID_HERE>/hqdefault.jpg
Miniatura de máxima calidad:
http://img.youtube.com/vi/<YouTube_Video_ID_HERE>/maxresdefault.jpg
https://img.youtube.com/vi/GNIzN32EruU/0.jpg
desde https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
*/
Thanks to @descolada for the part of the code that captures the chrome client window viewtopic.php?p=477537#p477537.
Due to my limits of knowledge, I will put several tabs; that the gui can be seen at 3, 8, or 10 columns..., lowering the size of the Thumbnail, but I can do little else. I used the CSV.ahk function https://github.com/hi5/CSV to control the position of images by reading them from a .CSV file. There is quite a lot of ingenuity in all the processes.
Demo:
(I ran out of Camtasia license.)
Download file with all necessary components: https://mega.nz/file/9FJhWDYA#OiAMNfsTdkdLa0n9-Aw7ioWKBaugS8LpuDWODwBQ2j0
Sorry to the administrators, the post has been duplicated. Sometimes I duplicate the tab to search for information and it is that action that must make things wrong. Also tiredness
[Mod edit: Fixed the code tags, which allowed most of the post that was hidden within the code box (everything after the code box) to be displayed since there was no correct closing tag. The code goes between a pair of code tags like this: [code]code goes here[/code], not inside one of the tags.