Multiple clipboard, with title and URL of web page

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

20 Oct 2021, 14:58

hi. Two small changes.

1. The clipboard pop up menu is now semi-transparent (you can change it on line 405. 0 for opaque and 255 fully transparent, now at 210).
2. There are two styles of this menu, the existing one and a new one more in line with the colors I'm using in the utility (yellow and blue).

Image

You can switch from one style to another in the "Basic Clipboard" submenu.

(The styles section is duplicated in the script because it has to be at the top for it to start, but you can't refer to the top of the script, when switching, via on gosub because the Tray menu creates problems).

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3c"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled=1
previousClip=%clipboard%
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
SuspendThumbnail := 0
SuspendHotkeys := 1
Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip := A_Index
;MsgBox, %NumberClip%
Loop, %NumberClip%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}

;***************************************************************************************************************************
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF        ;selection text color
                ,"selBGColor" :  0x036FC5         ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 0          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69        ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9        ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 32          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

;***************************************************************************************************************************
Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF        ;selection text color
                ,"selBGColor" :  0x036FC5         ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 0          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69        ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9        ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 32          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
Return
}
;If !Iniciate=1
Gosub, RButton
Return

;^!v::^
^Up::
^MButton::
ClipBoardEnabled=0
MouseGetPos, mx, my, WinUMID
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold" : 1
	    , "icon" : "Resources\Clipboard Utility.ico" } )
menu.Add()
}
index:=ClipBoardHistory.maxIndex()
if index=
return
while Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Index]["plain"]
	FullDescription:=Description
	;if(StrLen(Description)>35)
	if(StrLen(Description)>80)
	{ 
		toCut:=StrLen(Description)-25 
		;toCut:=StrLen(Description)-50
		;StringMid, itemTemp1, Description, 1, 12
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	if index<10
	MenuString:="&" . (ClipBoardHistory.maxindex()-Index+1) . ".  " . Description
	else
	MenuString:= (ClipBoardHistory.maxindex()-Index+1) . ".  " . Description
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "index" : Index
			, "tooltip" : ClipBoardHistory[Index]["plain"]})
			
	index--
}

;WinGet, ActiveWindow , ID, A
MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
;item := menu.Show( A_ScreenWidth/3, A_ScreenHeight/3 ) 
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu
;tooltip
WinActivate, ahk_id %WinUMID%
WinWaitActive, ahk_id %WinUMID%
if item
{
ClipBoardEnabled=0
test:=item.index
;tempClip:=clipboard
WinClip.Clear()
clipboard:=ClipBoardHistory[test]["plain"]
;Sleep, 300
send, ^v
;clipboard:=tempClip
;ClipBoardEnabled=1
}

Menu.destroy()
ClipBoardEnabled=1
return

PUM_out( msg, obj )
{
;  if ( msg = "onselect" )
;    tooltip %  obj.tooltip 
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     }
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
;  if ( msg = "onrbutton" )
;    tooltip % "Right clicked: " obj.name
;  if ( msg = "onmbutton" )
;    Clipboard:=obj.name
;     ;ClipBoardEnabled=1
;    ;tooltip % "Middle clicked: " obj.name
;  if ( msg = "onrun" )
;    tooltip % "Item runned: " obj.name
}

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
} Else {
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
{
ErrorType :=1
Gosub, ControlError
;MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.
Return
}
Else 
CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)
	;CorpusCount++
	;FileDelete, 
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	;currentClipAll=%clipboardall% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip,, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, 15)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,maxclips=15)
{
	ClipBoardHistory.insert(Object())
	index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[index]["plain"]:=clip
	;ClipBoardHistory[index]["All"]:=clipall
	ClipTemp:= "TempClip\Clip" index ".clip"
	If Index<=15 
		{
		FileAppend, %Clip%, %ClipTemp%
		}
	if (index>maxclips)
		{
		ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
		FileDelete, TempClip\Clip1.clip
		Loop 15
		if !FileExist("TempClip\Clip" A_Index ".clip")
			{
			NumberFile := A_Index
		        FileSup := NumberFile+1
			Sup := "TempClip\Clip" Filesup ".clip"
			NumF:= "TempClip\Clip" NumberFile ".clip"
			Filemove, %Sup%, %NumF%
			}
			FileAppend, %Clip%, TempClip\Clip15.clip
			}
}
;************************************************************************************************************************

^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Return

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
;MsgBox, HOLA!!!
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
SoundPlay, Resources\Close Window.mp3
}
else
{
Style=1
SoundPlay, Resources\Close Window.mp3
}
Iniciate := 1
Gosub, Style
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

NotifyTrayClick_201:
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

21 Oct 2021, 10:02

Hi.

Small corrections.

In some processes it is loaded to the clipboard and then pasted and copied to the basic clipboard (because it is active). I've been looking to disable the basic clipboard during all these processes (i'm not sure if there are still any unregistered processes left).

I've added the possibility of a small copy window for the basic clipboard. It is activated with the keys Windows+Alt and mouse drag.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3d"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled=1
;ChangeClipEnable=0
previousClip=%clipboard%
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
SuspendThumbnail := 0
SuspendHotkeys := 1
Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip := A_Index
;MsgBox, %NumberClip%
Loop, %NumberClip%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
Return
}
;If !Iniciate=1
Gosub, RButton
Return

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF        ;selection text color
                ,"selBGColor" :  0x036FC5         ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69        ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9        ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )
Return

;^!v::^
^Up::
^MButton::
Gosub, Style
Sleep 400
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos, mx, my, WinUMID
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold" : 1
	    , "icon" : "Resources\Clipboard Utility.ico" } )
menu.Add()
}
index:=ClipBoardHistory.maxIndex()
if index=
return
while Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Index]["plain"]
	FullDescription:=Description
	;if(StrLen(Description)>35)
	if(StrLen(Description)>80)
	{ 
		toCut:=StrLen(Description)-25 
		;toCut:=StrLen(Description)-50
		;StringMid, itemTemp1, Description, 1, 12
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	if index<10
	MenuString:="&" . (ClipBoardHistory.maxindex()-Index+1) . ".  " . Description
	else
	MenuString:= (ClipBoardHistory.maxindex()-Index+1) . ".  " . Description
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "index" : Index
			, "tooltip" : ClipBoardHistory[Index]["plain"]})
			
	index--
}

;WinGet, ActiveWindow , ID, A
MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
;item := menu.Show( A_ScreenWidth/3, A_ScreenHeight/3 ) 
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu
;tooltip
WinActivate, ahk_id %WinUMID%
WinWaitActive, ahk_id %WinUMID%
if item
{
;ClipBoardEnabled=0
test:=item.index
;tempClip:=clipboard
WinClip.Clear()
clipboard:=ClipBoardHistory[test]["plain"]
;Sleep, 300
send, ^v
;clipboard:=tempClip
;ClipBoardEnabled=1
}

Menu.destroy()
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
return

PUM_out( msg, obj )
{
;  if ( msg = "onselect" )
;    tooltip %  obj.tooltip 
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     }
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
;  if ( msg = "onrbutton" )
;    tooltip % "Right clicked: " obj.name
;  if ( msg = "onmbutton" )
;    Clipboard:=obj.name
;     ;ClipBoardEnabled=1
;    ;tooltip % "Middle clicked: " obj.name
;  if ( msg = "onrun" )
;    tooltip % "Item runned: " obj.name
}

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
} Else {
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
{
ErrorType :=1
Gosub, ControlError
;MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.
Return
}
Else 
CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)
	;CorpusCount++
	;FileDelete, 
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	;currentClipAll=%clipboardall% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip,, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, 15)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,maxclips=15)
{
	ClipBoardHistory.insert(Object())
	index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[index]["plain"]:=clip
	;ClipBoardHistory[index]["All"]:=clipall
	ClipTemp:= "TempClip\Clip" index ".clip"
	If Index<=15 
		{
		FileAppend, %Clip%, %ClipTemp%
		}
	if (index>maxclips)
		{
		ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
		FileDelete, TempClip\Clip1.clip
		Loop 15
		if !FileExist("TempClip\Clip" A_Index ".clip")
			{
			NumberFile := A_Index
		        FileSup := NumberFile+1
			Sup := "TempClip\Clip" Filesup ".clip"
			NumF:= "TempClip\Clip" NumberFile ".clip"
			Filemove, %Sup%, %NumF%
			}
			FileAppend, %Clip%, TempClip\Clip15.clip
			}
}
;************************************************************************************************************************

^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
;MsgBox, HOLA!!!
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
SoundPlay, Resources\Close Window.mp3
}
else
{
Style=1
SoundPlay, Resources\Close Window.mp3
}
Iniciate := 1
Gosub, Style
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

NotifyTrayClick_201:
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
Redirected at 7:34 pm. Fixed an error that has been present for a long time, when it was about editing two titles, one to another. He gave the error that a variables could not be used in two different fields.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

22 Oct 2021, 09:14

Last night I installed Windows 11 and the basic clipboard became very erratic: The menu didn't appear in many occasions, it didn't paste the text, it warned about the last pasted text (TrayTip)... I adopted a script that was in development and still had some bugs or some more development (it's from capitalH and it's on this page: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/). I've revised a few things to make it do things better, but I think I need to tweak the whole thing. At the moment the following script solves some problems. I don't know if it's Windows 10 or 11, but keep in mind that I'm now on 11 and in my case it works a bit more stable (I have to install Windows 10 on a test computer).

Something strange is that if I open notepad from the secondary monitor, not even the clipboard menu comes up (lots of weird and random things!, I don't understand anything.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3g"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled=1
;ChangeClipEnable=0
previousClip=%clipboard%
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
SuspendThumbnail := 0
SuspendHotkeys := 1
Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip := A_Index
;MsgBox, %NumberClip%
Loop, %NumberClip%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
Return
}
;If !Iniciate=1
Gosub, RButton
Return

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF        ;selection text color
                ,"selBGColor" :  0x036FC5         ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69        ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9        ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )
;Return

;^!v::
^Up::
^MButton::
MouseGetPos, mx, my, WinUMID
Gosub, Style
WinClip.Clear()
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold" : 1
	    , "icon" : "Resources\Clipboard Utility.ico" } )
menu.Add()
}
index:=ClipBoardHistory.maxIndex()
if index=
return
while Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Index]
	FullDescription:=Description
	;if(StrLen(Description)>35)
	if(StrLen(Description)>80)
	{ 
		toCut:=StrLen(Description)-25 
		;toCut:=StrLen(Description)-50
		;StringMid, itemTemp1, Description, 1, 12
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	if index<10
	MenuString:="&" . (ClipBoardHistory.maxindex()-Index+1) . ".  " . Description
	else
	MenuString:= (ClipBoardHistory.maxindex()-Index+1) . ".  " . Description
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "index" : Index})
			
	index--
}

;WinGet, ActiveWindow , ID, A
MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
;item := menu.Show( A_ScreenWidth/3, A_ScreenHeight/3 ) 
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu

Menu.destroy()
if item
{
test:=item.index
WinClip.Clear()
clipboard:=ClipBoardHistory[test]
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
}
WinClip.Clear()
return

PUM_out( msg, obj )
{
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     sleep, 400
     }
;  if ( msg = "onselect" )
;    tooltip %  obj.tooltip 
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
;  if ( msg = "onrbutton" )
;    tooltip % "Right clicked: " obj.name
;  if ( msg = "onmbutton" )
;    Clipboard:=obj.name
;     ;ClipBoardEnabled=1
;    ;tooltip % "Middle clicked: " obj.name
;  if ( msg = "onrun" )
;    tooltip % "Item runned: " obj.name
;  if ( msg ~= "oninit|onuninit|onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
;  if ( msg ~= "onclose" )
;    WinActivate, ahk_id %WinUMID%
;    WinWaitActive, ahk_id %WinUMID%
;    if item
;     {
;      ClipBoardEnabled=0
;      test:=item.index
;      WinClip.Clear()
;      Clipboard:=ClipBoardHistory[test]
;      send, ^v
;      }
}

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
} Else {
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
{
ErrorType :=1
Gosub, ControlError
;MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.
Return
}
Else 
CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)
	;CorpusCount++
	;FileDelete, 
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	;currentClipAll=%clipboardall% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip,, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, 15)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,maxclips=15)
{
	ClipBoardHistory.insert(Object())
	index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[index]:=clip
	;ClipBoardHistory[index]["All"]:=clipall
	ClipTemp:= "TempClip\Clip" index ".clip"
	If Index<=15 
		{
		FileAppend, %Clip%, %ClipTemp%
		}
	if (index>maxclips)
		{
		ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
		FileDelete, TempClip\Clip1.clip
		Loop 15
		if !FileExist("TempClip\Clip" A_Index ".clip")
			{
			NumberFile := A_Index
		        FileSup := NumberFile+1
			Sup := "TempClip\Clip" Filesup ".clip"
			NumF:= "TempClip\Clip" NumberFile ".clip"
			Filemove, %Sup%, %NumF%
			}
			FileAppend, %Clip%, TempClip\Clip15.clip
			}
}
;************************************************************************************************************************

^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
;MsgBox, HOLA!!!
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
SoundPlay, Resources\Close Window.mp3
}
else
{
Style=1
SoundPlay, Resources\Close Window.mp3
}
Iniciate := 1
Gosub, Style
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

NotifyTrayClick_201:
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

23 Oct 2021, 17:49

I've fixed some problems. It's tricky to keep track of when to disable or enable clipboard capture. Sometimes it crashes and stays disabled. This is what I've tried to correct (I don't know if it's bug free now, but I'm working on it).

The PUM (Pop Up Menu) menus can be programmed to do what they do when hit with one of the three mouse buttons (I'm talking about basic clipboard). I have programmed it so that with the middle button you select what is going to be pasted and the order, and you finish the operation with the right mouse button, which pastes all the selected contents. (Previously you have to have an application open and focused where you are going to paste the content, obvious!)

Demonstration video:



I don't know programming. This utility is mainly based on automations. It is possible that it can be improved through all that I do not know. I learn from my mistakes. I'm trying to learn what is an object and arrays to modify some functions.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3h"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled=1
;ChangeClipEnable=0
previousClip=%clipboard%
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
SuspendThumbnail := 0
SuspendHotkeys := 1
Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
;MsgBox, %NumberClip0%
Loop, %NumberClip0%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
Return
}
;If !Iniciate=1
Gosub, RButton
Return

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF        ;selection text color
                ,"selBGColor" :  0x036FC5         ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69        ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9        ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any of this events happen, se it below
                ,"onuninit"    : "PUM_out"
                ,"onselect"    : "PUM_out"
                ,"onrbutton"   : "PUM_out"
                ,"onmbutton"   : "PUM_out"
                ,"onrun"       : "PUM_out" }

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )
;Return

;^!v::
^Up::
^MButton::
index:=ClipBoardHistory.maxIndex()
if !index
;{
;MsgBox, There are Currently no Clipboards
return
;}
MouseGetPos, mx, my, WinUMID
Gosub, Style
FileDelete, TempClip.clip
WinClip.Clear()
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
menu.Add( { "name" : "     Clipboard Utility"
            , "bold" : 1
	    , "icon" : "Resources\Clipboard Utility.ico" } )
menu.Add()

while Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Index]
	FullDescription:=Description
	;if(StrLen(Description)>35)
	if(StrLen(Description)>80)
	{ 
		toCut:=StrLen(Description)-25 
		;toCut:=StrLen(Description)-50
		;StringMid, itemTemp1, Description, 1, 12
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	if index<10
	MenuString:="&" . (ClipBoardHistory.maxindex()-Index+1) . ".   " . Description
	else
	MenuString:= (ClipBoardHistory.maxindex()-Index+1) . ".   " . Description
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "index" : Index})
	index--
}

;WinGet, ActiveWindow , ID, A
MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
;item := menu.Show( A_ScreenWidth/3, A_ScreenHeight/3 ) 
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu

if item
{
test:=item.index
WinClip.Clear()
clipboard:=ClipBoardHistory[test]
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Close Window.mp3
}

Menu.destroy()
If ChangeClipEnable=1
  {
  WinClip.Clear()
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
WinClip.Clear()
return

PUM_out( msg, obj )
{
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     sleep, 400
     }
;  if ( msg = "onselect" )
;    tooltip %  obj.tooltip 
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
;    tooltip % "Right clicked: " obj.name
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id-2
     Loop, TempClip\Clip*.clip
     NumberClip := A_Index
     Loop %NumberClip%
       {
       If A_index=%CLipM%
        {
        break
        }
      ;ClipNew--
      NumberClip--
      }
     WinClip.Clear()
     ReadClip := "TempClip\Clip" NumberClip ".clip"
     FileRead, Clipboard, %ReadClip%
     FileAppend, %CLipM%: %Clipboard%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	WinClip.Clear()
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
;    ;tooltip % "Middle clicked: " obj.name
;  if ( msg = "onrun" )
;    tooltip % "Item runned: " obj.name
;  if ( msg ~= "oninit|onuninit|onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  WinClip.Clear()
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
WinClip.Clear()
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   WinClip.Clear()
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
} Else {
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
{
ErrorType :=1
Gosub, ControlError
;MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.
Return
}
Else 
CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)
	;CorpusCount++
	;FileDelete, 
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	;currentClipAll=%clipboardall% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip,, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, 15)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,maxclips=15)
{
	ClipBoardHistory.insert(Object())
	index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[index]:=clip
	;ClipBoardHistory[index]["All"]:=clipall
	ClipTemp:= "TempClip\Clip" index ".clip"
	If Index<=15 
		{
		FileAppend, %Clip%, %ClipTemp%
		}
	if (index>maxclips)
		{
		ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
		FileDelete, TempClip\Clip1.clip
		Loop 15
		if !FileExist("TempClip\Clip" A_Index ".clip")
			{
			NumberFile := A_Index
		        FileSup := NumberFile+1
			Sup := "TempClip\Clip" Filesup ".clip"
			NumF:= "TempClip\Clip" NumberFile ".clip"
			Filemove, %Sup%, %NumF%
			}
			FileAppend, %Clip%, TempClip\Clip15.clip
			}
}
;************************************************************************************************************************

^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
SoundPlay, Resources\Close Window.mp3
}
else
{
Style=1
SoundPlay, Resources\Close Window.mp3
}
Iniciate := 1
Gosub, Style
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

NotifyTrayClick_201:
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
I had to match the two menus (both with headers) to make the add-on work. A function doesn't seem to read a variable from the script, or I don't know how to do it.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

25 Oct 2021, 14:37

Small, but important changes (some just small :lol: ).

I've already learned to be able to use variables in functions and have the script "read" variables of the functions. As simple as making them global.

Now it will be easier for me to create a configuration file. At the moment if you want to change the basic clipboard limit, you can do it by changing its value in line 43 (MaxClips := 15).

The problem with uploading to more clipboards is that the appearance of the clipboard menu can be impaired, because it is inside a loop where you have to trim the size of the texts. I think they have more problems the first time and that's why I've created a variable to make the time to appear the first time longer (I don't know if it's really effective, I'm testing options).

Now when copying only text with Ctrl+F3 (which is not copied because it is only for HTML type clipboards), it gives the option to save it in the basic clipboard.

I'm learning about the use of the PUM (Pop up menu) library. I've added tooltip, adjusting the width and length, so it doesn't overflow all over the screen. But it still has flaws when it tries to position itself next to the menu. (Cannot be solved, or it is not within my capabilities). They can be disabled in the inbox menu, in the basic clipboard section.

I think it pastes text from the basic clipboard faster now. I have optimized this option as much as possible.

I've changed the main style to make the header more different.

Image

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3i"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled=1
;ChangeClipEnable=0
previousClip=%clipboard%
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
SuspendThumbnail := 0
SuspendHotkeys := 1
Global MaxClips, Style, CLipM, FirstTime, ShowTip
ShowTip :=1
FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
;MsgBox, %NumberClip0%
Loop, %NumberClip0%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Deactivate Tip, DisableTip
Menu, BasicClipID, Icon, Deactivate Tip, Resources\2220.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
Max_Index:=ClipBoardHistory.maxIndex()
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
/*
If Iniciate=1
{
Return
}
Gosub, RButton
Return
*/
If !Iniciate=0 Gosub, RButton
Return

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF        ;selection text color
                ,"selBGColor" :  0x036FC5         ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"     ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "select"}
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"            ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69        ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9        ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"     ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "select"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
  /*
  if ( msg = "onselect" )
     {
     Rectangle:=obj.getRect()
     x:=Rectangle.right
     y:=Rectangle.top
     CoordMode, ToolTip, Screen
     Tooltip:=obj.tooltip
     tooltip %ToolTip%,%X%,%Y%
     }
*/
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        ;Tooltip:=obj.tooltip
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        ;Tooltip:=obj.tooltip
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     If FirstTime=0
        {
        FirstTime:=1
	WinSet, Transparent, 210, ahk_class #32768
        SoundPlay, Resources\Close Window.mp3
        sleep, 1000
        }
    Else
       {
       WinSet, Transparent, 210, ahk_class #32768
       SoundPlay, Resources\Close Window.mp3
       sleep, 300
       }
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
;    tooltip % "Right clicked: " obj.name
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     Loop, TempClip\Clip*.clip
     NumberClip := A_Index
     Loop %NumberClip%
       {
       If A_index=%CLipM%
        {
        break
        }
      NumberClip--
      }
     WinClip.Clear()
     ReadClip := "TempClip\Clip" NumberClip ".clip"
     FileRead, Clipboard, %ReadClip%
     FileAppend, %CLipM%: %Clipboard%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	WinClip.Clear()
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
;    ;tooltip % "Middle clicked: " obj.name
   /*
   if ( msg = "onrun" )
     {
     CLipM:=obj.id
     Gosub, PasteOne
     }
   */
   if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;    tooltip % "Item runned: " obj.name
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}

^!k::
Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
{
Ello:=ClipBoardHistory.maxindex()-Max_Index+1
Texto:=ClipBoardHistory[A_Index]
Max_Index--
MsgBox %A_index% - %Texto%
;MsgBox Ello: %Ello% Max: %Max_Index%
}
Return

^Up::
^MButton::
Max_Index:=ClipBoardHistory.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
Gosub, Style
FileDelete, TempClip.clip
WinClip.Clear()
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
while Max_Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Max_Index]
	;FullDescription:=Description
	;if(StrLen(Description)>35)
	if(StrLen(Description)>80)
	{
		toCut:=StrLen(Description)-25 
		;toCut:=StrLen(Description)-50
		;StringMid, itemTemp1, Description, 1, 12
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	if Max_Index<10
	MenuString:="   &" . (ClipBoardHistory.maxindex()-Max_Index+1) . ".   " . Description
	else
	MenuString:= "   "(ClipBoardHistory.maxindex()-Max_Index+1) . ".   " . Description
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

;WinGet, ActiveWindow , ID, A
MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu

/*
if item
{
Global Item_Select
Item_Select:=item.Max_Index
WinClip.Clear()
clipboard:=ClipBoardHistory[Item_Select]
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
Send, ^v
SoundPlay, Resources\Close Window.mp3
}
*/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  WinClip.Clear()
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Max_Index:=ClipBoardHistory.maxIndex()
WinClip.Clear()
return

PasteOne:
WinClip.Clear()
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;SendRaw %clipboard% `n
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
Send, {asc 013}
Return

/*
PasteOne:
If !Style=0
  {
  CLipM:=CLipM-2
  }
Loop, TempClip\Clip*.clip
NumberClip := A_Index
Loop %NumberClip%
  {
  If A_index=%CLipM%
   {
    break
   }
  NumberClip--
  }
clip:=ClipBoardHistory[CLipM]
;Msgbox, %NumberClip% %clip% %CLipM%
WinClip.Clear()
Clipboard:=ClipBoardHistory[NumberClip]
;Clipboard:=ClipBoardHistory[CLipM]
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Close Window.mp3
Return
*/

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  WinClip.Clear()
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
WinClip.Clear()
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   WinClip.Clear()
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 TrayTip
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
} Else {
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
{
ErrorType :=1
Gosub, ControlError
;MsgBox, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.
WinClip.Clear()
Return
}
Else 
CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, 0x1024,, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)`n`nDo you want to save the copied text to the basic clipboard?
	IfMsgBox No
	Return
	Else
	If ChangeClipEnable=1
	  {
          ClipBoardEnabled=1
          ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	If ChangeClipEnable=0
	  {
	  ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        Menu Tray, NoIcon
        Sleep 200  ; It may be necessary to adjust this sleep.
        Menu Tray, Icon
    }
}

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	;currentClipAll=%clipboardall% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip
		  TrayTip,Clipboard Message, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, MaxClips)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=clip
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	If Max_Index<=MaxClips
		{
		FileAppend, %Clip%, %ClipTemp%
		}
	if (Max_Index>MaxClips)
		{
		ClipBoardHistory.removeAt(1)
		;ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
		FileDelete, TempClip\Clip1.clip
		Loop %MaxClips%
		if !FileExist("TempClip\Clip" A_Index ".clip")
			{
			NumberFile := A_Index
		        FileSup := NumberFile+1
			Sup := "TempClip\Clip" Filesup ".clip"
			NumF:= "TempClip\Clip" NumberFile ".clip"
			Filemove, %Sup%, %NumF%
			}
			MaxFile:= "TempClip\Clip" MaxClips ".clip"
			FileAppend, %Clip%, %MaxFile%
			;FileAppend, %Clip%, TempClip\Clip15.clip
			}
}
;************************************************************************************************************************

^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
}
else
{
Style=1
}
Iniciate := 1
Gosub, Style
Return

DisableTip:
Menu, BasicClipID, ToggleCheck, Deactivate Tip
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ShowTip=1
{
ShowTip=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Tip have been Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
else
{
ShowTip=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, TIP has been Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
Iniciate := 1
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

NotifyTrayClick_201:
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
Day 26. A small change. Sometimes I make the simple complicated.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

26 Oct 2021, 12:46

Hi. New arrangements.

I hadn't noticed that the last number of the file on the basic clipboard hard drive was duplicated information. Apparently as before it was wrongly configured it didn't give any problem as I did it, but when I repaired the clipboard copy system, as it worked faster, the last file was created twice, duplicating its content. Now it has been repaired, processes have been removed, which makes it faster.

On the other hand there was a missing variable (not declared) that caused the menu to not position the clipboard keyboard shortcut (first underlined symbol) correctly. Anyway, it's not very useful, because when I hit the keyboard shortcut it just marks it, without activating the action (I have to look to see why and how to fix it).

The problem was that the clipboard menu puts the last one first (as seen in the graphic), and as I adopted the script was misconfigured because it referred to the numbering of the normal index, not the new inverse index which did not have a declared name of the variable being generated. With the declared variable I have made other arrangements.

Image

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3i"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
;ClipBoardEnabled:=1
ClipBoardEnabled=1
;ChangeClipEnable=0
previousClip=%clipboard%
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
SuspendThumbnail := 0
SuspendHotkeys := 1
Global MaxClips, Style, CLipM, FirstTime, ShowTip
ShowTip :=1
FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style := 1


if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
;MsgBox, %NumberClip0%
Loop, %NumberClip0%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Deactivate Tip, DisableTip
Menu, BasicClipID, Icon, Deactivate Tip, Resources\2220.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
Max_Index:=ClipBoardHistory.maxIndex()
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
/*
If Iniciate=1
{
Return
}
Gosub, RButton
Return
*/
If !Iniciate=0 Gosub, RButton
Return

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"}		;Other Option: ,mnemonicCMD   : "select"
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"}		;Other Option: ,mnemonicCMD   : "select"

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
  /*
  if ( msg = "onselect" )
     {
     Rectangle:=obj.getRect()
     x:=Rectangle.right
     y:=Rectangle.top
     CoordMode, ToolTip, Screen
     Tooltip:=obj.tooltip
     tooltip %ToolTip%,%X%,%Y%
     }
*/
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        ;Tooltip:=obj.tooltip
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        ;Tooltip:=obj.tooltip
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     If FirstTime=0
        {
        FirstTime:=1
	WinSet, Transparent, 210, ahk_class #32768
        SoundPlay, Resources\Close Window.mp3
	sleep, 1000
        item := menu.Show( xpos5, ypos5 )
	}
    Else
       {
       WinSet, Transparent, 210, ahk_class #32768
       SoundPlay, Resources\Close Window.mp3
       sleep, 300
       }
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
;    tooltip % "Right clicked: " obj.name
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     /*
     Loop, TempClip\Clip*.clip
     NumberClip := A_Index
     Loop %NumberClip%
       {
       If A_index=%CLipM%
        {
        break
        }
      NumberClip--
      }
     WinClip.Clear()
     ReadClip := "TempClip\Clip" NumberClip ".clip"
     ReadClip := "TempClip\Clip" Min_Index ".clip"
     FileRead, Clipboard, %ReadClip%
     FileAppend, %CLipM%: %Clipboard%`n`n, TempClip.clip
     */
     FileAppend, %CLipM%: %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	WinClip.Clear()
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
;    ;tooltip % "Middle clicked: " obj.name
   /*
   if ( msg = "onrun" )
     {
     CLipM:=obj.id
     Gosub, PasteOne
     }
   */
   if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;    tooltip % "Item runned: " obj.name
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}

^!k::
Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
{
Ello:=ClipBoardHistory.maxindex()-Max_Index+1
Texto:=ClipBoardHistory[A_Index]
Max_Index--
MsgBox %A_index% - %Texto%
;MsgBox Ello: %Ello% Max: %Max_Index%
}
Return

^Up::
^MButton::
Max_Index:=ClipBoardHistory.maxIndex()
if !Max_Index
{
SoundPlay, Resources\Close Window.mp3
MsgBox, There are Currently no Clipboards
return
}
MouseGetPos, mx, my, WinUMID
Gosub, Style
FileDelete, TempClip.clip
WinClip.Clear()
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
while Max_Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Max_Index]
	;FullDescription:=Description
	;if(StrLen(Description)>35)
	if(StrLen(Description)>80)
	{
		toCut:=StrLen(Description)-25 
		;toCut:=StrLen(Description)-50
		;StringMid, itemTemp1, Description, 1, 12
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	Global Min_Index
	Min_Index:= (ClipBoardHistory.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . (ClipBoardHistory.maxindex()-Max_Index+1) . ".   " . Description
	else
	  MenuString:= "   "(ClipBoardHistory.maxindex()-Max_Index+1) . ".   " . Description
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

;WinGet, ActiveWindow , ID, A
MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu

/*
if item
{
Global Item_Select
Item_Select:=item.Max_Index
WinClip.Clear()
clipboard:=ClipBoardHistory[Item_Select]
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
Send, ^v
SoundPlay, Resources\Close Window.mp3
}
*/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  WinClip.Clear()
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Max_Index:=ClipBoardHistory.maxIndex()
WinClip.Clear()
return

PasteOne:
WinClip.Clear()
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;SendRaw %clipboard% `n
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
Send, {asc 013}
Return

/*
PasteOne:
If !Style=0
  {
  CLipM:=CLipM-2
  }
Loop, TempClip\Clip*.clip
NumberClip := A_Index
Loop %NumberClip%
  {
  If A_index=%CLipM%
   {
    break
   }
  NumberClip--
  }
clip:=ClipBoardHistory[CLipM]
;Msgbox, %NumberClip% %clip% %CLipM%
WinClip.Clear()
Clipboard:=ClipBoardHistory[NumberClip]
;Clipboard:=ClipBoardHistory[CLipM]
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Close Window.mp3
Return
*/

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
;WinWaitActive, ahk_id %WinUMID%
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  WinClip.Clear()
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
WinClip.Clear()
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   WinClip.Clear()
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 TrayTip
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
}
/*Else {
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500
*/

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
   {
   ErrorType :=1
   Gosub, ControlError
   WinClip.Clear()
   Return
   }
Else 
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
 SetTimer, HideTrayTip, -1500

CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, 0x1024,, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)`n`nDo you want to save the copied text to the basic clipboard?
	IfMsgBox No
	Return
	Else
	If ChangeClipEnable=1
	  {
          ClipBoardEnabled=1
          ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	If ChangeClipEnable=0
	  {
	  ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        Menu Tray, NoIcon
        Sleep 200  ; It may be necessary to adjust this sleep.
        Menu Tray, Icon
    }
}

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	;currentClipAll=%clipboardall% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip
		  TrayTip, Basic Clipboard Message, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, MaxClips)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=clip
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	;ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	  {
	  NumberFile := A_Index
	  FileSup := NumberFile+1
	  Sup := "TempClip\Clip" Filesup ".clip"
	  NumF:= "TempClip\Clip" NumberFile ".clip"
	  FileMove, %Sup%, %NumF%
	  }
	}
}
;************************************************************************************************************************

^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
}
else
{
Style=1
}
Iniciate := 1
Gosub, Style
Return

DisableTip:
Menu, BasicClipID, ToggleCheck, Deactivate Tip
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ShowTip=1
{
ShowTip=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Tip have been Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
else
{
ShowTip=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, TIP has been Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
Iniciate := 1
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

NotifyTrayClick_201:
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
And the next script is from the basic isolated clipboard. The libraries (https://apathysoftworks.com/ahk/index.htmland file it calls are in the last shared file above.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip
ShowTip :=1
FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style=1

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  FileDelete, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  }
}

;Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"}		;Other Option: ,mnemonicCMD   : "select" 
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"}		;Other Option: ,mnemonicCMD   : "select"
                
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     If FirstTime=0
        {
        FirstTime:=1
	WinSet, Transparent, 210, ahk_class #32768
        SoundPlay, Resources\Close Window.mp3
	sleep, 1000
        item := menu.Show( xpos5, ypos5 )
	}
    Else
       {
       WinSet, Transparent, 210, ahk_class #32768
       SoundPlay, Resources\Close Window.mp3
       sleep, 300
       }
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
;    tooltip % "Right clicked: " obj.name
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %CLipM%: %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;    tooltip % "Item runned: " obj.name
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}

^Up::
^MButton::
Max_Index:=ClipBoardHistory.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
while Max_Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Max_Index]
	if(StrLen(Description)>80)
	{
		toCut:=StrLen(Description)-25 
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	Global Min_Index
	Min_Index:= (ClipBoardHistory.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . (ClipBoardHistory.maxindex()-Max_Index+1) . ".   " . Description
	else
	  MenuString:= "   "(ClipBoardHistory.maxindex()-Max_Index+1) . ".   " . Description
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return

PasteOne:
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
Send, {asc 013}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

HideTrayTip:
TrayTip
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
		previousClip=%clipboard%
		If NotifyClip=1
		  {
		  TrayTip
		  TrayTip, Basic Clipboard Message, %currentClip%
		  SoundPlay, Close Window.mp3
		  SetTimer, HideTrayTip, -1000
		  }
		ClipSave(ClipBoardHistory,currentclip, MaxClips)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=clip
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}
Reeditated. Fixed the keyboard shortcut issue in the menu. Now when you press 1 to 9 on the keyboard (see graphic above), when the menu is visible, the corresponding clipboard is pasted.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

27 Oct 2021, 10:26

Maybe this thread should go in the Scripts and Functions section (or this post), I leave it up to the moderators.

In the basic clipboard TrayTip messages are annoying, because they are system-dependent and can crash, regardless of whether you try to control the time. In the following script the messages are generated by a function (CornerNotify, source: http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/) that shows a translucent gui (with a clipboard clipping). It is more elegant, less intrusive and generates fewer problems than the system's TrayTip.


Image

Another small fix is that it no longer deletes and recreates the clipboards saved on the hard drive, when it starts.

I have added the ability to view the current clipboard with the F5 key.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1


Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
ShowTip :=1
FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style=1


if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  }
DisableWrite:=0
}

;Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     If FirstTime=0
        {
        FirstTime:=1
	WinSet, Transparent, 210, ahk_class #32768
        SoundPlay, Resources\Close Window.mp3
	sleep, 800
        item := menu.Show( xpos5, ypos5 )
	}
    Else
       {
       WinSet, Transparent, 210, ahk_class #32768
       SoundPlay, Resources\Close Window.mp3
       sleep, 300
       }
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
;    tooltip % "Right clicked: " obj.name
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %CLipM%: %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;    tooltip % "Item runned: " obj.name
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}

^Up::
^MButton::
Max_Index:=ClipBoardHistory.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
while Max_Index>=ClipBoardHistory.minIndex()
{
	Description:=ClipBoardHistory[Max_Index]
	if(StrLen(Description)>80)
	{
		toCut:=StrLen(Description)-25 
		StringMid, itemTemp1, Description, 1, 50
		StringTrimLeft, itemTemp2, Description, %toCut% 
		Description=%itemTemp1%...%itemTemp2% 
	} 
	Global Min_Index
	Min_Index:= (ClipBoardHistory.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Description
	else
	  MenuString:= "   " Min_Index . ".   " . Description
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard  ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return

PasteOne:
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
Send, {asc 013}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip := ""
    MaxLen := 36
    TipLen := StrLen(CutTooTip)
    LastChar := 1
    Loop
     {
     If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	currentClip=%clipboard% 
	If (A_EventInfo=1) and (currentClip <> previousClip)
	{
	  previousClip=%clipboard%
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", previousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, previousClip, 1, 100
		    CutTip := ""
		    MaxLen := 36
		    TipLen := StrLen(CutTooTip)
		    LastChar := 1
		    Loop
		     {
		     If (LastChar >= TipLen)
	             Break
                     CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
                     LastChar += MaxLen
                     }
		  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }   
	ClipSave(ClipBoardHistory,currentclip, MaxClips)	
	}
	}
Return

ClipSave(ClipBoardHistory,clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=clip
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}
;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------
All necessary files: https://mega.nz/file/4JImFBSI#d4QqFkD_2hB7nC497ub7dOybieOg2U_iyBtAEr-6Dtw
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Multiple clipboard, with title and URL of web page

27 Oct 2021, 12:21

Hi!
wetware05 wrote:
27 Oct 2021, 10:26
Maybe this thread should go in the Scripts and Functions section...
I was going to propose the same too!
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

28 Oct 2021, 13:17

Hi. rommmcek. See if you can help me with this.

I'm working in isolation with the basic clipboard, and then implementing it optimized in the main script.

When the clipboard menu is generated, (as it was before I worked on it) I trimmed the text from the clipboards so that they all had the same formatting and the menu always kept the same size.

The process is quite fast, I isolated it to see its processing time. But I think it is that time that makes the presentation of the menu with transparency vulnerable and erratic.

The following script creates that snippet every time something is copied to the clipboard and now the menu only presents the snipped clipboards. This speeds up the process of displaying the menu. Now you no longer have a timeout (if anyone has problems you can remove the semicolon from line 140).

Here comes the question I want to raise. I think that Autohotkey's help in certain subjects is written with those who know other programming languages in mind, and it is impossible for those who don't know programming (or very intelligent people, I don't know, I recognize that I have problems with learning, partly because of my dyslexia and that I am somewhat hyperactive) to learn from such help. That is the case of creating arrays and working with them.

So. What I've done in this script is to copy how HCapitan (https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/) programmed an array (or an object, I don't know, I'm lost in this language), into a new array (or object), which maybe should go together. In practice they are generated at the same time and share the same index. As they are not "together" I can't work them inside the function that saves the clipboards, I create a gosub to work in parallel to the function (which I don't think is the best thing to do).

Anyway, it works fine now. I'm going to try to remove the function and make it all part of the same process. I think it would be faster and more optimal, but I would still have the same problem of two different objects that should be in the same array.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style=1

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  }
DisableWrite:=0
}

If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return
;**************************************************************
PasteOne:
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip := ""
    MaxLen := 36
    TipLen := StrLen(CutTooTip)
    LastChar := 1
    Loop
     {
     If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip := ""
		    MaxLen := 36
		    TipLen := StrLen(CutTooTip)
		    LastChar := 1
		    Loop
		     {
		     If (LastChar >= TipLen)
	             Break
                     CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
                     LastChar += MaxLen
                     }
		  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2% 
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------
User avatar
rommmcek
Posts: 1470
Joined: 15 Aug 2014, 15:18

Re: Multiple clipboard, with title and URL of web page

29 Oct 2021, 08:45

I think that Autohotkey's help in certain subjects is written with those who know other programming languages...
I agree!
I'm amateur too, but as far as I know in Ahk Array is Object.
Here is simple example if it can help you, otherwise ask again...

Code: Select all

arr1:= [1, 2]
arr2:= [3, 4]
arr3:= [arr1, arr2]
arrDuplicat:= arr3


pa(arr3)
pa(arrDuplicat)


; Auxiliary functions
txtArr(r, i:="  ", d:=0, b:="") {
	For k, v in (r, IsObject(r)? "": e:= 1)
		c.= IsObject(v)? b k ":`n" txtArr(v, i, d+1, b i): b k ": " v "`n", d>0? "": t:=c
    Return e? r: d>0? c: t
}
pa(in) {
    MsgBox % txtArr(in)
}
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

29 Oct 2021, 15:48

Thanks rommmcek, I'll leave it as it is for now, because it's working fine.

The main script with the new changes. I have fixed (in the main interface) that the copy to clipboard button was not working (in the graph the middle interface, the second button from the right) , and I have added the possibility to copy the text from the main clipboard to the basic clipboard even if it is disabled (in the graph the middle interface, the first button from the right — holding down the Control key and click. Only click paste is text.).

Image

I've changed the text trimming function for the basic clipboard's tiptool and warning window display to a better function that doesn't trim words.

Main clipboard (includes basic):

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

Name := "Clipboard Utility - "
Version := "4.3i"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
ClipBoardEnabled:=1
;ChangeClipEnable=0
previousClip:=clipboard
NotifyClip := 1 
CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
SuspendThumbnail := 0
SuspendHotkeys := 1
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style := 1


if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  }
DisableWrite:=0
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Deactivate Tip, DisableTip
Menu, BasicClipID, Icon, Deactivate Tip, Resources\2220.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=1
Max_Index:=ClipBoardHistory.maxIndex()
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
/*
If Iniciate=1
{
Return
}
Gosub, RButton
Return
*/
If !Iniciate=0 Gosub, RButton
Return

;Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800        
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip	
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }     
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return

;**************************************************************
PasteOne:
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 TrayTip
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
}
/*Else {
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500
*/

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
   {
   ErrorType :=1
   Gosub, ControlError
   WinClip.Clear()
   Return
   }
Else 
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
 SetTimer, HideTrayTip, -1500

CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, 0x1024,, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)`n`nDo you want to save the copied text to the basic clipboard?
	IfMsgBox No
	Return
	Else
	If ChangeClipEnable=1
	  {
          ClipBoardEnabled=1
          ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	If ChangeClipEnable=0
	  {
	  ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        Menu Tray, NoIcon
        Sleep 200  ; It may be necessary to adjust this sleep.
        Menu Tray, Icon
    }
}

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
StringTrimLeft, TextPlane, a_guicontrol, 6
GetKeyState, state, Control
if (state = "D") and ClipBoardEnabled:=1
 {
 WinClip.Clear()
 htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
 Clipboard = %htmlPl%
 SoundPlay, Resources\Clipboard_Sound.mp3
 Return
 }
if (state = "D") and ClipBoardEnabled:=0
 {
 WinClip.Clear()
 htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
 Clipboard = %htmlPl%
 ClipSave(ClipBoardHistory,Clipboard, MaxClips)
 SoundPlay, Resources\Clipboard_Sound.mp3
 Return
 }
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

/*
TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
*/

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMenu:
Menu Case, Add
Menu Case, DeleteAll
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &a Title to Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Case, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
}
else
{
Style=1
}
Iniciate := 1
;Gosub, Style
Return

DisableTip:
Menu, BasicClipID, ToggleCheck, Deactivate Tip
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ShowTip=1
{
ShowTip=0
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Tip have been Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
else
{
ShowTip=1
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, TIP has been Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
Iniciate := 1
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

!F5::
NotifyTrayClick_201:
SoundPlay, Resources\Close Window.mp3
  if(StrLen(previousClip)<50)
   {
   CornerNotify(1, "Basic Clipboard", PreviousClip)
   } 
   Else
    {
    StringMid, CutTooTip, PreviousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
   }
Return

/*
^!F7::
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
*/

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
		  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2% 
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}
Basic Clipboard:

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style=1

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  }
DisableWrite:=0
}

If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        CutTip:= st_wordWrap(CutTooTip)
	;Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	;Gosub, CutWidthTip
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return
;**************************************************************
PasteOne:
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%	  
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
                  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2% 
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}
Happy halloween :twisted: I think I'm going to take a break.

Reissued on the 30th. There was a repeated process in the main clipboard: the one to show the current clipboard (error when doing copy/paste from the basic clipboard script). The current clipboard is displayed by clicking on the utility icon button (on the trayicon), or with the keyboard shortcut Alt+F5.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

30 Oct 2021, 13:17

Hi.

I have added in the basic clipboard the ability to not copy duplicates. Why? If it is a clipboard with only a few items (15, can be changed to more on line 29), it is desirable that it is not repeated content.

On the one hand it prevents that the last item is the same as the previous one, that was already implemented (it's basic), but now it looks for equal items, and deletes the oldest ones, because it is assumed that we don't remember that we already have them in the clipboard and we want the new item to be at the top of the menu.

The process is carried out with the help of a library. I made a first script that deleted equal elements by the description (the short text that appears in the menu), but in a long text, if they were equal, but one contained "love". and another "hate" (the two four-letter ones) the description was the same. How many times can it happen like this, I think few, but I opted for a safer method.

The library creates a CRC32 code and the script I have created looks for no two CRCs to be the same, deleting the oldest one. It's all done in memory (virtually), but they have to be matched with the saved files.

Thank you very much to all those who create functions that we are going to use all. :clap: :thumbup:

------

Another topic.

From what I see, and I'm learning, I use three arrays, one for the clipboards, one for the descriptions and one for the CRC32 codes. I was looking for an associative array of type Array(Clipboard, Description, CRC32), but I don't know how to handle them and I would also have to modify the function that is the core of the clipboards... Very complicated, for the moment the script stays as it is, until I learn more.

The library can be downloaded from here: https://github.com/ahkscript/libcrypt.ahk/. Expand the "Code" button and click on the "Download ZIP" option. You have to copy the file "libcrypt.ahk" in the "Resources" directory. The rest of the files is here: https://mega.nz/file/4JImFBSI#d4QqFkD_2hB7nC497ub7dOybieOg2U_iyBtAEr-6Dtw

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
#Include Resources\libcrypt.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style=1

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip
  }
DisableWrite:=0
}

If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        CutTip:= st_wordWrap(CutTooTip)
	;Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	;Gosub, CutWidthTip
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg ~= "onclose" )
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility"
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return
;**************************************************************
PasteOne:
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%	  
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
                  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	CRCClip:=LC_CRC32(Currentclip)
	Gosub, DuplicateCRC
	CRC32.insert(Object())
        Max_CRC:=CRC32.MaxIndex()
	CRC32[Max_CRC]:=CRCClip
	if (Max_CRC>MaxClips)
	  {
	  CRC32.removeAt(1)
	  }
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2%
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  ;DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

DuplicateCRC:
;Max_CRC:=CRC32.MaxIndex()
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  FileDelete, TempClip\Clip%XClip%.clip
Loop, %MaxClips%
  if !FileExist("TempClip\Clip" A_Index ".clip")
     {
     NumberClip := A_Index
     ClipSup := NumberClip+1
     Sup2 := "TempClip\Clip" ClipSup ".clip"
     NumF2:= "TempClip\Clip" NumberClip ".clip"
     FileMove, %Sup2%, %NumF2%
     }
}
Return

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}
Important!!! You have to delete the current files from the "TempClip" directory, because if there are several duplicates the script will not work well. Try tests before trusting that new options do what they have to do.

Edited Day 1. I forgot to include the deleting the first CRC32 when it reaches 15.
Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Multiple clipboard, with title and URL of web page

31 Oct 2021, 00:14

Awesome piece of software.

I'm a bit overwhelmed about it, to be honest I didn't read whole thread, I just execute it and I'm lost LOL, I would spend some time on it to learn the basic. On this topic, I would like to suggest some instructions at the beginning of the main file, shortcuts to use, and a few basic things. I know you are doing changes so it is imposible to build a detailed and synchronized help file, I don't need it.

It Would be cool that everything goes into a Database. I have seeen that Autohotkey can handle database easily and I think it would simplify a lot with files, sessions and so on. Sinces it is a big rework, I would understand you don't want to do it, but I would like to know your thoughts.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

31 Oct 2021, 09:11

Hi Lepes. Thank you for your encouragement.

I did think about using a database, but I haven't found any help on how to do it. I searched for just one day, but didn't come up with any posts that gave guidance on that purpose. They only gave the option to use Jason. I'm used to MySQL.

I have pending to make a video with the basic functionality. I just hope everything is stable. I still need to check new possible bugs, because adding new possibilities creates conflicts that I don't always notice.

It all started by wanting to automate (Autohotkey's specialization) pasting several HTML content snippets into one and it was based on keyboard shortcuts, but I've been complicating it. Making it complicated, or complex, is not always the best thing for the software. The basic clipboard is simple.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

01 Nov 2021, 16:09

Hi.
A small addition to the basic clipboard.

A submenu containing common texts that you want to keep handy for pasting. It is intended for short texts.
You have to create a file called "Favorites.fav". which will be saved in the directory "\TempClip", if it does not exist or is not created the program will not give error. The submenu will only be created if the file exists. Each text will occupy one line, followed by of a line break (enter key).
The file format, if you want to have symbols like in the example, has to be "unicode".
Image

(This add-on can be used to split clipboards into two parts, of 15 entries each, for example. Changes would have to be made to what paste.)

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
#Include Resources\libcrypt.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 15
Style=1

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip
  }
DisableWrite:=0
}

If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        CutTip:= st_wordWrap(CutTooTip)
	;Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	;Gosub, CutWidthTip
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     WinSet, Transparent, 210, ahk_class #32768
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     ;MsgBox, %ClipTool% - %Favorite%
     Global ClipTool, Favorite
     ClipTool:=obj.tooltip
     Favorite:=obj.name
     ;Favorite:=item.name
     ;Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg = "onshow" ) ; ~=
;    tooltip % "menu " msg ": " obj.handle
   if ( msg = "onclose" ) ; ~=
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
Global WinUMID, mx, my
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
newmenu1 := pm.CreateMenu( menuParams1 )
If Style=1
{
menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
menu.Add()
}
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

if FileExist("TempClip\Favorites.fav")
{
Loop, read, TempClip\Favorites.fav
{
newmenu1.add( { "name" : A_LoopReadLine, "noicons": 1, "bold": 1} )
;newmenu1.add( { "name" : A_LoopReadLine , "noicons": 1, "bold": 1, "tooltip" : A_LoopReadLine} )
}
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return
;**************************************************************

PasteOne:
If !ClipTool
{
Clipboard:=""
Clipboard:=Favorite
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Else
{
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%	  
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
                  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	CRCClip:=LC_CRC32(Currentclip)
	Gosub, DuplicateCRC
	CRC32.insert(Object())
        Max_CRC:=CRC32.MaxIndex()
	CRC32[Max_CRC]:=CRCClip
	if (Max_CRC>MaxClips)
	  {
	  CRC32.removeAt(1)
	  }
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	;CRC32.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2%
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  ;DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

DuplicateCRC:
;Max_CRC:=CRC32.MaxIndex()
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  FileDelete, TempClip\Clip%XClip%.clip
  Gosub, RelocateFile
}
Return

RelocateFile:
Loop, %MaxClips%
  if !FileExist("TempClip\Clip" A_Index ".clip")
     {
     NumberClip := A_Index
     ClipSup := NumberClip+1
     Sup2 := "TempClip\Clip" ClipSup ".clip"
     NumF2:= "TempClip\Clip" NumberClip ".clip"
     FileMove, %Sup2%, %NumF2%
     }
Return

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}
I think it goes without saying not to use such a this file to store passwords.
Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Multiple clipboard, with title and URL of web page

02 Nov 2021, 08:56

Currently DBA supports SQLite, MySQL and ADO
Source: https://www.autohotkey.com/board/topic/71179-ahk-l-dba-16-oop-sql-database-sqlite-mysql-ado/d/topic/71179-ahk-l-dba-16-oop-sql-database-sqlite-mysql-ado/
https://github.com/IsNull/ahkDBA

Hope it helps. It comes with an example, but I don't have installed DB engine.

Thank you for your work!
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

03 Nov 2021, 14:55

Hi.
Some changes in the direction of creating a utility configuration interface. Starting the following script will create a file. ini which will contain the options that can be toggled in the start menu (show Tip, disable keyboard shortcuts, disable basic clipboard...). With this procedure the utility will "remember" the status of the previous session. In the menu I have added the possibility to restore all settings to default. I've also added the ability to change the limit number of the basic clipboard (it's in the "Basic Clipboard" submenu).

I've added the latest updates to the basic clipboard from the previous two posts.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
#Include Library\libcrypt.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

if !FileExist("Config.ini")
  {
  IniWrite, 1, Config.ini, Setting_Clipboard, Style
  IniWrite, 1, Config.ini, Setting_Clipboard, ShowTip
  IniWrite, 1, Config.ini, Setting_Clipboard, SuspendHotkeys
  IniWrite, 0, Config.ini, Setting_Clipboard, SuspendThumbnail
  IniWrite, 1, Config.ini, Setting_Clipboard, NotifyClip
  IniWrite, 15, Config.ini, Setting_Clipboard, MaxClips
  IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
  }

IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

Name := "Clipboard Utility - "
Version := "4.4a"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
;ClipBoardEnabled:=1
;ChangeClipEnable=0
previousClip:=clipboard
;NotifyClip := 1 
;CorpusCount := 0
DirectoryCount := 0
Iniciate := 0
PDFCount := 0
WordCount := 0
NumberTemp := 1
;SuspendThumbnail := 0
;SuspendHotkeys := 1
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
;ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
;MaxClips := 15
;Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip
  }
DisableWrite:=0
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add, Restore Default Settings, RestoreSettings
Menu, Tray, Icon, Restore Default Settings, Resources\1609.ico
Menu, Tray, Add
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Maximum Number of Clipboards: %MaxClips%, MaxClipsGui
Menu, BasicClipID, Icon, Maximum Number of Clipboards: %MaxClips%, Resources\2084.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, BasicClipID, Add, Deactivate Tip, DisableTip
Menu, BasicClipID, Icon, Deactivate Tip, Resources\2220.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

;****************************************************************************
IniRead, Style, Config.ini, Setting_Clipboard, Style
  If Style=0
  {
  Menu, BasicClipID, ToggleCheck, Switch to Simple Style
  }
IniRead, ShowTip, Config.ini, Setting_Clipboard, ShowTip
  If ShowTip=0
  {
  Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
  }
IniRead, SuspendHotkeys, Config.ini, Setting_Clipboard, SuspendHotkeys
  If SuspendHotkeys=0
  {
  Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
  Hotkey, ^Up, Toggle
  Hotkey, ^F4, Toggle
  Hotkey, ^F5, Toggle
  Hotkey, !F5, Toggle
  Hotkey, ^F6, Toggle
  Hotkey, ^F7, Toggle
  Hotkey, ^F8, Toggle
  Hotkey, ^F10, Toggle
  Hotkey, ^F11, Toggle
  Hotkey, ^F12, Toggle
  }
IniRead, SuspendThumbnail, Config.ini, Setting_Clipboard, SuspendThumbnail
  If SuspendThumbnail=1
  {
  Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
  }
IniRead, NotifyClip, Config.ini, Setting_Clipboard, NotifyClip
  If NotifyClip=0
  {
  Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
  }
IniRead, ClipBoardEnabled, Config.ini, Setting_Clipboard, ClipBoardEnabled
  If ClipBoardEnabled=0
  {
  Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
  }
;****************************************************************************
; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

;**************************************** H O M E ***********************************
/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=0 ; Previo 1
Max_Index:=ClipBoardHistory.maxIndex()
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
/*
If Iniciate=1
{
Return
}
Gosub, RButton
Return
*/
If !Iniciate=0 
Gosub, RButton
Return
;**************************************** H O M E ***********************************
Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
   {
   WinSet, Transparent, 210, ahk_class #32768
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800        
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip	
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }     
     Return     
     }
   } 
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool, Favorite
     ClipTool:=obj.tooltip
     Favorite:=obj.name     
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg = "onclose" ) ; ~=
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
  {
  MsgBox, There are Currently no Clipboards
  SoundPlay, Resources\Close Window.mp3
  return
  }
Global WinUMID, mx, my
MouseGetPos, mx, my, WinUMID
Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
  {
  ClipBoardEnabled:=0
  ChangeClipEnable=1
  }
menu := pm.CreateMenu( menuParams1 )
newmenu1 := pm.CreateMenu( menuParams1 )

If Style=1
  {
  menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
  menu.Add()
if FileExist("TempClip\Favorites.fav")
  {
    Loop, read, TempClip\Favorites.fav
    {
    newmenu1.add( { "name" : A_LoopReadLine, "noicons": 1, "bold": 1} )
    ;newmenu1.add( { "name" : A_LoopReadLine , "noicons": 1, "bold": 1, "tooltip" : A_LoopReadLine} )
    }
  }
 }
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return

;**************************************************************
PasteOne:
If !ClipTool
{
Clipboard:=""
Clipboard:=Favorite
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Else
{
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 TrayTip
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
}
/*Else {
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500
*/

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
   {
   ErrorType :=1
   Gosub, ControlError
   WinClip.Clear()
   Return
   }
Else 
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
 SetTimer, HideTrayTip, -1500

CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, 0x1024,, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)`n`nDo you want to save the copied text to the basic clipboard?
	IfMsgBox No
	Return
	Else
	If ChangeClipEnable=1
	  {
          ClipBoardEnabled=1
	  CRCClip:=LC_CRC32(Clipboard)
	  Gosub, DuplicateCRC
	  CRC32.insert(Object())
          Max_CRC:=CRC32.MaxIndex()
	  CRC32[Max_CRC]:=CRCClip	  
	  if (Max_CRC>MaxClips)
	     {
	     CRC32.removeAt(1)
	     }
          ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	If ChangeClipEnable=0
	  {
	  CRCClip:=LC_CRC32(Clipboard)
	  Gosub, DuplicateCRC
	  CRC32.insert(Object())
          Max_CRC:=CRC32.MaxIndex()
	  CRC32[Max_CRC]:=CRCClip	  
	  if (Max_CRC>MaxClips)
	     {
	     CRC32.removeAt(1)
	     }
	  ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
Gui, ContextClip: Destroy
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" MyEdit "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
Gui, ContextClip1: Destroy
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        Menu Tray, NoIcon
        Sleep 200  ; It may be necessary to adjust this sleep.
        Menu Tray, Icon
    }
}

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
StringTrimLeft, TextPlane, a_guicontrol, 6
GetKeyState, state, Control
if (state = "D") and ClipBoardEnabled:=1
 {
 WinClip.Clear()
 htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
 Clipboard := %htmlPl%
 /*
 CRCClip:=LC_CRC32(Clipboard)
 Gosub, DuplicateCRC
 CRC32.insert(Object())
 Max_CRC:=CRC32.MaxIndex()
 CRC32[Max_CRC]:=CRCClip	  
  if (Max_CRC>MaxClips)
     {
     CRC32.removeAt(1)
     }
  */
 SoundPlay, Resources\Clipboard_Sound.mp3
 Return
 }
if (state = "D") and ClipBoardEnabled:=0
 {
 WinClip.Clear()
 htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
 Clipboard = %htmlPl%
 ClipSave(ClipBoardHistory,Clipboard, MaxClips)
 SoundPlay, Resources\Clipboard_Sound.mp3
 Return
 }
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

/*
TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
*/

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMays:
Menu Mays, Add
Menu Mays, DeleteAll
Menu Mays, Add, &UPPERCASE, CCase
Menu Mays, Add, &lowercase, CCase
Menu Mays, Add, &Title Case, CCase
Menu Mays, Add, &a Title to Case, CCase
Menu Mays, Add, &Sentence case, CCase
Menu Mays, Add
Menu Mays, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Mays, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

MaxClipsGui:
Gui, MxClips: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, MxClips: Font, S10 Bold, Verdana
Gui, MxClips: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, MxClips: Add, Text, cYellow BackgroundTrans x35 y6 W290 h32 GuiMove, Maximum Number of Clipboards
;Gui, MxClips: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, MxClips: Font, S12 Bold, Verdana
Gui, MxClips: Add, Edit, x55 y38 vMaxClipsS%NumberTemp% h28 w168, %MaxClips%
Gui, MxClips: Font, S8 Bold, Verdana
Gui MxClips: Add, Button, x55 y72 w70 h20 gMxClipsSave, OK
Gui MxClips: Add, Button, x153 y72 w70 h20 gClipCancel, Cancel
xClips := Floor((A_ScreenWidth/2)-448)
yClips := Floor((A_ScreenHeight/2)-200)
Gui, MxClips: Show, x%xClips% y%yClips% w290
Return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

MxClipsSave:
Gui, MxClips: Submit
MaxTemp:=MaxClipsS%NumberTemp%
MaxClips=%MaxTemp%
IniWrite, %MaxTemp%, Config.ini, Setting_Clipboard, MaxClips
NumberTemp++
MaxTemp:=
MaxClips:=
Return

ClipCancel:
Gui, Session: Submit
Gui, MxClips:Destroy
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, !F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
IniWrite, 0, Config.ini, Setting_Clipboard, SuspendHotkeys
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, !F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
IniWrite, 1, Config.ini, Setting_Clipboard, SuspendHotkeys
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
IniWrite, 1, Config.ini, Setting_Clipboard, SuspendThumbnail
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
IniWrite, 0, Config.ini, Setting_Clipboard, SuspendThumbnail
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
IniWrite, 0, Config.ini, Setting_Clipboard, ClipBoardEnabled
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
IniWrite, 1, Config.ini, Setting_Clipboard, NotifyClip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
IniWrite, 0, Config.ini, Setting_Clipboard, NotifyClip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

RestoreSettings:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Restore All Values to Default? `n`n (The Application will Restart)
IfMsgBox No
Return
IniWrite, 1, Config.ini, Setting_Clipboard, Style
IniWrite, 1, Config.ini, Setting_Clipboard, ShowTip
IniWrite, 1, Config.ini, Setting_Clipboard, SuspendHotkeys
IniWrite, 0, Config.ini, Setting_Clipboard, SuspendThumbnail
IniWrite, 1, Config.ini, Setting_Clipboard, NotifyClip
IniWrite, 15, Config.ini, Setting_Clipboard, MaxClips
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
Reload
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
IniWrite, 0, Config.ini, Setting_Clipboard, Style
}
else
{
Style=1
IniWrite, 1, Config.ini, Setting_Clipboard, Style
}
Iniciate := 1
Gosub, Style
Return

DisableTip:
Menu, BasicClipID, ToggleCheck, Deactivate Tip
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ShowTip=1
{
ShowTip=0
IniWrite, 0, Config.ini, Setting_Clipboard, ShowTip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Tip have been Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
else
{
ShowTip=1
IniWrite, 1, Config.ini, Setting_Clipboard, ShowTip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, TIP has been Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
Iniciate := 1
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

!F5::
NotifyTrayClick_201:
SoundPlay, Resources\Close Window.mp3
  if(StrLen(previousClip)<50)
   {
   CornerNotify(1, "Basic Clipboard", PreviousClip)
   } 
   Else
    {
    StringMid, CutTooTip, PreviousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
   }
Return

/*
^!F7::
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
*/

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
		  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	CRCClip:=LC_CRC32(Currentclip)
	Gosub, DuplicateCRC
	CRC32.insert(Object())
        Max_CRC:=CRC32.MaxIndex()
	CRC32[Max_CRC]:=CRCClip
	if (Max_CRC>MaxClips)
	  {
	  CRC32.removeAt(1)
	  }
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	  {
	  ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	  FileAppend, %Clip%, %ClipTemp%
	  }
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2% 
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  ;DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}

DuplicateCRC:
;Max_CRC:=CRC32.MaxIndex()
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  FileDelete, TempClip\Clip%XClip%.clip
  Gosub, RelocateFile
}
Return

RelocateFile:
Loop, %MaxClips%
  if !FileExist("TempClip\Clip" A_Index ".clip")
     {
     NumberClip := A_Index
     ClipSup := NumberClip+1
     Sup2 := "TempClip\Clip" ClipSup ".clip"
     NumF2:= "TempClip\Clip" NumberClip ".clip"
     FileMove, %Sup2%, %NumF2%
     }
Return
(If you want to change the default clipboard limit, change line 31 and 2852.)

Re-edited: I forgot to change an icon. And you have to download "libcrypt.ahk" from https://github.com/ahkscript/libcrypt.ahk/ and copy it to the Library directory.
Last edited by wetware05 on 03 Nov 2021, 15:12, edited 1 time in total.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

03 Nov 2021, 14:58

Thank you Lepes. I'll look into it. :thumbup:
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

04 Nov 2021, 15:26

Hi.

Rectified some mistakes in yesterday's changes. Problems due to the typical Copy/paste and not verifying if what was pasted was correct.

Fixed other small errors.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
;EnvSet, SD, %A_ScriptDir%

#Include Library\WinClipAPI.ahk
#Include Library\WinClip.ahk
#Include Library\ViewHtml.ahk
#Include Library\Gdip_All_1.45.ahk
#Include Library\PUM_API.ahk
#Include Library\PUM.ahk
#Include Library\libcrypt.ahk
;#Include Library\ToolTipEx.ahk
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

if !FileExist("Config.ini")
  {
  IniWrite, 1, Config.ini, Setting_Clipboard, Style
  IniWrite, 1, Config.ini, Setting_Clipboard, ShowTip
  IniWrite, 1, Config.ini, Setting_Clipboard, SuspendHotkeys
  IniWrite, 0, Config.ini, Setting_Clipboard, SuspendThumbnail
  IniWrite, 1, Config.ini, Setting_Clipboard, NotifyClip
  IniWrite, 15, Config.ini, Setting_Clipboard, MaxClips
  IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
  }

IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

Name := "Clipboard Utility - "
Version := "4.4a"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
;ClipBoardEnabled:=1
;ChangeClipEnable=0
previousClip:=clipboard
;NotifyClip := 1 
;CorpusCount := 0
DirectoryCount := 0
Iniciate := 1
PDFCount := 0
WordCount := 0
NumberTemp := 1
;SuspendThumbnail := 0
;SuspendHotkeys := 1
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite
DisableWrite:=0
;ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
;MaxClips := 15
;Style := 1

if !FileExist(HTMLTemp)
{
FileCreateDir, HTMLTemp
}
if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

;Hotkey, LButton Up, off
;loop, HTMLTemp\Corpus*.html
;CorpusCount := % Floor(A_Index)

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip
  }
DisableWrite:=0
}

Menu, Tray, Icon, Resources\Scissors_Green.ico
Menu, Tray, NoStandard
Menu, tray, Add, %name% %version%, Nothing
Menu, tray, Icon, %name% %version%, Resources\Clipboard Utility.ico
Menu, Tray, Add
Menu, tray, Add, Exit                 , Exit
Menu, tray, Icon, Exit   , shell32.dll, 132
Menu, Tray, Add
Menu, Tray, Add, Help, HelpButton
Menu, Tray, Icon, Help, %A_ScriptDir%\Resources\Help.ico
Menu, Tray, Add
Menu Tray, Add, Open Info, Tray_Open
Menu Tray, Icon, Open Info, %A_ScriptDir%\Resources\Info.ico
Menu, tray, Add, &Reload this Script  , Reloaded
Menu, tray, Icon,&Reload this Script  , %A_ScriptDir%\Resources\2488.ico
Menu, tray, Add, &Edit this Script    , EditScript
Menu, tray, Icon,&Edit this Script    , comres.dll, 7
Menu, tray, Add 
Menu, tray, Add, &Suspend Clipboard Utility     , Stanby
Menu, tray, Icon,&Suspend Clipboard Utility     , %A_ScriptDir%\Resources\Scissors_Red.ico
Menu, Tray, Add, Keep Only Hotkeys Necessary, SuspendHotkeys
Menu, Tray, Icon, Keep Only Hotkeys Necessary, Resources\No_Hotkeys.ico
Menu, Tray, Add, Restore Default Settings, RestoreSettings
Menu, Tray, Icon, Restore Default Settings, Resources\1609.ico
Menu, Tray, Add
Menu, winmanagetID, Add, Clipboard Window Extended, RButtonAlt
Menu, winmanagetID, icon, Clipboard Window Extended, %A_ScriptDir%\Resources\162.ico
Menu, winmanagetID, Add, Clipboard Window Reduced, ReducedAlt
Menu, winmanagetID, icon, Clipboard Window Reduced, %A_ScriptDir%\Resources\Clipboard Utility.ico
Menu, winmanagetID, Add, Utility Window, WUtil
Menu, winmanagetID, icon, Utility Window, %A_ScriptDir%\Resources\75a.ico
Menu, winmanagetID, Add, Copy Clipboard Window, CopyGui
Menu, winmanagetID, icon, Copy Clipboard Window, Resources\Clipboard Utility 5.ico
Menu, Tray, add, Window Management, :winmanagetID
Menu, tray, Icon,  Window Management, %A_ScriptDir%\Resources\2036.ico
Menu, BasicClipID, Add, Maximum Number of Clipboards: %MaxClips%, MaxClipsGui
Menu, BasicClipID, Icon, Maximum Number of Clipboards: %MaxClips%, Resources\2084.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Disable Basic Clipboard, SuspendBasicClip
Menu, BasicClipID, Icon, Disable Basic Clipboard, Resources\Clipboard Utility 4.ico
Menu, BasicClipID, Add, Deactivate Notifications in Tray, SuspendNotifClip
Menu, BasicClipID, Icon, Deactivate Notifications in Tray, Resources\No_Sound.ico
Menu, BasicClipID, Add, Switch to Simple Style, SwitchStyle
Menu, BasicClipID, Icon, Switch to Simple Style, Resources\1005.ico
Menu, BasicClipID, Add, Deactivate Tip, DisableTip
Menu, BasicClipID, Icon, Deactivate Tip, Resources\2220.ico
Menu, BasicClipID, Add
Menu, BasicClipID, Add, Delete all Basic Clipboard, DeleteBasic
Menu, BasicClipID, Icon, Delete all Basic Clipboard, Resources\Recycle 2.ico
Menu, Tray, Add, Basic Clipboard, :BasicClipID
Menu, Tray, Icon, Basic Clipboard, Resources\Clipboard-Blue.ico
Menu, tray, Add
Menu, Tray, Add, Save all Clipboard to PDF File, SavePDF
Menu, Tray, Icon, Save all Clipboard to PDF File, %A_ScriptDir%\Resources\PDF.ico
Menu, Tray, Add, Save all Clipboard to Word File, SaveWord
Menu, Tray, Icon, Save all Clipboard to Word File, %A_ScriptDir%\Resources\Word1.ico
Menu, Tray, Add, Extract URL's from Clipboard, URLButton
Menu, Tray, Icon, Extract URL's from Clipboard, %A_ScriptDir%\Resources\URL.ico
Menu, ThumbnailID, Add, Postpone Thumbnail Creation, SuspendThumbnail
Menu, ThumbnailID, Icon, Postpone Thumbnail Creation, %A_ScriptDir%\Resources\1908.ico
Menu, ThumbnailID, Add, Create Missing Thumbnails, CreateMissing 
Menu, ThumbnailID, Icon, Create Missing Thumbnails, %A_ScriptDir%\Resources\949.ico
Menu, Tray, Add, Thumbnail Creation, :ThumbnailID
Menu, Tray, Icon, Thumbnail Creation, %A_ScriptDir%\Resources\989.ico
Menu, DeleteID, Add, Delete Last Clipboard, DeleteLast
Menu, DeleteID, Icon, Delete Last Clipboard, %A_ScriptDir%\Resources\1892.ico
Menu, DeleteID, Add, Delete All Clipboard, DeleteAll
Menu, DeleteID, Icon, Delete All Clipboard, %A_ScriptDir%\Resources\Recycle Bin Full.ico
Menu, Tray, add, Delete Options, :DeleteID
Menu, tray, Icon,  Delete Options, %A_ScriptDir%\Resources\Recycle 3.ico
Menu, Tray, add
;**********************************************************************************************
IniRead, Style, Config.ini, Setting_Clipboard, Style
  If Style=0
  {
  Menu, BasicClipID, ToggleCheck, Switch to Simple Style
  }
IniRead, ShowTip, Config.ini, Setting_Clipboard, ShowTip
  If ShowTip=0
  {
  Menu, BasicClipID, ToggleCheck, Deactivate Tip
  }
IniRead, SuspendHotkeys, Config.ini, Setting_Clipboard, SuspendHotkeys
  If SuspendHotkeys=0
  {
  Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
  Hotkey, ^Up, Toggle
  Hotkey, ^F4, Toggle
  Hotkey, ^F5, Toggle
  Hotkey, !F5, Toggle
  Hotkey, ^F6, Toggle
  Hotkey, ^F7, Toggle
  Hotkey, ^F8, Toggle
  Hotkey, ^F10, Toggle
  Hotkey, ^F11, Toggle
  Hotkey, ^F12, Toggle
  }
IniRead, SuspendThumbnail, Config.ini, Setting_Clipboard, SuspendThumbnail
  If SuspendThumbnail=1
  {
  Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
  }
IniRead, NotifyClip, Config.ini, Setting_Clipboard, NotifyClip
  If NotifyClip=0
  {
  Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
  }
IniRead, ClipBoardEnabled, Config.ini, Setting_Clipboard, ClipBoardEnabled
  If ClipBoardEnabled=0
  {
  Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
  }
;****************************************************************************
ReloadSession:
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1
FileDelete, SessionNumber.txt
;If !CorpusCount=0
 ;{
NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
;   Fileappend, %Session1% `n, SessionNumber.txt
;Menu, SessionID, add, %Session1%, LabelSessionAct1
;Menu, SessionID, Icon, 0: %Session1%, %A_ScriptDir%\Resources\2293.ico
;Menu, SessionID, add
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Empty Sessions, DeleteSessions
Menu, SessionID, Icon, Delete Empty Sessions, %A_ScriptDir%\Resources\Recycle 2.ico
Menu, SessionID, add
Menu, SessionID, add, 0:  %Session1%, LabelSessionAct1
Menu, SessionID, Icon, 0:  %Session1%, %A_ScriptDir%\Resources\2478.ico
;Menu, SessionID, add, Current Session, LabelSessionAct0
;Menu, SessionID, Icon, Current Session, %A_ScriptDir%\Resources\2478.ico
;************************************************************************
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;If FilesCount="" FilesCount=0
NameTemp := ScriptDir "HTMLTemp" A_Index "\Session.txt"
FileRead, Session1, %NameTemp%
Fileappend, %Session1% — %FilesCount% Clipboards`n, SessionNumber.txt
}
Loop, read, SessionNumber.txt
   {
   Menu, SessionID, add, %A_Index%:  %A_LoopReadLine%, LabelSession
   }
Menu, Tray, add, Clipboard Sessions, :SessionID
Menu, Tray, Icon, Clipboard Sessions, %A_ScriptDir%\Resources\2036.ico
;**********************************************************************
ReloadMenu:
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
FileDelete, SesionName.txt
If !CorpusCount=0
 {
 Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}

Loop, read, SesionName.txt
   {
   Menu, ClipboardID, add, %A_Index%:  %A_LoopReadLine%, ButtonLabelTray
   }
Menu, Tray, add, Clipboard, :ClipboardID
Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
}
Menu, Tray, Default, Basic Clipboard 
;Menu, Tray, Default, Window Management
;Menu, Tray, Tip, Clipboard Utility 4.1f
Menu, Tray, Tip, This Session has 0%CorpusCount% Clipboards

;****************************************************************************
; Menu2
Gui, CopyButtom: new
Gui, CopyButtom: -Caption +Owner
Gui, CopyButtom:Color, ffffd6
Gui, CopyButtom:Margin, 12, 12
;Gui, CopyButtom:+Owner
Gui, CopyButtom:Add, Button, x1 y1 w64 h15 gExitCopy, Exit
Gui, CopyButtom:Add, Button, x1 y17 w64 h65 hwndIcon gCopyTexClip
Gui, CopyButtom:Add, Picture, x66 y0 w12 h81 E0x200 vState0 icon1 gSubRoutine1, Resources\PauseOn.png
Gui, CopyButtom:Add, Picture, x66 y0 w14 h83 Border vState1 icon1 gSubRoutine1, Resources\PauseOff.png
GuiButtonIcon(Icon, "Resources\Clipboard Utility 5.ico", 1, "s90")

;**************************************** H O M E ***********************************
/*
if FileExist("HTMLTemp\Text1.html")
    MsgBox, 0x1034,, There are clipboards from a previous session `n`n Do you want to delete them?
IfMsgBox Yes 
Gosub, Borrado
Else
*/
GoSub, Toggle_Switch
CorpusCount := 0
;DirectoryCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
;MsgBox, %DirectoryCount%
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
threeRButton=0 ; Previo 1
Max_Index:=ClipBoardHistory.maxIndex()
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
;MsgBox, %PDFCount%
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
Return
}
If Iniciate=0
{
Gosub, RButton
Return
}
/*
If !Iniciate=0 
Gosub, RButton
Return
*/
;**************************************** H O M E ***********************************
Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4   ;background color of the menu R
            , "iconssize" : 8          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 24          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
   {
   WinSet, Transparent, 210, ahk_class #32768
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800        
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip	
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }     
     Return     
     }
   } 
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     Global ClipTool, Favorite
     ClipTool:=obj.tooltip
     Favorite:=obj.name     
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg ~= "onshow|onclose" )
;    tooltip % "menu " msg ": " obj.handle
   if ( msg = "onclose" ) ; ~=
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Gui, ContextClip: Destroy
Gui, ContextClip1: Destroy
Max_Index:=Description.maxIndex()
if !Max_Index
  {
  MsgBox, There are Currently no Clipboards
  SoundPlay, Resources\Close Window.mp3
  return
  }
Global WinUMID, mx, my
MouseGetPos, mx, my, WinUMID
Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
  {
  ClipBoardEnabled:=0
  ChangeClipEnable=1
  }
menu := pm.CreateMenu( menuParams1 )
newmenu1 := pm.CreateMenu( menuParams1 )

If Style=1
  {
  menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xF2F1C5})
  menu.Add()
if FileExist("TempClip\Favorites.fav")
  {
    Loop, read, TempClip\Favorites.fav
    {
    newmenu1.add( { "name" : A_LoopReadLine, "noicons": 1, "bold": 1} )
    ;newmenu1.add( { "name" : A_LoopReadLine , "noicons": 1, "bold": 1, "tooltip" : A_LoopReadLine} )
    }
  }
 }
Loop, %Max_Index%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return

;**************************************************************
PasteOne:
If !ClipTool
{
Clipboard:=""
Clipboard:=Favorite
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Else
{
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F4::
GuiUtily:
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
;Gui, -Caption +AlwaysOnTop HwndHwnd +Owner
Gui, Utily: -Caption HwndHwnd +Owner
;Gui, Utily: +Owner
Gui1.Hwnd := hwnd
;Gui, -Caption +alwaysontop +ToolWindow
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
;Gui, Add, Text, x0 y0 w691 h35 GuiMove ; , `&& Drag
Gui, Utily: Add, Picture, x0 y0 w691 h35 GuiMove, Resources\ArribaIzq1.png

;BUTTON 1
;************************************************************************************************************************
Gui1.Button1 := {} ;Button 1 
Gui1.Button1.DefaultImage := "Resources\PDFup.png"
Gui1.Button1.HoverImage := "Resources\PDFhover.png"
Gui1.Button1.PressedImage := "Resources\PDFDown.png"
Gui1.Button1.Label := "SavePDF"
Gui, Utily: Add, Picture, x12 y36 w141 h115 hwndhwnd, % Gui1.Button1.DefaultImage
Gui1.Handles[ hwnd ] := "Button1" ;The name of the control to point at.
Gui1.Button1.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 2
;************************************************************************************************************************
Gui1.Button2 := {} ;Button 2
Gui1.Button2.DefaultImage := "Resources\WordUp.png"
Gui1.Button2.HoverImage := "Resources\WordOver.png"
Gui1.Button2.PressedImage := "Resources\WordDown.png"
Gui1.Button2.Label := "SaveWord" 
Gui, Utily: Add, Picture, x154 y36 w141 h115 hwndhwnd, % Gui1.Button2.DefaultImage
Gui1.Handles[ hwnd ] := "Button2" ;The name of the control to point at.
Gui1.Button2.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 3
;************************************************************************************************************************
Gui1.Button3 := {} ;Button 3 
Gui1.Button3.DefaultImage := "Resources\PasteUp.png"
Gui1.Button3.HoverImage := "Resources\PasteHover.png"
Gui1.Button3.PressedImage := "Resources\PasteDown.png"
Gui1.Button3.Label := "ControlPaste" 
Gui, Utily: Add, Picture, x297 y36 w141 h115 hwndhwnd, % Gui1.Button3.DefaultImage
Gui1.Handles[ hwnd ] := "Button3" ;The name of the control to point at.
Gui1.Button3.Hwnd := hwnd 
;************************************************************************************************************************
;BUTTON 4
;************************************************************************************************************************
Gui1.Button4 := {} ;Button 4
Gui1.Button4.DefaultImage := "Resources\UrlUp.png"
Gui1.Button4.HoverImage := "Resources\UrlHover.png"
Gui1.Button4.PressedImage := "Resources\UrlDown.png"
Gui1.Button4.Label := "URLButton" 
Gui, Utily: Add, Picture, x440 y36 w141 h115 hwndhwnd, % Gui1.Button4.DefaultImage
Gui1.Handles[ hwnd ] := "Button4" ;The name of the control to point at.
Gui1.Button4.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 5
;************************************************************************************************************************
Gui1.Button5 := {} ;Button 5
Gui1.Button5.DefaultImage := "Resources\HelpUp.png"
Gui1.Button5.HoverImage := "Resources\HelpHover.png"
Gui1.Button5.PressedImage := "Resources\HelpDown.png"
Gui1.Button5.Label := "HelpButton" 
Gui, Utily: Add, Picture, x583 y36 w141 h115 hwndhwnd, % Gui1.Button5.DefaultImage
Gui1.Handles[ hwnd ] := "Button5" ;The name of the control to point at.
Gui1.Button5.Hwnd := hwnd
;************************************************************************************************************************
;BUTTON 6
;************************************************************************************************************************
Gui1.Button6 := {} ;Button 6 
Gui1.Button6.DefaultImage := "Resources\ExitUp1.png"
Gui1.Button6.HoverImage := "Resources\ExitHover1.png"
Gui1.Button6.PressedImage := "Resources\ExitDown1.png"
;Gui1.Button6.Label := "ExitLabel" 
Gui1.Button6.Label := "GuiClose" 
Gui, Utily: Add, Picture, x691 y0 w48 h35 hwndhwnd, % Gui1.Button6.DefaultImage
Gui1.Handles[ hwnd ] := "Button6" ;The name of the control to point at.
Gui1.Button6.Hwnd := hwnd
;************************************************************************************************************************
/*
MouseGetPos, xpos2, ypos2
Gui, Show, x%xpos2% y%ypos2% W600 h167, Hover Demo
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return
*/
MouseGetPos, xposUtil, yposUtil
If UtilButton=1
{
xposUtil := Floor((A_ScreenWidth/2)-450)
yposUtil := Floor((A_ScreenHeight/2)-200)
}
Gui, Utily: Show, x%xposUtil% y%yposUtil% W739 h167, Hover
OnMessage( 0x200 , "ButtonHover" )
OnMessage( 0x201 , "ButtonPress" )
Return


;************************************************************************************************************************
ButtonHover(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( !Gui1.Active && !Gui1.Pressed && Gui1.Handles[ ctrl ] ){ ;If a button isn't already active (Hover) and if no buttons are being pressed, and there is a match for the control in the Handles array.
		Gui1.Active := ctrl ;Assign this control as being the active control
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].HoverImage ;Set the picture to the hover image
		SetTimer, WatchLeaveHover, 30 ;Set a timer to watch for the cursor leaving this control (turn off hover)
	}
}

WatchLeaveHover: ;checks to see if the control that was being hovered is still being hovered.
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Pressed ){ ;If a button is being pressed, skip for another 30ms
	return
	}else if( ctrl != Gui1.Active ){ ;if the control under the cursor isn't the same as the control that is being hovered. (if you move your cursor away from the control)
		GuiControl,, % Gui1.Active , % Gui1[ Gui1.Handles[ Gui1.Active ] ].DefaultImage ;Set the picture back to the default image
		SetTimer, WatchLeaveHover, Off ;Turn off the timer
		Gui1.Active := "" ;empty this so that a new control can be hovered.
	}
	return

ButtonPress(){
	MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor
	if( Gui1.Handles[ctrl] ){ ; if the control under the cursor is a valid control.
		Gui1.Pressed := ctrl ;Assign this control as being the pressed control
		GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].PressedImage ;Set the picture to the pressed image
		While( GetKeyState( "LButton" ) ) ;While you continue to hold the mouse down, wait a few ms
		Sleep, 30
		MouseGetPos,,,, ctrl, 2 ;Get the hwnd of the control under the cursor again 
		if( ctrl = Gui1.Pressed ){ ;Test to see if it is still the same as the control you clicked on.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].HoverImage ;Set the picture to the Hover image
			Gui1.Pressed := "" ;empty
			try 
				gosub, % Gui1[ Gui1.Handles[ ctrl ] ].Label ;if the control has a label, run it.
		}else{ ;if the control is not the same. Cancel running that controls label and set the control back to its default image.
			GuiControl,, % Gui1.Pressed , % Gui1[ Gui1.Handles[ Gui1.Pressed ] ].DefaultImage ;Set the picture to the Default image
			Gui1.Pressed := "" ;empty
		}
	}
}
;************************************************************************************************************************
 
WUtil:
UtilButton:=1
Gosub, GuiUtily
Return

^F3::
MainProcess:
Gui, Submit
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
last := Clipboard, Clipboard := ""
Send ^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
 Return
} Else If (Clipboard = last) {
 TrayTip
 SoundPlay, Resources\ambiguity2.mp3
 TrayTip, Clipboard Message, REPEATED CLIPBOARD!,, 0x2, 0x10, 0x20
 Return
}
/*Else {
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
}
SetTimer, HideTrayTip, -1500
*/

;Data:=clip_GetHtmlString()
accData:= GetAccData()
;******************************************************************************************************************
If not ClipboardGet_HTML( Data )
   {
   ErrorType :=1
   Gosub, ControlError
   WinClip.Clear()
   Return
   }
Else 
 TrayTip
 SoundPlay, Resources\Clipboard_Sound.mp3
 TrayTip, Clipboard Message, %Clipboard%,, 0x1, 0x10, 0x20
 SetTimer, HideTrayTip, -1500

CorpusCount++
;******************************************************************************************************************
FileTex := "HTMLTemp\Text" CorpusCount ".html"
aData := accData.1
LenText := StrLen(aData)
StringGetPos, pos, aData, -, r1
length := pos-1
StringLeft, OutText, aData, %length%
FileaccData := "HTMLTemp\Name" CorpusCount ".txt"
FileAppend, %OutText%, %FileaccData%, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile, %FileaccData%
If !FileaccData or SizeFile=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
FileURL := "HTMLTemp\URL" CorpusCount ".txt"
2Data := accData.2
FileAppend, %2Data%, %FileURL%, CP65001 
Sleep 300
myResult := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" accData.2 ">" OutText "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResult%, %FileTex%
;******************************************************************************************************************
FileGetSize, SizeFile1, %FileTex%
If !FileTex or SizeFile1=3
{
ErrorType :=0
Gosub, ControlError
If ErrorTex=0
Return
}
;******************************************************************************************************************
;ClipboardGet_HTML( Data )

DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
;MsgBox, %SizeFile2%
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
;If ErrorTex=0
Return
}
;******************************************************************************************************************
clipboard=%clipboard%
Plain := "HTMLTemp\TextPlain" CorpusCount ".txt"
FileAppend, %clipboard%, %Plain%, CP65001
Loop, read, Temp.html
{
   If A_Index >6
   FileAppend, %A_LoopReadLine%`n, TempPDF.html
}
;NameCopy := "HTMLTemp\Temp" CorpusCount ".html"
;FileCopy, TempPDF.html, %NameCopy%
RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 TempPDF.html temp2.html ,,hide

If SuspendThumbnail=0
   {
   RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 temp2.html Image_Temp.jpg,,hide
   Gosub, ResizeH
   ImageCount := "HTMLTemp\Image" CorpusCount ".jpg"
   FileMove, Image_Temp.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
;Gosub, CheckProcess
SoundPlay, Resources\Clipboard_Sound.mp3
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -1200
Iniciate:=1
Data :=""
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Gosub, ReloadMenu
Return

ControlError:
If ErrorType =0
	{
	MsgBox, 0x1024,, You have not been able to save the name of the clipboard source, you will be able to name it later. `nContinue in every way?	
	IfMsgBox Yes
	   {
	   ErrorTex:=1
	   Return
	   }
        ErrorText:=0
        Return
	}
If ErrorType =1
	{
	MsgBox, 0x1024,, The content of the clipboard does not have a valid format to be saved and the operation will be canceled.`n(The source of the text must be from the Internet or from formatted Word or PDF files opened with a browser.)`n`nDo you want to save the copied text to the basic clipboard?
	IfMsgBox No
	Return
	Else
	If ChangeClipEnable=1
	  {
          ClipBoardEnabled=1
	  CRCClip:=LC_CRC32(Clipboard)
	  Gosub, DuplicateCRC
	  CRC32.insert(Object())
          Max_CRC:=CRC32.MaxIndex()
	  CRC32[Max_CRC]:=CRCClip	  
	  if (Max_CRC>MaxClips)
	     {
	     CRC32.removeAt(1)
	     }
          ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	If ChangeClipEnable=0
	  {
	  CRCClip:=LC_CRC32(Clipboard)
	  Gosub, DuplicateCRC
	  CRC32.insert(Object())
          Max_CRC:=CRC32.MaxIndex()
	  CRC32[Max_CRC]:=CRCClip	  
	  if (Max_CRC>MaxClips)
	     {
	     CRC32.removeAt(1)
	     }
	  ClipSave(ClipBoardHistory,Clipboard, MaxClips)
	  SoundPlay, Resources\Close Window.mp3
	  }
	Return
	}
If ErrorType =2
	;{
	;MsgBox, 0x1024,, The clipboard image could not be saved. The clipboard exists, but it won't display an image `nContinue in every way?	
	MsgBox, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	*/
	IfMsgBox Yes
	   {
	   ErrorImg:=1
	   Return
	   }
        ErrorImg:=0
        */
	Return
	;}
Return

ResizeH:
filePath := "Image_Temp.jpg"
size := GetImageSize(filePath)

If size.H !>500
return
else
if ErrorLevel
	return
crop(FilePath, 0, 0, W, 500)
Return

/*
CheckProcess:
Corpus:= "HTMLTemp\Corpus" CorpusCount ".html"
Corpus:= "HTMLTemp\Image" CorpusCount ".jpg"
Corpus:= "HTMLTemp\name" CorpusCount ".txt"
Corpus:= "HTMLTemp\TextPlain" CorpusCount ".txt"
Corpus:= "HTMLTemp\URL" CorpusCount ".txt"
Corpus:= "HTMLTemp\Text" CorpusCount ".txt"
Return
*/

CopyGui:
CopyButton:=1
;GoSub, Toggle_Switch
Gosub, Menu2
Return

ClipDelete:
StringTrimLeft, DelClip, a_guicontrol, 12
MsgBox, 0x1034,, Do you want to delete the %DelClip%st entrance of the clipboard?
IfMsgBox Yes 
	{
	Gui, 4: Destroy
	Gui, ContextClip: Destroy
	FileDelete, HTMLTemp\Corpus%DelClip%.html
	FileDelete, HTMLTemp\image%DelClip%.jpg
	FileDelete, HTMLTemp\Name%DelClip%.txt
	FileDelete, HTMLTemp\Text%DelClip%.html
	FileDelete, HTMLTemp\TextPlain%DelClip%.txt
	FileDelete, HTMLTemp\URL%DelClip%.txt
	Loop, %CorpusCount%
        if !FileExist("TextPlain" A_Index ".txt")
	   {
	   NumberFile := A_Index
           FileSup := NumberFile+1
           Sup := "HTMLTemp\TextPlain" Filesup ".txt"
           NumF:= "HTMLTemp\TextPlain" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\URL" Filesup ".txt"
           NumF:= "HTMLTemp\URL" NumberFile ".txt"
           Filemove, %Sup%, %NumF%
           Sup := "HTMLTemp\Corpus" Filesup ".html"
           NumF:= "HTMLTemp\Corpus" NumberFile ".html"
           Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Text" Filesup ".html"
	   NumF:= "HTMLTemp\Text" NumberFile ".html"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Image" Filesup ".jpg"
	   NumF:= "HTMLTemp\Image" NumberFile ".jpg"
	   Filemove, %Sup%, %NumF%
	   Sup := "HTMLTemp\Name" Filesup ".txt"
	   NumF:= "HTMLTemp\Name" NumberFile ".txt"
	   Filemove, %Sup%, %NumF%
	   }
	;CorpusCount--
	;Gosub, RButton
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	;Gosub, IniciateUtility
	Gosub, ReloadMenu
	}
Return

^F8::
Menu2:
;MouseGetPos, xpos1, ypos1
MouseGetPos, xposMen, yposMen
If CopyButton=1
{
xposMen := Floor(A_ScreenWidth/2)
yposMen := Floor(A_ScreenHeight/2-100)
}
Gui, CopyButtom:Show, x%xposMen% y%yposMen% W81 h84
Return

+RButton::
RButton:
Gui, ContextClip: Destroy
global Gui1 := {} ;Main object for everything to do with this gui.
Gui1.Handles := [] ;an array that uses the hwnd of a control as its index position. (this has the name of the controls main object as its values)
;Gui1.Active := "" ;The hwnd of the currently hovered button
Gui1.Pressed := "" ;The hwnd of the currently pressed button
Gui1.Hwnd := hwnd

FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip: Add, Button, x0 y%posy% w20 h20 hwndIcon hwndIcon8 gGoURL vTURL%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x520 y%posy% w20 h20 hwndIcon gTxtLabel vTCopy%A_Index%, %A_Index%
   Gui, ContextClip: Add, Button, x540 y%posy% w20 h20 hwndIcon1 gTxtPlane vTplane%A_Index%
   Gui, ContextClip: Add, Button, x20 y%posy% w20 h20 hwndIcon10 gClipDelete vDeleteButton%A_Index%
   Gui, ContextClip: Add, Button, x500 y%posy% w20 h20 hwndIcon9 gTitleEditing vEditing%A_Index%
   Gui, ContextClip: Add, Button, x40 y%posy% w460 h20 gButtonLabel vNameButton%A_Index%, %A_LoopReadLine%
   GuiButtonIcon(Icon, "Resources\clipboard.ico", 1, "s32")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s32")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s32")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s32")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s24")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip: Margin, 2, 2 
;Gui, ContextClip: -Caption +ToolWindow +0x400000 +hWndhMainWnd HwndHwnd ;Menu3s
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
;Gui, ContextClip: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;WinSet, Transparent
;Gui, ContextClip:+Owner
posyExitSess := posyExit+20
;LeeSession:= ScriptDir "\HTMLTemp\Session.txt"
LeeSession:= "HTMLTemp\Session.txt"
FileRead, SessClip, %LeeSession%
Gui, ContextClip: Add, Picture, x0 y%posyExit% W560 h32, Resources\Fondo_p.png
Gui, ContextClip: Add, Picture, x0 y%posyExit% W29 h32 gLabelSessionAct0, Resources\IConChange.png
Gui, ContextClip: Add, Picture, x30 y%posyExit% W435 h32 GuiMove, Resources\Resto1.png
;***********************************************************************
Gui1.Button7 := {} ;Button 7 
Gui1.Button7.DefaultImage := "Resources\Reducedcap.png"
,Gui1.Button7.HoverImage := "Resources\Close.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
;Gui1.Button7.Label := "ReducedM"
Gui, ContextClip: Add, Picture, x487 y%posyExit% W72 h32 gReducedM hwndhwnd, % Gui1.Button7.DefaultImage
Gui1.Handles[ hwnd ] := "Button7" ;The name of the control to point at.
Gui1.Button7.Hwnd := hwnd
;***********************************************************************
Gui1.Button8 := {} ;Button 8 
Gui1.Button8.DefaultImage := "Resources\Close.png"
,Gui1.Button8.HoverImage := "Resources\Close.png"
Gui1.Button8.PressedImage := "Resources\Close1.png"
Gui1.Button8.Label := "ExitLabel" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip: Add, Text, cYellow BackgroundTrans +Center x2 y%posyExitSess1% vTextTitle W536 h20, %SessClip%
MouseGetPos, xpos1, ypos1
If threeRButton=1
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}
If ControlTwo=1
{
xpos1 := XActTwo-140
ypos1 := yActTwo-13
}
;xpos1 := xpos1-560
;ypos1 := ypos1-alto
AltoSess := Alto+12
Gui, ContextClip: Show, x%xpos1% y%ypos1% w560 h%AltoSess% ;Menu3s
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
OnMessage( 0x201 , "ButtonPress" )
Gosub, NewWindow
return

RButtonAlt:
threeRButton :=1
Gosub, RButton
Return

TitleEditing:
Gosub, NewWindow
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Edit:+Owner
Gui, Edit: Font, S10 Bold, Verdana
Gui, Edit: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, Edit: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Clipboard Title
Gui, Edit: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Edit: Font, S8 Bold, Verdana
Gui, Edit:Add, Edit, x5 y40 w544 h20 vMyEdit%NumberTemp%, %FileCont%
;Gui, Edit: Add, Edit, x12 y9 w460 h20 vMyEdit%REdit%, %FileCont%
Gui, Edit:Add, Button, x20 y70 w70 h20 gTitleSave, OK
Gui, Edit:Add, Button, x120 y70 w70 h20 gTitleCancel, Cancel
Gui, Edit:Add, CheckBox, x240 y70 w210 h20 Checked1 vVeryfyChange%NumberTemp%, Change also the Title to Paste
EdXm := pXm-846
EdYm := pYm-148 ;96
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit, Destroy
EditTemp :=MyEdit%NumberTemp%
fileAdd := FileOpen(FileChange, "w")
fileAdd.Write(EditTemp)
;fileAdd.Write(MyEdit)
fileAdd.Close()
VeryfyChange:=VeryfyChange%NumberTemp%
If VeryfyChange=1
{
ReadURL := "HTMLTemp\URL" REdit ".txt"
Fileread URLTxt, %ReadURL%
ReadText:= "HTMLTemp\Text" REdit ".html"
FileDelete, %ReadText%
myResultSave := "<h1><span lang=ES-ES style='font-size:10.0pt;color:#78230C;mso-ansi-language:ES-ES'>Text extracted from:<br></span><span style='font-size:12.0pt'><a href=" URLTxt ">" EditTemp "</a> <o:p></o:p></span></p></h1>"
FileAppend, %myResultSave%, %ReadText%
}
MyEdit :=""
FileCont :=""
FileChange :=""
NumberTemp++
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
;Gosub, NewWindow
NumberTemp++
Gosub, RButton
Return

ReducedM:
WinGetPos, XActOne, YActOne,,, A
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=1
ControlTwo :=0
Gosub, NotifyTrayClick_207
Return

NotifyTrayClick_207:
Gui, ContextClip1: Destroy
FileDelete, SesionName.txt
Gui, ContextClip: new
Gui, 2: new
Gui, 3: new
Loop, %CorpusCount%
{
   NameTemp := "HTMLTemp\Name" A_Index ".txt"
   FileRead, Name1, %NameTemp%
   FileAppend, %Name1%`n, SesionName.txt
}
Loop, read, SesionName.txt
   {
   posy:=20*(A_Index-1)
   Gui, ContextClip1: Add, Button, x0 y%posy% w460 h20 gButtonTwo vTwoButton%A_Index%, %A_LoopReadLine%
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
;Gui, ContextClip1: Margin, 2, 2
Gui, ContextClip1: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
;Gui, Font, S14 Bold, Verdana
;Gui, ContextClip1:+Owner
Gui, ContextClip1: Add, Button, x20 y%posyExit% w380 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x400 y%posyExit% w60 h20 hwndIcon20 gExtendedM
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*31.5)
XPos:= A_ScreenWidth-(700)
YPos:= A_ScreenHeight-AltoT-60
If threeRButton=1
{
xpos := Floor((A_ScreenWidth/2)-450)
ypos := Floor((A_ScreenHeight/2)-200)
}
If ControlOne=1
{
xPos := XActOne
yPos := YActOne
}
Gui, ContextClip1: Show, x%XPos% y%YPos% w460 h%Alto% ;Menu3s
GuiButtonIcon(Icon21, "Resources\Hand4.ico", 1, "s32")
GuiButtonIcon(Icon20, "Resources\ArrowExt.png", 1, "W90" "H30")
VarSetCapacity(tme,16,0)
NumPut(16,tme,0), NumPut(2,tme,4), NumPut(hwnd,tme,8)
OnMessage(0x2A3,"OnMouseLeave")
OnMessage(0x200,"OnMouseMove")
Gosub, NewWindow
return

ExtendedM:
WinGetPos, XActTwo, YActTwo,,, A
Gui, ContextClip1: Destroy
SoundPlay, Resources\Close Window.mp3
ControlOne :=0
ControlTwo :=1
Gosub, RButton
Return

~+LButton::start := A_TickCount
~+LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

~#!LButton::start := A_TickCount
~#!LButton Up::
If (A_TickCount - start < 1200)
  Return
MouseGetPos,,, WinUMID
MouseGetPos, xpos1, ypos1
TextOnly=1
Gui, CopyButtom:Show, x%xpos1% y%ypos1% W79 h87 ;Menu2S
Return

ReducedAlt:
threeRButton :=1
Gosub, NotifyTrayClick_207
Return

GoURL:
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
Run, %WebURL%
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
;Gui, Help: +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w640 h250, Resources\Help.jpg
Gui, Help: Add, Button, x495 y209 w100 h30 gNextButton, More...
Gui, Help: Show, w640 h250
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
;Gui, Help2: +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h397, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x10 y340 w100 h30 gExitButton, Exit
Gui, Help2: Show, w800 h397
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
;Gui, 2:default
;Gui, destroy
Return

HideTrayTip:
TrayTip
Return

HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        Menu Tray, NoIcon
        Sleep 200  ; It may be necessary to adjust this sleep.
        Menu Tray, Icon
    }
}

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiEscape:
GuiClose:
ExitCopy:
SoundPlay, Resources\Close Window.mp3
CopyButton=0
UtilButton :=0
Gui, Hide
Gui, CopyButtom:Hide
Return

;*************************************************************************
alert:
if (status_button=status_button_old)
return
Gui, 2:default
Gui, destroy
NumberFile:= RegExReplace(status_button,"\D")
image_file := "HTMLTemp\Image" NumberFile ".jpg"
if !image_file
return

Gui,3:Destroy
Gui,2: -border -caption +toolwindow 
Gui, 2: Margin, 2, 2
gui,2: color,202020
gui,2: add,picture,vpic ,%image_file%
Gui,2: Show, x%pXm% y%pYm%
status_button_old:=status_button
return
;*************************************************************************
Deletealert:
if (status_delete=status_delete_old)
return
Gui, 4:default
Gui, destroy
NumberDelete:= RegExReplace(status_delete,"\D")
if !NumberDelete
return

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Delete Clipboard Number %NumberDelete%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 4:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 4:margin, 0, 0
Gui, 4:add, ActiveX, vWB w64 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
DelXm := pXm-944
GuiControl, Move, WB, h%maxBottom%
Gui, 4: Show, x%DelXm% y%pYm% w64 h60
status_delete_old:=status_delete
Return
;*************************************************************************
Copyalert:
if (status_Copy=status_Copy_old)
return
Gui, 6:default
Gui, destroy
NumberCopy:= RegExReplace(status_Copy,"\D")
if !NumberCopy
return
      
Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Copy Item %NumberCopy% as Current Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 6:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 6:margin, 0, 0
Gui, 6:add, ActiveX, vWB w60 h72, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
GuiControl, Move, WB, h%maxBottom%
Gui, 6: Show, x%pXm% y%pYm% w60 h72
status_Copy_old:=status_Copy
Return
;*************************************************************************
URLalert:
if (status_URL=status_URL_old)
return
Gui, 5:default
Gui, destroy
NumberURL:= RegExReplace(status_URL,"\D")
URL_file := "HTMLTemp\URL" NumberURL ".txt"
if !URL_file
return

;Gui,2:Destroy
;URL_file := "HTMLTemp\URL" NumberURL ".txt"
FileRead, URLContents, %URL_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Go to: %URLContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 5:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 5:margin, 0, 0
Gui, 5:add, ActiveX, vWB w562 h30, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
DelXm := pXm-845
;DelXm := pXm-819
DelYm := pYm-47
;Gui, 5: Show, x%DelXm% y%DelYm% w543 h30
Gui, 5: Show, x%DelXm% y%DelYm% w562 h30
status_URL_old:=status_URL
Return
;*************************************************************************
Planealert:
if (status_plane=status_plane_old)
return
Gui, 3:default
Gui, destroy
NumberPlane:= RegExReplace(status_plane,"\D")
Text_file := "HTMLTemp\TextPlain" NumberPlane ".txt"
if !NumberPlane
return

Gui,2:Destroy
Gui,5:Destroy
FileRead, FileContents, %Text_file%

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 10pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">%FileContents%</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 3:+AlwaysOnTop -Caption +ToolWindow Border
Gui, 3:margin, 0, 0
Gui, 3:add, ActiveX, vWB w320 h220, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom

GuiControl, Move, WB, h%maxBottom%
Gui, 3: Show, x%pXm% y%pYm% w320 h220
status_plane_old:=status_plane
Return
;*************************************************************************
Editingalert:
if (status_Editing=status_Editing_old)
return
Gui, 6:default
Gui, destroy
EditingNumber:= RegExReplace(status_Editing,"\D")
if !EditingNumber
return

Gui,2:Destroy
Gui,5:Destroy

Html = 
(
   <html><head><Style>
      body {background-color: #FFFFF4; overflow: hidden} 
      p {font-family: 'Raleway-Thin'; font-size: 9pt; }
      .words {color: #3d3c3c;}
      .reference {color: #00ffff;}
   </style></head><body>
<p class="words">Edit Title of the %EditingNumber%th Clipboard</p>
<p class="reference">%f_ref%</p>
</body></html>
)

Gui, 7: +AlwaysOnTop -Caption +ToolWindow Border
;Gui, +AlwaysOnTop -Caption +ToolWindow Border
gui, 7:margin, 0, 0
gui, 7:add, ActiveX, vWB w62 h60, HTMLfile
WB.write(html)

children := WB.body.children
maxBottom := 0
Loop % children.length {
   rect := children[A_Index - 1].getBoundingClientRect()
   (rect.bottom > maxBottom && maxBottom := rect.bottom)
}
maxBottom *= 96/A_ScreenDPI
maxBottom += 15 ; some value you want for the padding-bottom
;DelXm := pXm-953
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F6::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nMake sure you do not move the mouse, or change the focus on the application.
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
;Gui, Hide
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
;   if (Errorlevel = 1)
;   Break
;   else if (Errorlevel = 0)
;	{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	;WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".html", "r").read()
	Sleep, 1000
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 300
	;SendInput {Del}
	html := FileOpen("Resources\Line2.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	Send, `n
	Sleep, 300
	}
;}
TrayTip, Timed TrayTip, Successful Process!, 0x1, 0x10, 0x20
SetTimer, HideTrayTip, -2000
SoundPlay, Resources\Close Window.mp3
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F5::
SavePDF:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	FileRead, html3, Resources\PDFLine.html
	FileAppend, %html3%<br/>, ToPDF.html
	}
}
;RunWait, %A_WorkingDir%\Addons\conv.exe -b 65001 ToPDF.html TempPDF.html ,,hide
RunWait, %A_WorkingDir%\Addons\wkhtmltopdf.exe ToPDF.html Final_Document.pdf,,hide
PDFCount++
FormatTime, CurrentDate,, dd-MM-yyyy
Filedate := "Documents\Final_Document_" CurrentDate "-" PDFCount ".pdf"
Filedateh := "Documents\ToPDF_" CurrentDate "-" PDFCount ".html"
FileMove, Final_Document.pdf, %Filedate%
Run, %Filedate%
FileMove, ToPDF.html, %Filedateh%
;FileDelete, ToPDF.html
;FileDelete, TempPDF.html
Return

^F7::
SaveWord:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a Word File?
IfMsgBox No
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gui, Utily: Destroy
Sleep, 1000
;ToolTip, Saving clipboard to docx file...
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToWord.html, CP65001
	;FileRead, Line1, Resources\WordLine.html 
	;FileAppend, %Line1%, ToWord.html, CP65001
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToWord.html, CP65001
	FileRead, Line2, Resources\WordLine.html
	FileAppend, %Line2%, ToWord.html, CP65001
	}
}
WinClip.Clear()
html := FileOpen("ToWord.html", "r").read()
WinClip.SetHTML(html)
Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt
Clip:= ScriptDir "Word.docx"
ClipToDoc( clip )
WordCount++
FormatTime, CurrentDate,, dd-MM-yyyy
FileWord := ScriptDir "\Documents\Final_Document_" CurrentDate "-" WordCount ".docx"
FileMove, Word.docx, %FileWord%
Run, %FileWord%
FileDelete, ToWord.html
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

^F11::
;^!z::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
;FileDelete, HTMLTemp\*%CorpusCount%.*
FileDelete, HTMLTemp\Corpus%CorpusCount%.html
FileDelete, HTMLTemp\image%CorpusCount%.jpg
FileDelete, HTMLTemp\Name%CorpusCount%.txt
FileDelete, HTMLTemp\Text%CorpusCount%.html
FileDelete, HTMLTemp\TextPlain%CorpusCount%.txt
FileDelete, HTMLTemp\URL%CorpusCount%.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, ReloadMenu
;CorpusCount--
Return
;************************************************************************************************************************
^Esc:: 
Exit:
ExitApp
Return

Borrado:
FileDelete, HTMLTemp\Text*.html
FileDelete, HTMLTemp\Corpus*.html
FileDelete, HTMLTemp\image*.jpg
FileDelete, HTMLTemp\Name*.txt
FileDelete, HTMLTemp\TextPlain*.txt
FileDelete, HTMLTemp\URL*.txt
Iniciate:=1
Menu, ClipboardID, DeleteAll
Gosub, LabelSessionAct1
CorpusCount :=0
;Gosub, ReloadSession
Gosub, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
;Gui, 2: Destroy
;Gui, ContextClip: Destroy
Gosub, ButtonLabel
Return

LabelSession:
;NumberFile:=A_ThisMenuItemPos
;Menu, tray, ToggleCheck, &Suspend Clipboard Utility
;Menu, tray, ToggleCheck, Clipboard Sessions
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return
;Loop, %DirectoryCount%
/*
if !FileExist("HTMLTemp" A_Index)
{
;NumberDir : %A_Index%
MoveDir := "HTMLTemp" A_Index
}
MsgBox, %MoveDir%
*/
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4
;MsgBox, %NumberPos%

   FileAppend, %A_ScriptDir%, SessionTemp.txt
   FileSession := "\HTMLTemp"
   FileAppend, %FileSession%, SessionTemp.txt


   FileAppend, %A_ScriptDir%, SessionTemp00.txt
   FileSession2 := "\HTMLTemp00"
   FileAppend, %FileSession2%, SessionTemp00.txt

   FileRead, DirectorySess, SessionTemp.txt
   FileRead, DirectorySess00, SessionTemp00.txt
   ;FileMove %DirectorySess%, %DirectorySess00%
FileMoveDir %DirectorySess%, %DirectorySess00%, R
;DirectorySess :=""
;DirectorySess00 :=""

   FileAppend, %A_ScriptDir%, SessionTemp01.txt
   FileSession3 := "\HTMLTemp" NumberPos
   FileAppend, %FileSession3%, SessionTemp01.txt

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  ;MsgBox, %DirectorySess01%`n%DirectorySess%

FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
Gosub, ReloadSession
Return

ButtonLabelTray:
If CorpusCount=0
Return
NumberFile:=A_ThisMenuItemPos
Gosub, ButtonLabel
Return

ButtonLabel:
;NumberFile:= RegExReplace(NameTwo,"\D")
Gosub, ExitLabel
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
Sleep, 1000
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
WinClip.Clear()
html := FileOpen("HTMLTemp\Text" NumberFile ".html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line1.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
html := FileOpen("HTMLTemp\Corpus" NumberFile ".html", "r").read()
Sleep, 1000
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()
Sleep, 300
html := FileOpen("Resources\Line2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

ExitLabel:
SoundPlay, Resources\Close Window.mp3
Gui, ContextClip1: Destroy
Gui, ContextClip: Destroy
;Gui, Destroy
Gui,2: Destroy
Gui, Gui1: Destroy
;Gui, 2:default
;Gui, destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
ControlOne :=0
ControlTwo :=0
threeRButton :=0
Alto:=0
Return

TxtLabel:
SoundPlay, Resources\Clipboard_Sound.mp3
StringTrimLeft, TextCopy, a_guicontrol, 5
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlTx := FileOpen("HTMLTemp\Corpus" TextCopy ".html", "r").read()
WinClip.SetHTML(htmlTx)
Return

TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
StringTrimLeft, TextPlane, a_guicontrol, 6
GetKeyState, state, Control
if (state = "D") and ClipBoardEnabled:=1
 {
 WinClip.Clear()
 htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
 Clipboard := %htmlPl%
 /*
 CRCClip:=LC_CRC32(Clipboard)
 Gosub, DuplicateCRC
 CRC32.insert(Object())
 Max_CRC:=CRC32.MaxIndex()
 CRC32[Max_CRC]:=CRCClip	  
  if (Max_CRC>MaxClips)
     {
     CRC32.removeAt(1)
     }
  */
 SoundPlay, Resources\Clipboard_Sound.mp3
 Return
 }
if (state = "D") and ClipBoardEnabled:=0
 {
 WinClip.Clear()
 htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
 Clipboard = %htmlPl%
 ClipSave(ClipBoardHistory,Clipboard, MaxClips)
 SoundPlay, Resources\Clipboard_Sound.mp3
 Return
 }
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return

/*
TxtPlane:
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
StringTrimLeft, TextPlane, a_guicontrol, 6
Gosub, ExitLabel
Sleep, 300
WinClip.Clear()
htmlPl := FileOpen("HTMLTemp\TextPlain" TextPlane ".txt", "r").read()
Clipboard = %htmlPl%
Send, ^v
Sleep, 300
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
WinClip.Clear()
Return
*/

Toggle_Switch:
If Toggle=0
  {
   GuiControl, Hide, State0
   GuiControl, Show, State1
   Toggle=1
  }
Else {
   GuiControl, Hide, State1
   GuiControl, Show, State0
   Toggle=0
  }
Return

SubRoutine1:
GoSub,Toggle_Switch
If Toggle=0
{
Hotkey, +LButton Up, on
;Gui, Destroy
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
;Gui, Destroy
Return
}

CopyTexClip:
Gui, Submit
WinActivate, ahk_id %WinUMID%
If TextOnly=1
{
Send, ^c
TextOnly=0
Return
}
Gosub, MainProcess
Return

NewWindow:
    WinGetPos pXm, pYm, Width, Height, ahk_id %hMainWnd%
    pXm := pXm + Width
    If (A_OSVersion ~= "WIN_(7|XP)") {
        SysGet BorderW, 32 ; SM_CXFRAME
        pXm += BorderW + 1
    }
 Return

ClipboardGet_HTML( byref Data ) ;www.autohotkey.com/forum/viewtopic.php?p=392624#392624
 {
 If CBID := DllCall( "RegisterClipboardFormat", Str,"HTML Format", UInt )
  If DllCall( "IsClipboardFormatAvailable", UInt,CBID ) <> 0
   If DllCall( "OpenClipboard", UInt,0 ) <> 0
    If hData := DllCall( "GetClipboardData", UInt,CBID, UInt )
       DataL := DllCall( "GlobalSize", UInt,hData, UInt )
     , pData := DllCall( "GlobalLock", UInt,hData, UInt )
     , VarSetCapacity( data, dataL * ( A_IsUnicode ? 2 : 1 ) ), StrGet := "StrGet"
     , A_IsUnicode ? Data := %StrGet%( pData, dataL, 0 )
                   : DllCall( "lstrcpyn", Str,Data, UInt,pData, UInt,DataL )
     , DllCall( "GlobalUnlock", UInt,hData )
 DllCall( "CloseClipboard" )
Return dataL ? dataL : 0
}

GuiButtonIcon(Handle, File, Index := 1, Options := "")
{
	RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
	RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
	RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
	RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
	RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
	RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
	RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
	RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
	Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
	VarSetCapacity( button_il, 20 + Psz, 0 )
	NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
	NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
	NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
	NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
	NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
	NumPut( A, button_il, 16 + Psz, DW )	; Alignment
	SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
	return IL_Add( normal_il, File, Index )
}

OnMouseMove( wParam, lParam, Msg,hwnd ) {
global status_button ,tme
global status_Plane ,tme
global status_Print ,tme
global status_Delete ,tme
global status_URL ,tme
global status_Copy ,tme
global status_Editing ,tme
DllCall( "TrackMouseEvent","uint",&tme )
status_button:=""
status_Plane:=""
Status_Print:=""
status_Delete:=""
status_URL:=""
status_Copy:="" 
status_Editing:=""
if instr(a_guicontrol,"BUTTON")
      {
      status_button:=a_guicontrol
      SetTimer, alert,-20
      }
if instr(a_guicontrol,"plane")
      {
      status_Plane:=a_guicontrol
      SetTimer, Planealert,-20
      }
if instr(a_guicontrol,"Print")
      {
      status_Print:=a_guicontrol
      SetTimer, Printalert,-20
      }
if instr(a_guicontrol,"Delete") 
      {
      status_Delete:=a_guicontrol
      SetTimer, Deletealert,-20
      }
if instr(a_guicontrol,"URL") 
      {
      status_URL:=a_guicontrol
      SetTimer, URLalert,-20
      }
if instr(a_guicontrol,"Copy") 
      {
      status_Copy:=a_guicontrol
      SetTimer, Copyalert,-20
      }
if instr(a_guicontrol,"Editing") 
      {
      status_Editing:=a_guicontrol
      SetTimer, Editingalert,-20
      }
}

OnMouseLeave(){
global
Gosub, NewWindow
Gui,2: Destroy
Gui,3: Destroy
Gui,4: Destroy
Gui,5: Destroy
Gui,6: Destroy
Gui,7: Destroy
status_button_old:=""
status_plane_old:=""
status_print_old:=""
status_Delete_old:=""
status_URL_old:=""
status_Copy_old:=""
status_Editing_old:=""
}

Printalert:
if (status_Print=status_print_old)
return

URLButton:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Extract URL's from Clipboards?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Loop, %CorpusCount%
{
   if (Errorlevel = 1)
   Break
   else if (Errorlevel = 0)
	{
	html1 := "HTMLTemp\Text" A_Index ".html"
	FileRead, PDF1, %html1%
	FileAppend, %PDF1%<br/>, ToPDF.html
	html2 := "HTMLTemp\Corpus" A_Index ".html"
	FileRead, PDF2, %html2%
	FileAppend, %PDF2%<br/>, ToPDF.html
	}
}
Gosub, ExtractURL
FileDelete, ToPDF.html
Return

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
}
;************************************************************************************************************************

ExtractURL:
;Create header html document
FileAppend,
(
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=AutoHotkey.File>
<meta name=Generator content="AutoHotkey">
</head>
<body lang=es style='font-family:Calibri;font-size:11.0pt'>
), Extracted_Links.html

FormatTime, CurrentDate,, dd-MM-yyyy
DateIncl := "<p style='margin:0in'><span style='font-family:Times New Roman;font-size:11.0pt;color:#1E4D78'>Clipboard Session URLs:  </span><span style='font-weight:bold;font-family:Calibri;font-size:12.0pt;color:#860000'>" CurrentDate "</span></p>"
FileAppend, %DateIncl%, Extracted_Links.html

;Add Line
myResult := "<p style='margin:0in;font-family:Calibri;font-size:11.0pt;color:#78230C'><p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>`r
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>`r"
FileAppend, %myResult%, Extracted_Links.html

;Routine loop, origin: https://www.autohotkey.com/docs/commands/LoopReadFile.htm
LinkCount := 0
ImgCount := 0

Loop, read, ToPDF.html, Extracted_Links.html

{
    URLSearchString := A_LoopReadLine
    Gosub, URLSearch
}

FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links.html

Loop, read, Extracted_Links.html
{
	If A_Index < 11
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	if A_Index > 11
	if RegExMatch(A_LoopReadLine, "\.(jpg<|jpeg<|png<|gif<|svg<)")
	{
	FileAppend, %A_LoopReadLine%`n, Extracted_Links_Img.html
	ImgCount++ ; increment by one
	}
	else If InStr(A_LoopReadLine, "</ul>", True) and A_Index > 17
	FileAppend,
(
</ul>
<p style='margin:0in;font-family:Calibri;font-size:11.0pt'>&nbsp;</p>
<p style='margin:0in'><span style='font-family:Courier;font-size:10.0pt;font-weight:bold'>───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br><ul type=disc style='direction:ltr;unicode-bidi:embed;margin-top:0in;margin-bottom:0in'>
<!--EndFragment-->
</body>
</html>
), Extracted_Links_Img.html
}

;URL number message, Optional
MsgBox %LinkCount% links were found and written to "Extracted_Links.html" `n %ImgCount% Images were found and written to "Extracted_Links_Img.html"
;Opcional, opens the result
FormatTime, CurrentDate,, dd-MM-yyyy
FileURL := "Documents\Extracted_Links_" CurrentDate ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Run, %FileURLImg%
return

URLSearch:
; It's done this particular way because some URLs have other URLs embedded inside them:
URLStart1 := InStr(URLSearchString, "https://")
URLStart2 := InStr(URLSearchString, "http://")
URLStart3 := InStr(URLSearchString, "ftp://")
URLStart4 := InStr(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 pseudo-array has been reached.
        break
    if (ArrayElement = 0)  ; This element is disqualified.
        continue
    if (URLStart = 0)
        URLStart := ArrayElement
    else ; URLStart has a valid position in it, so compare it with ArrayElement.
    {
        if (ArrayElement != 0)
            if (ArrayElement < URLStart)
                URLStart := ArrayElement
    }
}

if (URLStart = 0)  ; No URLs exist in URLSearchString.
    return

; Otherwise, extract this URL:
URL := SubStr(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".
}
StringReplace, URLCleansed, URL, ",, All
; Makes a second check to replace extraneous signs.
FixString := % URLCleansed 
vList := "
(
%21	!
%23	#
%24	$
%26	&
%27	'
%28	(
%29	)
%2A	*
%2B	+
%2C	,
%3B	;
%2F	/
%3A	:
%3D	=
%3F	?
%40	@
%5B	[
%5D	]
%20	 
%C2%B4	´
%2E	.
%25	%
%2D	-
%3C	<
%3E	>
%5C	\
%5E	^
%5F	_
%60	`
%7B	{
%7C	|
%7D	}
%7E	~
%22	""
\/	\
)"
Loop, Parse, vList, `n
{
	oTemp := StrSplit(A_LoopField, "`t")
	FixString := StrReplace(FixString, oTemp.1, oTemp.2)
}
oTemp := ""
ClipBoard := "<li style='margin-top:0;margin-bottom:0;vertical-align:middle'><p style='margin:0in;font-family:Calibri;font-size:10.0pt'><a href=" FixString ">" FixString "</a></p></li>"
FileAppend, %ClipBoard%`n
LinkCount += 1

; See if there are any other URLs in this line:
CharactersToOmit := StrLen(URL)
CharactersToOmit += URLStart
URLSearchString := SubStr(URLSearchString, CharactersToOmit)
Gosub, URLSearch  ; Recursive call to self.
return

;**********************************************************************************************

^F1::
CaseMays:
Menu Mays, Add
Menu Mays, DeleteAll
Menu Mays, Add, &UPPERCASE, CCase
Menu Mays, Add, &lowercase, CCase
Menu Mays, Add, &Title Case, CCase
Menu Mays, Add, &a Title to Case, CCase
Menu Mays, Add, &Sentence case, CCase
Menu Mays, Add
Menu Mays, Add, &Remove Spaces, CCase

GetText(Txt)
If NOT ERRORLEVEL
  Menu Mays, Show
Return

CCase:
p:=A_ThisMenuItemPos
If (p=1)
  StringUpper, Txt, Txt
Else If (p=2)
  StringLower, Txt, Txt
Else If (p=3)
  StringLower, Txt, Txt, T
Else If (p=4)
{
StringLower, Txt, Txt
;IMPORTANT! Change short words to be replaced in the following list according to each language or add more
lowers := ["a", "ha", "el", "y", "pero", "o", "para", "las", "es", "para", "por", "los", "con", "en", "que", "un", "de", "del", "la", "una", "cada", "en", "al", "por", "uno", "mi", "tu", "tú", "no", "ni", "sin", "se", "lo", "e", "su", "sí", "ser", "hay"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
;Txt := RegExReplace(Txt, "(*UCP)(^\b|\b(?!(" . low . ")\b))\w+\b|\b\w+\b$", "$T0")
;Txt := RegExReplace(Txt, "((?:^|[.!?-]\s+)[a-z])", "$u1")
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
}
Else If (p=5)
{
  StringLower, Txt, Txt
  Txt := RegExReplace(Txt, "((?:^|[.!?]\s+)[a-z])", "$u1")
}
Else If (p=7)
{
  Loop 
  { 
  StringReplace, Txt, Txt, %A_Space%%A_Space%, %A_Space%, UseErrorLevel 
  if ErrorLevel = 0  
    break 
  }
}
PutText(Txt)
Return

GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^{vk43} ;Ctrl C
ClipWait 0.5
If ERRORLEVEL
{
  Clipboard := SavedClip
  MyText =
  Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}

PutText(MyText)
{
SavedClip := ClipboardAll 
Clipboard =
Sleep 20
Clipboard := MyText
Send ^{vk56} ;Ctrl V
Sleep 100
Clipboard := SavedClip
Return
}

ClipToDoc(FileName) {
	oWord := ComObjCreate("Word.Application")
	Document := oWord.Documents.Add
	; oWord.Selection.Paste
	oWord.Selection.PasteAndFormat(16) ; wdFormatOriginalFormatting = 16
	Document.SaveAs(FileName)
	Document.Close()
	oWord.Quit
}

GetImageSize(imageFilePath) {
   if !hBitmap := LoadPicture(imageFilePath, "GDI+")
      throw "Failed to load the image"
   VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
   DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
   DllCall("DeleteObject", "Ptr", hBitmap)
   Return { W: NumGet(BITMAP, 4, "UInt"), H: NumGet(BITMAP, 8, "UInt") }
}

crop(FilePath, x, y, w, h) {
	static IP
	img := ComObjCreate("WIA.ImageFile")
	img.LoadFile(FilePath)
	if (!IP) {
		IP:=ComObjCreate("WIA.ImageProcess")
		ip.Filters.Add(IP.FilterInfos("Crop").FilterID)
	}
	
	; x,y,r,b are the number of pixels to crop from each edge. They cannot be negative numbers.
	ip.filters[1].properties("Left") := x
	ip.filters[1].properties("Top") := y
	if ((r := img.width - w - x) < 1)
		r := 0
	if ((b := img.height - h - y) < 1)
		b := 0
	ip.filters[1].properties("Right") := r
	ip.filters[1].properties("Bottom") := b
	img := IP.Apply(img)
	FileDelete, %FilePath%
	while FileExist(FilePath)
		Sleep, 10
	img.SaveFile(FilePath)
	return
}
;*******************************************************************************
Nothing:
Run, https://www.autohotkey.com/boards/viewtopic.php?t=92963
Return

Tray_Open:
  ListLines
return

MaxClipsGui:
Gui, MxClips: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, MxClips: Font, S10 Bold, Verdana
Gui, MxClips: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, MxClips: Add, Text, cYellow BackgroundTrans x35 y6 W290 h32 GuiMove, Maximum Number of Clipboards
;Gui, MxClips: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, MxClips: Font, S12 Bold, Verdana
Gui, MxClips: Add, Edit, x55 y38 vMaxClipsS%NumberTemp% h28 w168, %MaxClips%
Gui, MxClips: Font, S8 Bold, Verdana
Gui MxClips: Add, Button, x55 y72 w70 h20 gMxClipsSave, OK
Gui MxClips: Add, Button, x153 y72 w70 h20 gClipCancel, Cancel
xClips := Floor((A_ScreenWidth/2)-448)
yClips := Floor((A_ScreenHeight/2)-200)
Gui, MxClips: Show, x%xClips% y%yClips% w290
Return

^!F4::
NewSession:
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
;Gui, Session:+Owner
Gui, Session: Font, S10 Bold, Verdana
Gui, Session: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, Session: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, Session: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, Session: Font, S8 Bold, Verdana
Gui, Session: Add, Edit, x5 y40 vSessEdit h20 w544, New Session
Gui Session:Add,  Button, x20 y70 w70 h20 gSessionSave, OK
Gui Session:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
Gui, Session: Show, x%xSess% y%ySess% w562
Return

SessionSave:
FileDelete, SessionTemp.txt
Gui, Session: Submit
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal1 := A_Index
FileCreateDir, HTMLTemp%SessionTotal1%
FileAppend, %A_ScriptDir%, SessionTemp.txt
FileSession := "\HTMLTemp" SessionTotal1 "\Session.txt"
FileAppend, %FileSession%, SessionTemp.txt
;Sleep, 3500
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%
Menu, SessionID, DeleteAll
Iniciate:=1
;Gosub, NewWindow
SessEdit :=""
Gosub, ReloadSession
Return

MxClipsSave:
Gui, MxClips: Submit
MaxTemp:=MaxClipsS%NumberTemp%
MaxClips=%MaxTemp%
IniWrite, %MaxTemp%, Config.ini, Setting_Clipboard, MaxClips
NumberTemp++
MaxTemp:=
MaxClips:=
Return

ClipCancel:
Gui, Session: Submit
Gui, MxClips:Destroy
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
; Gui, RenSession:+Owner
Gui, RenSession: Font, S10 Bold, Verdana
Gui, RenSession: Add, Picture, x0 y0 h20 w564 h32, Resources\Fondo_Limp.png
Gui, RenSession: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
;Gui, RenSession: Add, Text, x5 y6 h20 w549, Session Name:
Gui, RenSession: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, RenSession: Font, S8 Bold, Verdana
Gui, RenSession: Add, Edit, x5 y40 vReSessEdit h20 w544, %RenSession%
Gui RenSession:Add,  Button, x20 y70 w70 h20 gRenSessionSave, OK
Gui RenSession:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
If Position=0
{
xSess := pXm-846
ySess := pYm-148 ;96
}
If Position=1
{
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
}
Gui, RenSession: Show, x%xSess% y%ySess% w564
Return

RenSessionSave:
Gui, RenSession: Submit
FileDelete, HTMLTemp\Session.txt
FileAppend, %ReSessEdit%, HTMLTemp\Session.txt
ReSessEdit :=""
Gosub, RButton
Return

/*
Paused:
Paused:=!Paused
IfEqual,Paused,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Orange.ico
IfEqual,Paused,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Pause Script
Menu,Tray,Icon,,,1
Pause,Toggle,1
Return
*/

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n    Can be Used on Another Occasion.
IfMsgBox No
Return
IndiDir := 0
SumDir := 0
loop, %SessionTotal%
{
FileDelete, SessionCount.txt
FileAppend, %A_ScriptDir%, SessionCount.txt
FullFile:="\HTMLTemp" A_Index "\*.*"
NameDir := "HTMLTemp" A_Index
FileAppend, %FullFile%, SessionCount.txt
FileRead, CountFiles, SessionCount.txt
loop, %CountFiles%
FilesCount := % Floor(A_Index/6)
;MsgBox, %FilesCount% - %NameDir%
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}
If InDir<>DirectoryCount
   {
   Loop %SumDir%
   {
   Loop %DirectoryCount%
	if !FileExist("HTMLTemp" A_Index)
	{
	NumberFile1 := A_Index
	FileSup1 := NumberFile1+1
	Sup1 := ScriptDir "HTMLTemp" Filesup1
	NumF1:= ScriptDir "HTMLTemp" NumberFile1
	;MsgBox, %Sup1% - %NumF1%
	FileMoveDir %Sup1%, %NumF1%, R
	;Filemove, %Sup%, %NumF%
	;FileMoveDir %DirectorySess%, %DirectorySess00%, R
	}
    }
DirectoryCount:=DirectoryCount-SumDir
Menu, SessionID, DeleteAll
Gosub, ReloadSession
}
Return

^F12::
Stanby:
Suspend:=!Suspend
IfEqual,Suspend,1, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Red.ico
IfEqual,Suspend,0, Menu,Tray,Icon,%A_ScriptDir%\Resources\Scissors_Green.ico
Menu, tray, ToggleCheck, &Suspend Clipboard Utility
Menu,Tray,Icon,,,1
Suspend,Toggle
Return

SuspendHotkeys:
Menu, Tray, ToggleCheck, Keep Only Hotkeys Necessary
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendHotkeys=1 
{
SuspendHotkeys:=0
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, !F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
IniWrite, 0, Config.ini, Setting_Clipboard, SuspendHotkeys
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated Only the Necessary Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendHotkeys:=1
Hotkey, ^Up, Toggle
Hotkey, ^F4, Toggle
Hotkey, ^F5, Toggle
Hotkey, !F5, Toggle
Hotkey, ^F6, Toggle
Hotkey, ^F7, Toggle
Hotkey, ^F8, Toggle
Hotkey, ^F10, Toggle
Hotkey, ^F11, Toggle
Hotkey, ^F12, Toggle
IniWrite, 1, Config.ini, Setting_Clipboard, SuspendHotkeys
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Activated All Hotkeys
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendThumbnail:
Menu, ThumbnailID, ToggleCheck, Postpone Thumbnail Creation
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If SuspendThumbnail=0 
{
SuspendThumbnail:=1
IniWrite, 1, Config.ini, Setting_Clipboard, SuspendThumbnail
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
SuspendThumbnail:=0
IniWrite, 0, Config.ini, Setting_Clipboard, SuspendThumbnail
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Thumbnail Creation Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendBasicClip:
Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ClipBoardEnabled=0 
{
ClipBoardEnabled:=1
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
ClipBoardEnabled:=0
IniWrite, 0, Config.ini, Setting_Clipboard, ClipBoardEnabled
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Basic Clipboard Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

SuspendNotifClip:
Menu, BasicClipID, ToggleCheck, Deactivate Notifications in Tray
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If NotifyClip=0
{
NotifyClip:=1
IniWrite, 1, Config.ini, Setting_Clipboard, NotifyClip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification,Notifications in Tray Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
else
{
NotifyClip:=0
IniWrite, 0, Config.ini, Setting_Clipboard, NotifyClip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Notifications in Tray Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1500
SplashTextOff
}
Return

RestoreSettings:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Restore All Values to Default? `n`n (The Application will Restart)
IfMsgBox No
Return
IniWrite, 1, Config.ini, Setting_Clipboard, Style
IniWrite, 1, Config.ini, Setting_Clipboard, ShowTip
IniWrite, 1, Config.ini, Setting_Clipboard, SuspendHotkeys
IniWrite, 0, Config.ini, Setting_Clipboard, SuspendThumbnail
IniWrite, 1, Config.ini, Setting_Clipboard, NotifyClip
IniWrite, 15, Config.ini, Setting_Clipboard, MaxClips
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
Reload
Return

DeleteBasic:
MsgBox, 0x1024,, Want to Delete all Basic Clipboards? `n`n It will be Deleted from the Hard Disk, `n Only the Last one will Remain in Memory.
IfMsgBox No
Return
FileDelete, TempClip\*.*
Reload
Return

SwitchStyle:
Menu, BasicClipID, ToggleCheck, Switch to Simple Style
If Style=1
{
Style=0
IniWrite, 0, Config.ini, Setting_Clipboard, Style
}
else
{
Style=1
IniWrite, 1, Config.ini, Setting_Clipboard, Style
}
Iniciate := 1
Gosub, Style
Return

DisableTip:
Menu, BasicClipID, ToggleCheck, Deactivate Tip
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If ShowTip=1
{
ShowTip=0
IniWrite, 0, Config.ini, Setting_Clipboard, ShowTip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, Tip have been Disabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
else
{
ShowTip=1
IniWrite, 1, Config.ini, Setting_Clipboard, ShowTip
SoundPlay, Resources\Close Window.mp3
SplashTextOn,500, 80, Notification, TIP has been Enabled
WinMove, Notification,, xSplash1, ySplash1
Sleep, 1200
SplashTextOff
}
Iniciate := 1
Return

CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
;MsgBox, %Corpus%
Filecopy %Corpus%, CorpusTemp.html
RunWait, %A_WorkingDir%\Addons\wkhtmltoimage.exe --width 640 CorpusTemp.html Image_Temp.jpg,,hide
Gosub, ResizeH
ImageCount1 := "HTMLTemp\Image" A_Index ".jpg"
FileMove, Image_Temp.jpg, %ImageCount1%
FileDelete, CorpusTemp.html
CountImg++
}
If CountImg=0
{
MsgBox, All Clipboard already have Thumbnails.
}
Else
{
MsgBox, Finished process.`n`n %CountImg% Thumbnail(s) has been Created.
}
Return

/*
;Loop, 6
MsgBox, %CorpusCount%
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, No existe Imagen %A_Index%
}
;Else
;{
;MsgBox, Sí existe Imagen %A_Index%
;}

idx = 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
;MsgBox, %CorpusCount% - %A_Index% - %idx%
Loop, %CorpusCount%
idx++
;MsgBox, %CorpusCount% - %A_Index% - %idx%
;Imagecheck :="HTMLTemp\Image" A_Index ".jpg"
if !FileExist("h:\Download\Script\MultiClipboard Preview 4.1n\HTMLTemp\Image" A_Index ".jpg")
{
MsgBox, Image does not Exist %A_Index% %idx%
}
*/

EditScript:
Run Edit %A_ScriptName%
Return

^!F7::
Reloaded:
Reload
Return

!F5::
NotifyTrayClick_201:
SoundPlay, Resources\Close Window.mp3
  if(StrLen(previousClip)<50)
   {
   CornerNotify(1, "Basic Clipboard", PreviousClip)
   } 
   Else
    {
    StringMid, CutTooTip, PreviousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
   }
Return

/*
^!F7::
;xSplash := Floor((A_ScreenWidth/2)-450)
;ySplash := Floor((A_ScreenHeight/2)-200)
xSplash := A_ScreenWidth-506
ySplash := A_ScreenHeight-180
SplashTextOn, 500, 80, Content of the current clipboard, %Clipboard%
WinMove, Content of the current clipboard,, xSplash, ySplash
;SplashTextOn,,, Displays only a title bar.
Sleep, 1000
SplashTextOff
;SplashTextOn,,, %Clipboard%
;WinMove,,, xSplash, ySplash
;Sleep, 1000
;SplashTextOff
Return
*/

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
		  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	CRCClip:=LC_CRC32(Currentclip)
	Gosub, DuplicateCRC
	CRC32.insert(Object())
        Max_CRC:=CRC32.MaxIndex()
	CRC32[Max_CRC]:=CRCClip
	if (Max_CRC>MaxClips)
	  {
	  CRC32.removeAt(1)
	  }
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	  {
	  ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	  FileAppend, %Clip%, %ClipTemp%
	  }
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2% 
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  ;DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}

DuplicateCRC:
;Max_CRC:=CRC32.MaxIndex()
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  FileDelete, TempClip\Clip%XClip%.clip
  Gosub, RelocateFile
}
Return

RelocateFile:
Loop, %MaxClips%
  if !FileExist("TempClip\Clip" A_Index ".clip")
     {
     NumberClip := A_Index
     ClipSup := NumberClip+1
     Sup2 := "TempClip\Clip" ClipSup ".clip"
     NumF2:= "TempClip\Clip" NumberClip ".clip"
     FileMove, %Sup2%, %NumF2%
     }
Return
I don't know if I like to be responsible for making this utility work well. :lol: ;)

Reissued 06-11. The title of a clipboard was not being saved properly because I had changed the name of the variable and had not made the necessary change to the renaming routine in the file.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Multiple clipboard, with title and URL of web page

07 Nov 2021, 16:25

Some changes in the basic clipboard (In Spain we call what I'm doing "marear la perdiz" :lol: , it's not exactly what I mean "beat about the bush" :? It's more like "complicating what should be simple.").

There are two styles, which are changed on line 31.

The 0, divides in a menu and a submenu the total of the clipboards, but does not show the favorite files.

Image

Style 1, only shows a menu. I've added another variable (ShowClip, in line 25), which defines the total number of clipboards shown, to limit the size of the menu and not take up too much screen. This menu does show favorites.

Image

This way of proceeding, in two types of menus, is in case you want to increase the number of clipboards and you can work in two different ways: see all or see only a part, the last ones.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
#Include Resources\libcrypt.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite, ShowClip
ShowClip:=20
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 30
Style=0

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip
  }
DisableWrite:=0
}

If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFEFFB1 ;background color of the menu R
            , "iconssize" : 32          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R
            , "iconssize" : 32          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        CutTip:= st_wordWrap(CutTooTip)
	;Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	;Gosub, CutWidthTip
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     WinSet, Transparent, 210, ahk_class #32768
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     ;MsgBox, %ClipTool% - %Favorite%
     Global ClipTool, Favorite
     ClipTool:=obj.tooltip
     Favorite:=obj.name
     ;Favorite:=item.name
     ;Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg = "onshow" ) ; ~=
;    tooltip % "menu " msg ": " obj.handle
   if ( msg = "onclose" ) ; ~=
     Gosub, ChangeClipState
}
;**************************************************************
^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
Global WinUMID, mx, my
MouseGetPos, mx, my, WinUMID
;Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
newmenu1 := pm.CreateMenu( menuParams1 )

If Style=1
{
menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xFFFF33}) ; 0xFFFF33, 0xF2F1C5
menu.Add()
Loop, %ShowClip%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}
if FileExist("TempClip\Favorites.fav")
Loop, read, TempClip\Favorites.fav
{
newmenu1.add( { "name" : A_LoopReadLine, "noicons": 1, "bold": 1} )
;newmenu1.add( { "name" : A_LoopReadLine , "noicons": 1, "bold": 1, "tooltip" : A_LoopReadLine} )
}
}

If Style=0
{
  menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
   , "bold"    : 1
   , "icon"    : "Resources\Clipboard Utility.ico"
   , "tcolor"  : 0xFFFF33 ; 0xcf630c 0xFFFFA9 0x303b6d
   , "bgcolor" : 0x363E69}) ; 0xFFFFA9 0xF2F1C5
   menu.Add()

Half_Index:= Max_Index/2
Half_Index1:= (Max_Index/2)+1
while Max_Index>=ClipBoardHistory.minIndex()
  {
  Descrip:=Description[Max_Index]
  Global Min_Index
  Min_Index:= (Description.maxindex()-Max_Index+1)

 MenuString1:="   &" . Min_Index . ".   " . Descrip
 MenuString:= "   " Min_Index . ".   " . Descrip
 
If Min_Index>=%Half_Index1%
   {
   newmenu1.add( { "name" : MenuString, "noicons": 1, "bold": 1, "tooltip" : ClipBoardHistory[Max_Index]} )
   }
If Min_Index between 10 and %Half_Index%
   {
   menu.Add( { "name" : MenuString, "bold" : 1, "Index" : Max_Index, "noicons": 1, "tooltip" : ClipBoardHistory[Max_Index]})
   }
If Min_Index<=9
   {
   menu.Add( { "name" : MenuString1, "bold" : 1, "Index" : Max_Index, "noicons": 1, "tooltip" : ClipBoardHistory[Max_Index]})
   }
  Max_Index--
  }
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return
;**************************************************************

PasteOne:
If !ClipTool
{
Clipboard:=""
Clipboard:=Favorite
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Else
{
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%	  
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
                  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	CRCClip:=LC_CRC32(Currentclip)
	Gosub, DuplicateCRC
	CRC32.insert(Object())
        Max_CRC:=CRC32.MaxIndex()
	CRC32[Max_CRC]:=CRCClip
	if (Max_CRC>MaxClips)
	  {
	  CRC32.removeAt(1)
	  }
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	;CRC32.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2%
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  ;DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

DuplicateCRC:
;Max_CRC:=CRC32.MaxIndex()
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  FileDelete, TempClip\Clip%XClip%.clip
  Gosub, RelocateFile
}
Return

RelocateFile:
Loop, %MaxClips%
  if !FileExist("TempClip\Clip" A_Index ".clip")
     {
     NumberClip := A_Index
     ClipSup := NumberClip+1
     Sup2 := "TempClip\Clip" ClipSup ".clip"
     NumF2:= "TempClip\Clip" NumberClip ".clip"
     FileMove, %Sup2%, %NumF2%
     }
Return

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}

Version where you have access to both menu modes. One with the keyboard shortcut CTRL+UP and the other with the CTRL+Mbutton (middle button).
I have changed the colors of the second menu. Also above.

Code: Select all

;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92963
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory
#SingleInstance, Force
#InstallMousehook
#Persistent
#Include Resources\PUM_API.ahk ;Source: https://apathysoftworks.com/ahk/index.html
#Include Resources\PUM.ahk
#Include Resources\libcrypt.ahk
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

Menu, Tray, Icon, Resources\Scissors_Green.ico
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
ClipBoardEnabled:=1
previousClip:=clipboard
NotifyClip :=1
Global MaxClips, CLipM, Style, FirstTime, ShowTip, DisableWrite, ShowClip
ShowClip:=20
DisableWrite:=0
ShowTip :=1
;FirstTime:=0
CLipM:= obj.id()
MaxClips := 30
Style=0

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

if FileExist("TempClip\Clip1.clip")
{
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index
Loop, %NumberClip0%
  {
  ReadClip:= "TempClip\Clip" A_Index ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip
  }
DisableWrite:=0
}

Style:
If Style=0
{
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0xFFFFFF         ;selection text color
                ,"selBGColor" :  0x036FC5       ;selection background color, -1 means invert current color , 0xFFFFA9, 0x036FC5
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
                ,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFEFFB1   ;background color of the menu R, #ffffeb, 0xFFFFF4, 0xFFFF33, 0xFFFF8E, 0xFEFFB1 
            , "iconssize" : 32          ;size of icons in the menu
            , "tcolor" : 0x064D85} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}
If Style=1
{
pumParams := { "SelMethod" : "fill"             ;item selection method, may be frame,fill
                ,"selTColor" : 0x363E69         ;selection text color 0x02192C 0xFFFFFF
                ,"selBGColor" :  0xFFFFA9       ;selection background color, -1 means invert current color 0x036FC5, 0xFFFF8E, 0xFFFFA9, 0xF2F1C5 
                ,"oninit"      : "PUM_out"      ;function which will be called when any menu going to be opened
                ,"onuninit"    : "PUM_out"      ;function which will be called when any menu going to be closing
                ,"onselect"    : "PUM_out"      ;function which will be called when any item selected with mouse (hovered)
                ,"onrbutton"   : "PUM_out"      ;function which will be called when any item right clicked
                ,"onmbutton"   : "PUM_out"      ;function which will be called when any item clicked with middle mouse button
                ,"onrun"       : "PUM_out"      ;function which will be called when any item clicked with left mouse button
                ,"onshow"      : "PUM_out"      ;function which will be called before any menu shown using Show method
                ,"onclose"     : "PUM_out"      ;function called just before quitting from Show method
                ,mnemonicCMD   : "run"		; Other Option: ,mnemonicCMD   : "select"
		,"pumfont"     : "Segoe UI"}

;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0x363E69   ;background color of the menu R 
            , "iconssize" : 32          ;size of icons in the menu
            , "tcolor" : 0xFFFF33} ; text color of the menu items 036FC5 1A86DB 054C84 064D85 02192C 043053
}

;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )

PUM_out( msg, obj )
{
if ( msg = "onselect" )
     If !ShowTip=0
     {
     Tooltip:=obj.tooltip
     if(StrLen(Tooltip)>800)
	{
	StringMid, CutTooTip, Tooltip, 1, 800
        CutTip:= st_wordWrap(CutTooTip)
	;Gosub, CutWidthTip
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
	} 
     Else
	{
	CutTooTip:=Tooltip
	;Gosub, CutWidthTip
	CutTip:= st_wordWrap(CutTooTip)
	Rectangle:=obj.getRect()
        x:=Rectangle.right+3
        y:=Rectangle.top
        CoordMode, ToolTip, Screen
        tooltip %CutTip%,%X%,%Y%
        }
     WinSet, Transparent, 210, ahk_class #32768
     CutWidthTip:
     CutTip := ""
     MaxLen := 80
     TipLen := StrLen(CutTooTip)
     LastChar := 1
       Loop
         {
         If (LastChar >= TipLen)
         Break
         CutTip := CutTip . SubStr(CutTooTip, LastChar, MaxLen) . "`n"
         LastChar += MaxLen
         }
     Return
     }
  if ( msg = "oninit" )
     {
     WinSet, Transparent, 210, ahk_class #32768
     SoundPlay, Resources\Close Window.mp3
     ;sleep, 300       
     }
;  if ( msg = "oninit" )
;    tooltip % "menu init: " obj.handle
;  if ( msg = "onuninit" )
;    tooltip % "menu uninit: " obj.handle
   if ( msg = "onrbutton" )
     Gosub, PasteClip
  if ( msg = "onmbutton" )
     {
     SoundPlay, Resources\Close Window.mp3
     CLipM:=obj.id
     Tooltip:=obj.tooltip
     If !Style=0
      {
      CLipM:=CLipM-2
      }
     FileAppend, %Tooltip%`n`n, TempClip.clip
     If ChangeClipEnable=1
	{
	Clipboard:=""
	ClipBoardEnabled=1
	ChangeClipEnable=0
	}
     }
  if ( msg = "onrun" )
     {
     ;MsgBox, %ClipTool% - %Favorite%
     Global ClipTool, Favorite
     ClipTool:=obj.tooltip
     Favorite:=obj.name
     ;Favorite:=item.name
     ;Global ClipTool
     ClipTool:=obj.tooltip
     Gosub, PasteOne
     }
;  if ( msg = "onshow" ) ; ~=
;    tooltip % "menu " msg ": " obj.handle
   if ( msg = "onclose" ) ; ~=
     Gosub, ChangeClipState
}
;**************************************************************
;^Up::
^MButton::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
Global WinUMID, mx, my
MouseGetPos, mx, my, WinUMID
Style:=1
Gosub, Style
FileDelete, TempClip.clip
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
newmenu1 := pm.CreateMenu( menuParams1 )

If Style=1
{
menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
            , "bold"    : 1
	    , "icon"    : "Resources\Clipboard Utility.ico"
	    , "tcolor"  : 0x303b6d ; 0xcf630c
	    , "bgcolor" : 0xFFFF33}) ; 0xFFFF33, 0xF2F1C5
menu.Add()
Loop, %ShowClip%
{
	Descrip:=Description[Max_Index]
	Global Min_Index
	Min_Index:= (Description.maxindex()-Max_Index+1)
	if Min_Index<10
	  MenuString:="   &" . Min_Index . ".   " . Descrip
	else
	  MenuString:= "   " Min_Index . ".   " . Descrip
	
  menu.Add( { "name" : MenuString
            , "bold" : 1
			, "Index" : Max_Index
			, "noicons": 1
			, "tooltip" : ClipBoardHistory[Max_Index]})
	Max_Index--
}
if FileExist("TempClip\Favorites.fav")
Loop, read, TempClip\Favorites.fav
{
newmenu1.add( { "name" : A_LoopReadLine, "noicons": 1, "bold": 1} )
;newmenu1.add( { "name" : A_LoopReadLine , "noicons": 1, "bold": 1, "tooltip" : A_LoopReadLine} )
}
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return

^Up::
Max_Index:=Description.maxIndex()
if !Max_Index
{
MsgBox, There are Currently no Clipboards
SoundPlay, Resources\Close Window.mp3
return
}
Global WinUMID, mx, my
MouseGetPos, mx, my, WinUMID
Style:=0
Gosub, Style
Clipboard:=""
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
menu := pm.CreateMenu( menuParams1 )
newmenu1 := pm.CreateMenu( menuParams1 )
If Style=0
{
  menu.Add( { "name" : "     Clipboard Utility", "submenu" : newmenu1
   , "bold"    : 1
   , "icon"    : "Resources\Clipboard Utility.ico"
   , "tcolor"  : 0xFFFF33 ; 0xcf630c 0xFFFFA9 0x303b6d
   , "bgcolor" : 0x363E69}) ; 0xFFFFA9 0xF2F1C5
   menu.Add()

Half_Index:= Max_Index/2
Half_Index1:= (Max_Index/2)+1
while Max_Index>=ClipBoardHistory.minIndex()
  {
  Descrip:=Description[Max_Index]
  Global Min_Index
  Min_Index:= (Description.maxindex()-Max_Index+1)

 MenuString1:="   &" . Min_Index . ".   " . Descrip
 MenuString:= "   " Min_Index . ".   " . Descrip
 
If Min_Index>=%Half_Index1%
   {
   newmenu1.add( { "name" : MenuString, "noicons": 1, "bold": 1, "tooltip" : ClipBoardHistory[Max_Index]} )
   }
If Min_Index between 10 and %Half_Index%
   {
   menu.Add( { "name" : MenuString, "bold" : 1, "Index" : Max_Index, "noicons": 1, "tooltip" : ClipBoardHistory[Max_Index]})
   }
If Min_Index<=9
   {
   menu.Add( { "name" : MenuString1, "bold" : 1, "Index" : Max_Index, "noicons": 1, "tooltip" : ClipBoardHistory[Max_Index]})
   }
  Max_Index--
  }
}

MouseGetPos, xpos5, ypos5
xpos5 := xpos5-200
ypos5 := ypos5-100
item := menu.Show( xpos5, ypos5 ), Basic Clipboard ; <<<<Menu--- Source: https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/

Menu.destroy()
Tooltip
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
;Max_Index:=ClipBoardHistory.maxIndex()
Clipboard:=""
return
;**************************************************************

PasteOne:
If !ClipTool
{
Clipboard:=""
Clipboard:=Favorite
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Else
{
Clipboard:=""
Clipboard:=ClipTool
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
Send, ^v
Sleep, 200
SoundPlay, Resources\Close Window.mp3
;Send, {asc 013}
}
Return

PasteClip:
FileRead, Clipboard, TempClip.clip
Sleep, 300
WinActivate, ahk_id %WinUMID%
MouseMove, x%mx%, y%my%, 0
send, ^v
SoundPlay, Resources\Clipboard_Sound.mp3
If ChangeClipEnable=1
  {
  Clipboard:=""
  ClipBoardEnabled=1
  ChangeClipEnable=0
  }
Clipboard:=""
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

^F5::
Max_Box:=ClipBoardHistory[Max_Index]
if(StrLen(Max_Box)<50)
  {
   CornerNotify(2, "Actual Clipboard", previousClip)
   } 
   Else
    {
    StringMid, CutTooTip, previousClip, 1, 100
    CutTip:= st_wordWrap(CutTooTip)
  CornerNotify(1, "Basic Clipboard", CutTip)
  }
Return

OnClipboardChange:
	if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
	{
	CurrentClip=%clipboard% 
	If (A_EventInfo=1) and (CurrentClip <> PreviousClip)
	  {
	  PreviousClip=%clipboard%	  
		If NotifyClip=1
		 {
		  SoundPlay, Resources\Close Window.mp3
		  if(StrLen(previousClip)<50)
		   {
		   CornerNotify(1, "Basic Clipboard", PreviousClip)
		   } 
		   Else
		    {
		    StringMid, CutTooTip, PreviousClip, 1, 100
		    CutTip:= st_wordWrap(CutTooTip)
                  CornerNotify(1, "Basic Clipboard", CutTip)
		  }
		 }	
	CRCClip:=LC_CRC32(Currentclip)
	Gosub, DuplicateCRC
	CRC32.insert(Object())
        Max_CRC:=CRC32.MaxIndex()
	CRC32[Max_CRC]:=CRCClip
	if (Max_CRC>MaxClips)
	  {
	  CRC32.removeAt(1)
	  }
	ClipSave(ClipBoardHistory,Currentclip, MaxClips)	 
	  }
        }
Return

ClipSave(ClipBoardHistory,Clip,MaxClips)
{
	ClipBoardHistory.insert(Object())
	Global Max_Index
	Max_Index:=ClipBoardHistory.MaxIndex()
	ClipBoardHistory[Max_Index]:=Clip	
	If DisableWrite=0
	{
	ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	FileAppend, %Clip%, %ClipTemp%
	}
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	;CRC32.removeAt(1)
	FileDelete, TempClip\Clip1.clip
	Loop %MaxClips%
	if !FileExist("TempClip\Clip" A_Index ".clip")
		{
		NumberFile := A_Index
	        FileSup := NumberFile+1
		Sup := "TempClip\Clip" Filesup ".clip"
		NumF:= "TempClip\Clip" NumberFile ".clip"
		Filemove, %Sup%, %NumF%
		}
	}
}

CreateDescription:
Descrp:=ClipBoardHistory[Max_Index]
if(StrLen(Descrp)<80)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-25 
  StringMid, itemTemp1, Descrp, 1, 50
  StringTrimLeft, itemTemp2, Descrp, %toCut% 
  Descrip=%itemTemp1%...%itemTemp2%
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrip
  ;DescriptionClip:=Description[Max_Descr]  
  } 
if (Max_Descr>MaxClips)
 Description.removeAt(1)
Return

DuplicateCRC:
;Max_CRC:=CRC32.MaxIndex()
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  FileDelete, TempClip\Clip%XClip%.clip
  Gosub, RelocateFile
}
Return

RelocateFile:
Loop, %MaxClips%
  if !FileExist("TempClip\Clip" A_Index ".clip")
     {
     NumberClip := A_Index
     ClipSup := NumberClip+1
     Sup2 := "TempClip\Clip" ClipSup ".clip"
     NumF2:= "TempClip\Clip" NumberClip ".clip"
     FileMove, %Sup2%, %NumF2%
     }
Return

;---------------------------------------------------------------
;http://www.autohotkey.com/board/topic/94458-msgbox-or-traytip-replacement-monolog-non-modal-transparent-msg-cornernotify/ Author: robertcollier4, LAGOMORPH
CornerNotify(secs, title, message, position="b r") { 
	CornerNotify_Create(title, message, position)
	if (secs = "p") ;persistent mode
		return
	millisec := secs*1000*-1
	SetTimer, CornerNotifyBeginFadeOut, %millisec%
}

CornerNotify_Create(title, message, position="b r") {
	global cornernotify_title, cornernotify_msg, w, curtransp, cornernotify_hwnd
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui, CornerNotify:+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,CornerNotify:Add, Picture, x18 y10 w30 h30, Resources\Scissor_Green.png
	Gui,CornerNotify:Color, 202020 ;background color
	Gui,CornerNotify:Font, cYellow s15 wbold, Arial ; c5C5CF0
	Gui,CornerNotify:Add, Text, x70 y12 w290 vcornernotify_title, %title%
	Gui,CornerNotify:Font, cF0F0F0 s12 wnorm
	Gui,CornerNotify:Add, Text, x15 y56 w290 vcornernotify_msg, %message%
	Gui,CornerNotify:Show, NoActivate W300
	WinMove(cornernotify_hwnd, position)
	Return
}

CornerNotify_ModifyTitle(title) {
	global cornernotify_title
	GuiControl,Text,cornernotify_title, %title%
}

CornerNotify_ModifyMessage(message) {
	global cornernotify_msg
	GuiControl,Text,cornernotify_msg, %message%
}

CornerNotify_Destroy() {
	global curtransp
	curtransp := 0
	Gui,CornerNotify: Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotifyBeginFadeOut:
	SetTimer, CornerNotifyBeginFadeOut, Off
	SetTimer, CornerNotify_FadeOut_Destroy, 10
Return

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui,CornerNotify: Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return
;---------------------------------------------------------------
; Modification of WinMove function by Learning One (http://www.autohotkey.com/board/topic/72630-gui-bottom-right/#entry461385)

; position argument syntax is to create a string with the following:
; t=top, vc= vertical center, b=bottom
; l=left, hc=horizontal center, r=right

WinMove(hwnd,position) {   ; by Learning one
   SysGet, Mon, MonitorWorkArea
   WinGetPos,ix,iy,w,h, ahk_id %hwnd%
   x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ?  (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
   y := InStr(position,"t") ? MonTop : InStr(position,"vc") ?  (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
   WinMove, ahk_id %hwnd%,,x,y
}
;---------------------------------------------------------------

st_wordWrap(string, column=75, indentChar="")
{
    indentLength := StrLen(indentChar)
     
    Loop, Parse, string, `n, `r
    {
        If (StrLen(A_LoopField) > column)
        {
            pos := 1
            Loop, Parse, A_LoopField, %A_Space%
                If (pos + (loopLength := StrLen(A_LoopField)) <= column)
                    out .= (A_Index = 1 ? "" : " ") A_LoopField
                    , pos += loopLength + 1
                Else
                    pos := loopLength + 1 + indentLength
                    , out .= "`n" indentChar A_LoopField
             
            out .= "`n"
        } Else
            out .= A_LoopField "`n"
    }
     
    Return SubStr(out, 1, -1)
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], robforAHK2 and 119 guests