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

14 Nov 2021, 16:31

Hi.

I got into a dark and huge swamp :? . The two types of basic clipboard menus and the new variable of how many clipboards can be displayed led to a lot of complications :crazy: . I had tried it to raise the clipboard number, but not to lower the number.

Being stuck in a swamp, the clipboard had an identity crisis: what is a clipboard, what is its meaning? Computer science has little trouble defining what an object is, but in philosophy this simple question is more complicated. Do categories exist, or are they just a human construct? Is reality shaped by human language or do certain concepts exist beforehand? :lol:

To try to get out of the quagmire I opted not to save the clipboards one by one, but at the end. I ended up going deeper into the swamp. Empty arrays were created. I looked up how to control them and how to delete them. The code:

Code: Select all

for index, value in ClipBoardHistory
    if (value="")
     {
     ClipBoardHistory.removeAt(index)
     Description.removeAt(index)
     CRC32.removeAt(index)
     }
It does not work well. Randomly erases sometimes two or three. Running that code several times deletes all of them, I put it in a loop, when in itself is a loop (line 690 and following). I searched the internet for options, none good. They advised to move to other arrays and then rename them. The biga.ahk libraries do it well https://www.npmjs.com/package/biga.ahk , works well in general with arrays and objects), but I opted to leave the double loop.

(In fact you don't have to create empty arrays, but in the end I chose to control that possibility that may never happen. If a script works well they are not created.)

I couldn't get out of the swamp until yesterday. I'm out of it now (I think!). :roll:

Since the last revision the code has increased by more than 200 lines. All in the direction that all the variables that come into play all work well and in harmony.

Now you have two options with the basic clipboard. Only save the clipboards to the hard disk at the end, or one by one (as it was before): is a safer system, because if they are saved at the end and if the computer or the program freezes, the clipboards are lost, but it is more expensive in terms of optimization of the program; the option is in the submenu of the basic clipboard). In addition, there are the two types of menus - described in the previous post - and the variable so that only part of the clipboards are displayed in one of the menus. This is a type of menu for those who only want to see the latest clipboards. (The minimum cannot be lowered below 9 because of the menu structure, as it is now)

I've tried to think of all the possible variations of menu types and variables and that there are no conflicts, but I'm not entirely sure that there isn't something wrong yet.

If you are using this utility and you want to use this version, you have to delete the "Config.ini" file. for the new script to write the new "Config.ini" file with the new variables.

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
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
;CoordMode, Menu, window
SetBatchLines, -1

OnExit, SaveOnClip ;, Menu

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, 30, Config.ini, Setting_Clipboard, MaxClips
  IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
  IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  }
Gosub, RelocateClips

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
;SuspendThumbnail := 0
;SuspendHotkeys := 1
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite, OneByOne
DisableWrite:=0
;OneByOne:=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)

IniRead, OneByOne, Config.ini, Setting_Clipboard, OneByOne
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip

if FileExist("TempClip\Clip1.clip")
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index

If (NumberClip0>MaxClips)
{
LastFiles:= (NumberClip0-MaxClips)
Loop, %LastFiles%
  {
  LastFiles++
  ReadClip:= "TempClip\Clip" LastFiles ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip  
  }
}
Else
If NumberClip0<=MaxClips
{
 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  
  }
}

If OneByOne=1
  {
  DisableWrite:=0
  }
 Else
  {
  FileDelete, TempClip\Clip*.clip
  }
Gosub, EmptyClean

;**************************************************************************************
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\1569.ico
Menu, BasicClipID, Add, Maximum Number of Clipboards: %MaxClips%, MaxClipsGui
Menu, BasicClipID, Icon, Maximum Number of Clipboards: %MaxClips%, Resources\2084.ico
Menu, BasicClipID, Add, Backup One by One, BackupOneByOne
Menu, BasicClipID, Icon, Backup One by One, Resources\2196.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 Double Menu, SwitchStyle
Menu, BasicClipID, Icon, Switch to Double Menu, 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, OneByOne, Config.ini, Setting_Clipboard, OneByOne
  If OneByOne=1
  {
  Menu, BasicClipID, ToggleCheck, Backup One by One
  }
IniRead, Style, Config.ini, Setting_Clipboard, Style
  If Style=0
  {
  Menu, BasicClipID, ToggleCheck, Switch to Double Menu
  }
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 , 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" )
   {
   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::
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
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}) ;0xF2F1C5
menu.Add()

ShowClipTemp:=ShowClip
If (ShowClipTemp>Max_Index) 
{
ShowClipTemp:=Max_Index
}
Loop, %ShowClipTemp%
{
	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:= % Floor(Max_Index/2)
Half_Index1:= % Floor(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 and Min_Index>9)
;If Min_Index>=%Half_Index%
   {
   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

SaveOnClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

for index, value in ClipBoardHistory
  if (value="")
  {
  ClipBoardHistory.removeAt(index)
  }

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
ExitApp
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

EmptyClean:
Max_Index:=ClipBoardHistory.maxIndex()
Loop, 6 ;%Max_Index% ;This loop is theoretically wrong, because the next one (for index, value) is already in a loop, but the second one doesn't delete all empty arrays at once if there are many of them. It is only solved by adding this loop
  {
  for index, value in ClipBoardHistory
    if (value="")
     {
     ClipBoardHistory.removeAt(index)
     Description.removeAt(index)
     CRC32.removeAt(index)
     }
  }
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, %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
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 :=""
Gui, Edit: Destroy
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:
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:
GetKeyState, state, Control
if (state = "D")
 {
 StringTrimLeft, GoURL, a_guicontrol, 4
 gURL := "HTMLTemp\Text" GoURL ".html"
 NewURL:="HTMLTemp\URL" GoURL ".txt"
 FileDelete, %NewURL%
 FileRead, ExtracURL, %gURL%
 StringTrimLeft, item, ExtracURL, 154 
 StringTrimRight, item2, item, 32 
 LenText := StrLen(item2)
 StringGetPos, pos, item2, >, r1
 Resta:= LenText-pos
 StringTrimRight, item3, item2, %Resta%
 FileAppend, %item3%, %NewURL%
 ;MsgBox, %item2% --- Posición: %pos% --- LenText: %LenText% --- Resta: %Resta%
 ;MsgBox, %item3%
 If !NewURL or SizeFile=0
   {
   MsgBox, URL could not be retrieved
   }
 Gui, ContextClip: Destroy
 Gosub, RButton
 Return
 }
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, 600
	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:
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
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, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y43 h28 w200, Maximum Number of Clipboards:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y41 h20 w40 vMaxClipsS, %MaxClips%
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y74 h28 w200, Number of Clipboard to Show:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y73 h20 w40 vShowClipsS, %ShowClip%
Gui, MxClips: Font, S8 Bold, Verdana
Gui MxClips: Add, Button, x35 y110 w70 h20 gMxClipsSave, OK
Gui MxClips: Add, Button, x163 y110 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
Max_Index:=ClipBoardHistory.MaxIndex()
  If (MaxClipsS<Max_Index)
     {   
     TempNumberClip:= Max_Index-MaxClipsS
     Loop, %TempNumberClip%
     {     
     ClipBoardHistory.removeAt(1)
     Description.removeAt(1)
     CRC32.removeAt(1)
     If OneByOne=1
      {
      Gosub, RewriteClip
      }
     }
   IniWrite, %MaxClipsS%, Config.ini, Setting_Clipboard, MaxClips   
   }

IniWrite, %ShowClipsS%, Config.ini, Setting_Clipboard, ShowClip
Gosub, RelocateClips
ShowClipsS:=""
MaxClipsS:=""
TempNumberClip:=""
Gui, MxClips: Destroy
Gosub, Style
Return

RewriteClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
Return

RelocateClips:
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
If (ShowClip>MaxClips)
  {  
  ShowClip:=MaxClips
  IniWrite, %ShowClip%, Config.ini, Setting_Clipboard, ShowClip
  }
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

BackupOneByOne:
Menu, BasicClipID, ToggleCheck, Backup One by One
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If OneByOne=1
  {
  OneByOne:=0
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Disabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=1
  }
else
  {
  OneByOne:=1
  IniWrite, 1, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Enabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=0
  Gosub, RewriteClip
  }
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, 30, Config.ini, Setting_Clipboard, MaxClips
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
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 Double Menu
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 and OneByOne=1)
	  {	  
	  ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	  FileAppend, %Clip%, %ClipTemp%
	  }
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	If OneByOne=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)
  If OneByOne=1
   {
   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
Reissued, day 15-11. I dreamed (dreaming about programming is something close to nightmares) that there was still something wrong with the option to lower the number of clipboards. And so it was, it was comparing it with the variable "MaxClips", when it had to be with respect to the maximum number of current clipboards in the array. As it was, it worked if the total number of arrays was the maximum, but it worked badly if the array was not full. Corrected.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

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

15 Nov 2021, 10:45

Angel to Mary and Joseph!!! ("Ángel a María y José", Spanish expression when someone is surprised in a negative way).

At first I created this utility for my own use, but as I have expanded and improved it, I thought it could be shared. I work with a 4K monitor and therefore have modified the DPI scale. I ran the utility on a "normal" DPi computer. and a lot of things don't work as they should.

I searched the help for "control". all these errors and the question is to disable the DPI of the gui's Gui -DPIScale, but in doing so you have to adapt all the graphics (displacements, positionings, how the tips emerge...) and icons to the new format. Too much work!!!, being so advanced in its usefulness. I am abandoning this project for the time being, until one day I find the will and the energy to change so many things at the same time.

So, as it is, it works fine on 4K monitors and the DPI scale at 150%. If you want to use it without these requirements, you have to adapt the whole utility to 96 DPI.
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

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

22 Jun 2022, 16:36

Hello!!! ;)

I'm back to the clipboard project. I chose to work with two different scripts. One for 96 DPI (up to 1080 monitors) and one for 150 DPI (2k or 4K monitors).

I've fixed quite a few things that didn't work right or did things I didn't expect.

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
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

OnExit, SaveOnClip ;, Menu

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, 30, Config.ini, Setting_Clipboard, MaxClips
  IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
  IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  }
Gosub, RelocateClips

Name := "Clipboard Utility - "
Version := "4.5b"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
previousClip:=clipboard
DirectoryCount := 0
Iniciate := 1
PDFCount := 0
WordCount := 0
URLCount := 0
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite, OneByOne
DisableWrite:=0
CLipM:= obj.id()

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

IniRead, OneByOne, Config.ini, Setting_Clipboard, OneByOne
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, ClipBoardEnabled, Config.ini, Setting_Clipboard, ClipBoardEnabled
If ClipBoardEnabled=1
  {
  ChangeClipEnable=1
  }

if FileExist("TempClip\Clip1.clip")
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index

If (NumberClip0>MaxClips)
{
LastFiles:= (NumberClip0-MaxClips)
Loop, %LastFiles%
  {
  LastFiles++
  ReadClip:= "TempClip\Clip" LastFiles ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip  
  }
}
Else
If NumberClip0<=MaxClips
{
 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  
  }
}

If OneByOne=1
  {
  DisableWrite:=0
  }
 Else
  {
  FileDelete, TempClip\Clip*.clip
  }
Gosub, EmptyClean

;**************************************************************************************
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\1569.ico
Menu, BasicClipID, Add, Maximum Number of Clipboards: %MaxClips%, MaxClipsGui
Menu, BasicClipID, Icon, Maximum Number of Clipboards: %MaxClips%, Resources\2084.ico
Menu, BasicClipID, Add, Backup One by One, BackupOneByOne
Menu, BasicClipID, Icon, Backup One by One, Resources\2196.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 Double Menu, SwitchStyle
Menu, BasicClipID, Icon, Switch to Double Menu, Resources\1005.ico
Menu, BasicClipID, Add, Edit Favorites Text File, EditFavotites
Menu, BasicClipID, Icon, Edit Favorites Text File, Resources\Notepad.png
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, OneByOne, Config.ini, Setting_Clipboard, OneByOne
  If OneByOne=1
  {
  Menu, BasicClipID, ToggleCheck, Backup One by One
  }
IniRead, Style, Config.ini, Setting_Clipboard, Style
  If Style=0
  {
  Menu, BasicClipID, ToggleCheck, Switch to Double Menu
  }
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

NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
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
;************************************************************************
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)
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, 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: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, "s64")

;**************************************** H O M E ***********************************
GoSub, Toggle_Switch
CorpusCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
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
}
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
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 , 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" : 16          ;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" : 16          ;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)>600)
	{
	StringMid, CutTooTip, Tooltip, 1, 600        
	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::
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
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}) ;0xF2F1C5
menu.Add()

ShowClipTemp:=ShowClip
If (ShowClipTemp>Max_Index) 
{
ShowClipTemp:=Max_Index
}
Loop, %ShowClipTemp%
{
	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:= % Floor(Max_Index/2)
Half_Index1:= % Floor(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 and Min_Index>9)
;If Min_Index>=%Half_Index%
   {
   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
}
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
}
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

SaveOnClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

for index, value in ClipBoardHistory
  if (value="")
  {
  ClipBoardHistory.removeAt(index)
  }

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
ExitApp
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

EmptyClean:
Max_Index:=ClipBoardHistory.maxIndex()
Loop, 6 ;%Max_Index% ;This loop is theoretically wrong, because the next one (for index, value) is already in a loop, but the second one doesn't delete all empty arrays at once if there are many of them. It is only solved by adding this loop
  {
  for index, value in ClipBoardHistory
    if (value="")
     {
     ClipBoardHistory.removeAt(index)
     Description.removeAt(index)
     CRC32.removeAt(index)
     }
  }
Return

GuiUtily_Close:
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
UtilButton=1
Gosub, GuiUtily
UtilButton=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, Utily: -Caption HwndHwnd +Owner
Gui1.Hwnd := hwnd
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
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, 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
}

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
If !2Data
   {
   MsgBox, 0x1024,, URL could not be retrieved `nContinue in every way?	
   IfMsgBox No
     {
     MsgBox, 0x30,, Operation Cancelled
     Goto, ReloadMenu
     }
   }
LenText := StrLen(2Data)
StringGetPos, pos, 2Data, /, l2
length := pos+1
StringTrimLeft, OutText2, 2Data, %length%
2Data := OutText2
StringRight, InPDF, 2Data, 3

;MsgBox, %OutText2% — %InPDF%
If InPDF=pdf
  {
  2Data := uriDecode(2Data)
  ;Gosub, ClearName
  ;2Data:=FixStringPDF
  }
If 2Data=Buscar en documento
   {
   2Data:= (ComObjActive("Word.Application").ActiveDocument.FullName)
   }
   else if InPDF = !pdf
   {
   2Data =https://%2Data%
   }
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=" 2Data ">" 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
}
;******************************************************************************************************************
DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
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
}
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_1.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
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, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	Return
	
ResizeH:
vFactorW := 2
vFactorH := 2

pToken := Gdip_Startup()
pBitmap1 := Gdip_CreateBitmapFromFile("Image_Temp.jpg")
Gdip_GetDimensions(pBitmap1, vImgW1, vImgH1)
vImgW2 := Round(vImgW1 / vFactorW)
vImgH2 := Round(vImgH1 / vFactorH)
pBitmap2 := Gdip_CreateBitmap(vImgW2, vImgH2)
pGraphics2 := Gdip_GraphicsFromImage(pBitmap2)

Gdip_DrawImage(pGraphics2, pBitmap1, 0, 0, vImgW2, vImgH2, 0, 0, vImgW1, vImgH1)
Gdip_SaveBitmapToFile(pBitmap2, "Image_Temp_1.jpg")
Gdip_DeleteGraphics(pGraphics2)
Gdip_DisposeImage(pBitmap1)
Gdip_DisposeImage(pBitmap2)
Gdip_Shutdown(pToken)

filePath := "Image_Temp_1.jpg"
size := GetImageSize(filePath)

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

CopyGui:
CopyButton:=1
Gosub, Menu2
Return

ClipDelete:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
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%
	   }
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	ControlThree=1
	Gosub, ReloadMenu
	}
ControlThree=1
Return

^F8::
Menu2:
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 := {}
Gui1.Handles := []
Gui1.Pressed := ""
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, "s16")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s16")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s16")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s16")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s16")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
posyExitSess := posyExit+20
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\Reducedcap.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
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, x427 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui1.Button9 := {} ;Button 9 
Gui1.Button9.DefaultImage := "Resources\Cabinet_2.png"
Gui1.Button9.HoverImage := "Resources\Cabinet_2.png"
Gui1.Button9.PressedImage := "Resources\Cabinet_3.png"
Gui1.Button9.Label := "GuiUtily_Close" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W31 h32 hwndhwnd, % Gui1.Button9.DefaultImage
Gui1.Handles[ hwnd ] := "Button9" ;The name of the control to point at.
Gui1.Button9.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
}
If ControlThree=1
{
xpos1 := xLabel
ypos1 := yLabel
ControlThree:=0
}

If xpos1=0
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}

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
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +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, 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-566
EdYm := pYm-99
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit
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 :=""
Gui, Edit: Destroy
ControlThree=1
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
ControlThree=1
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: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
Gui, ContextClip1: Add, Button, x20 y%posyExit% w420 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x440 y%posyExit% w20 h20 hwndIcon20 gExtendedM
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*25.4)
XPos:= A_ScreenWidth-(460)
YPos:= A_ScreenHeight-AltoT
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, "s20")
GuiButtonIcon(Icon20, "Resources\ArrowArr.png", 1, "s24")
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
GoSub, Toggle_Switch
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
GoSub, Toggle_Switch
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:
GetKeyState, state, Control
if (state = "D")
 {
 StringTrimLeft, GoURL, a_guicontrol, 4
 gURL := "HTMLTemp\Text" GoURL ".html"
 NewURL:="HTMLTemp\URL" GoURL ".txt"
 FileDelete, %NewURL%
 FileRead, ExtracURL, %gURL%
 StringTrimLeft, item, ExtracURL, 154 
 StringTrimRight, item2, item, 32 
 LenText := StrLen(item2)
 StringGetPos, pos, item2, >, r1
 Resta:= LenText-pos
 StringTrimRight, item3, item2, %Resta%
 FileAppend, %item3%, %NewURL%
 If !NewURL or SizeFile=0
   {
   MsgBox, URL could not be retrieved
   }
 Gui, ContextClip: Destroy
 Gosub, RButton
 Return
 }
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
StringRight, OutPDF, WebURL, 3
;MsgBox, %WebURL%
If OutPDF=pdf
  {
  Run, %WebURL%
  }
Else
 {
 Run, %WebURL%, , Max UseErrorLevel
 if (ErrorLevel = "ERROR")
  {
  WebURL:= "https://" WebURL
  Run, %WebURL%
  }
}
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w800 h400, Resources\Help.jpg
Gui, Help: Add, Button, x650 y374 w80 h20 gNextButton, More...
Gui, Help: Show, w800 h400
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h400, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x30 y375 w80 h20 gExitButton, Exit
Gui, Help2: Show, w800 h400
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
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-630
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 h74, 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 h74
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

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-566
DelYm := pYm-32
Gui, 5: Show, x%DelXm% y%DelYm% w563 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
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F5::
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
MouseGetPos,,, WinUMID
WinActivate, ahk_id %WinUMID%
WinClip.Clear()

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>———————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;'font-size:24.0pt;color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%, SessionWord.html
html := FileOpen("SessionWord.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()

WinClip.Clear()
html := FileOpen("Resources\WordLine2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
Send, `n
Loop, %CorpusCount% ;Loop, %Number% ;so many loops are given as clipboard exist
{
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 600
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".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
}
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
}
FileDelete, SessionWord.html
WinClip.Clear()
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F6::
SavePDF:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>————————————————————————————————————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman; color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%<br/>, ToPDF.html

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\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%
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

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>———————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman; color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%<br/>, ToWord.html, CP65001
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
	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::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
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
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, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
Gosub, ButtonLabel
Return

LabelSession:
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return

FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4

   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
   FileMoveDir %DirectorySess%, %DirectorySess00%, R

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

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  
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:
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,2: Destroy
Gui, Gui1: 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

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
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
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
URLCount ++
FileURL := "Documents\Extracted_Links_" CurrentDate "-" URLCount ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate "-" URLCount ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Sleep, 800
Run, %FileURLImg%
ClipBoardEnabled=1
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

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

^F2::
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
GetText(Txt)
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", "él", "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", "tras"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
PutText(Txt)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
Return

^F1::
CaseMays:
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
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
Menu Mays, Add, &Invert Text, 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", "él", "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", "tras"]
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 
  }
}
Else If (p=8)
{
GetText(Txt)
Flip =
Loop, Parse, Txt
	Flip := A_LoopField Flip
Txt = % Flip
}
PutText(Txt)
If ChangeClipEnable=1
 {
 WinClip.Clear()
 ClipBoardEnabled=1
 ChangeClipEnable=0
 }
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:
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
Gui, MxClips: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, MxClips: Font, S10 Bold, Verdana
Gui, MxClips: Add, Picture, x0 y0 h20 w290 h32, Resources\Fondo_Limp_S.png
Gui, MxClips: Add, Text, cYellow BackgroundTrans x35 y6 W290 h32 GuiMove, Maximum Number of Clipboards
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y43 h28 w200, Maximum Number of Clipboards:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y41 h20 w40 vMaxClipsS, %MaxClips%
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y74 h28 w200, Number of Clipboard to Show:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y73 h20 w40 vShowClipsS, %ShowClip%
Gui, MxClips: Font, S8 Bold, Verdana
Gui MxClips: Add, Button, x35 y110 w70 h20 gMxClipsSave, OK
Gui MxClips: Add, Button, x163 y110 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:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +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, 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
Gui Session:Add, CheckBox, x220 y70 w280 h20 Checked1 vVeryfySession, Activate the New Session when Creating
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
If PosSession=1
{
xSess := pXm-566
ySess := pYm-99
}
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
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%

If VeryfySession=1
{
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1

   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
   FileMoveDir %DirectorySess%, %DirectorySess00%, R

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

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  
FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Gui, ContextClip: Destroy
}

Menu, SessionID, DeleteAll
PosSession:=0
Iniciate:=0
SessEdit :=""
VeryfySession :=""
ControlThree=1
Gosub, ReloadSession
Return

MxClipsSave:
Gui, MxClips: Submit
Max_Index:=ClipBoardHistory.MaxIndex()
If (MaxClipsS<Max_Index)
   {   
   TempNumberClip:= Max_Index-MaxClipsS
   Loop, %TempNumberClip%
     {     
     ClipBoardHistory.removeAt(1)
     Description.removeAt(1)
     CRC32.removeAt(1)
     If OneByOne=1      
      {
      Gosub, RewriteClip
      }
     }
   ;IniWrite, %MaxClipsS%, Config.ini, Setting_Clipboard, MaxClips   
   }

IniWrite, %ShowClipsS%, Config.ini, Setting_Clipboard, ShowClip
Gosub, RelocateClips
ShowClipsS:=""
MaxClipsS:=""
TempNumberClip:=""
Gui, MxClips: Destroy
;Gosub, Style
Gosub, Reloaded
Return

RewriteClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
Return

RelocateClips:
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
If (ShowClip>MaxClips)
  {  
  ShowClip:=MaxClips
  IniWrite, %ShowClip%, Config.ini, Setting_Clipboard, ShowClip
  }
Return

ClipCancel:
Gui, Session: Submit
Gui, MxClips:Destroy
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
PosSession:=0
ControlThree=1
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
GetKeyState, state, Control
if (state = "D")
 {
PosSession:=1
Gosub, NewSession
Return
}

Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
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, 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-566
ySess := pYm-99
}
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 :=""
ControlThree=1
Gosub, RButton
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)
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:
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
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
if A_IsSuspended=0
  {
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, The Application has Been Activated
  xSplash1 := A_ScreenWidth-506
  ySplash1 := A_ScreenHeight-180
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
    ;If ChangeClipEnable=0 ;SuspendHotkeys=1
    ;{
    ;Gosub, SuspendBasicClip
  If (ClipBoardEnabled=0 and ChangeClipEnable=1)
    {
    ;Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
    xSplash1 := A_ScreenWidth-506
    ySplash1 := A_ScreenHeight-180
    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
    ;ChangeClipEnable=1
    }
  }
 if A_IsSuspended=1
  {
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, The Application has Been Deactivated
  xSplash1 := A_ScreenWidth-506
  ySplash1 := A_ScreenHeight-180
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  ;If ChangeClipEnable=1
  ;  {
  ;  Gosub, SuspendBasicClip
  If (ClipBoardEnabled=1 and ChangeClipEnable=1)
   {
   ;Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
   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
   ;ChangeClipEnable=0
   }
  }
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, ^!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, ^!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

BackupOneByOne:
Menu, BasicClipID, ToggleCheck, Backup One by One
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If OneByOne=1
  {
  OneByOne:=0
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Disabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=1
  }
else
  {
  OneByOne:=1
  IniWrite, 1, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Enabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=0
  Gosub, RewriteClip
  }
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
ChangeClipEnable=1
}
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
ChangeClipEnable=0
}
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, 30, Config.ini, Setting_Clipboard, MaxClips
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
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 Double Menu
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

EditFavotites:
Run Notepad.exe TempClip\Favorites.fav
Return
CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
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_1.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

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

;---------------------------------------------------------------
;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 and OneByOne=1)
	  {	  
	  ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	  FileAppend, %Clip%, %ClipTemp%
	  }
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	If OneByOne=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)<60)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-15 
  StringMid, itemTemp1, Descrp, 1, 40
  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=60, 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:
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  If OneByOne=1
   {
   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

;---------------------------------------------------------------------
;by polyethene http://www.autohotkey.com/forum/post-119507.html
;modified by Ageless http://www.autohotkey.com/forum/post-128491.html
uriEncode(str) {
   f = %A_FormatInteger%
   SetFormat, Integer, Hex
   If RegExMatch(str, "^\w+:/{0,2}", pr)
      StringTrimLeft, str, str, StrLen(pr)
   StringReplace, str, str, `%, `%25, All
   Loop
      If RegExMatch(str, "i)[^\w\.~%/:]", char)
         StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All
      Else Break
   SetFormat, Integer, %f%
   Return, pr . str
}

uriDecode(str) {
   Loop
      If RegExMatch(str, "i)(?<=%)[\da-f]{1,2}", hex)
         StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
      Else Break
   Return, str
}
The two versions and other necessary components, can be downloaded from here https://mega.nz/file/IYpECBIQ#eGbVZHzHCZE2XVqWifcwF4uMacu6cmThCsKi-D-XmtA. I made this video tutorial:


:wave:
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

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

18 Jul 2022, 16:43

Hello!!

A small addition to the program. When all clipboards are pasted with Ctrl-F5, a progress bar and total number of clipboards to paste will be displayed. The process can be interrupted with the Shift+Esc key (when you have just pasted the current clipboard).

Image

Known issue notes. I have tried by various means to make the cursor hide and freeze. On lines 1712-13, I call a function (it's at the end of the code) and use the nomousy.exe utility to freeze it, but the cursor intermittently appears and may move. At line 1744, inside the loop, I try to return the cursor to a preset place to avoid problems.

Can anyone tell me an effective method to hide and freeze the mouse? I have searched and have not found any effective ideas.

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
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

OnExit, SaveOnClip ;, Menu

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, 30, Config.ini, Setting_Clipboard, MaxClips
  IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
  IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  }
Gosub, RelocateClips

Name := "Clipboard Utility - "
Version := "4.6b"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
previousClip:=clipboard
DirectoryCount := 0
Iniciate := 1
PDFCount := 0
WordCount := 0
URLCount := 0
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite, OneByOne
DisableWrite:=0
CLipM:= obj.id()

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

IniRead, OneByOne, Config.ini, Setting_Clipboard, OneByOne
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, ClipBoardEnabled, Config.ini, Setting_Clipboard, ClipBoardEnabled
If ClipBoardEnabled=1
  {
  ChangeClipEnable=1
  }

if FileExist("TempClip\Clip1.clip")
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index

If (NumberClip0>MaxClips)
{
LastFiles:= (NumberClip0-MaxClips)
Loop, %LastFiles%
  {
  LastFiles++
  ReadClip:= "TempClip\Clip" LastFiles ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip  
  }
}
Else
If NumberClip0<=MaxClips
{
 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  
  }
}

If OneByOne=1
  {
  DisableWrite:=0
  }
 Else
  {
  FileDelete, TempClip\Clip*.clip
  }
Gosub, EmptyClean

;**************************************************************************************
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\1569.ico
Menu, BasicClipID, Add, Maximum Number of Clipboards: %MaxClips%, MaxClipsGui
Menu, BasicClipID, Icon, Maximum Number of Clipboards: %MaxClips%, Resources\2084.ico
Menu, BasicClipID, Add, Backup One by One, BackupOneByOne
Menu, BasicClipID, Icon, Backup One by One, Resources\2196.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 Double Menu, SwitchStyle
Menu, BasicClipID, Icon, Switch to Double Menu, Resources\1005.ico
Menu, BasicClipID, Add, Edit Favorites Text File, EditFavotites
Menu, BasicClipID, Icon, Edit Favorites Text File, Resources\Notepad.png
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, OneByOne, Config.ini, Setting_Clipboard, OneByOne
  If OneByOne=1
  {
  Menu, BasicClipID, ToggleCheck, Backup One by One
  }
IniRead, Style, Config.ini, Setting_Clipboard, Style
  If Style=0
  {
  Menu, BasicClipID, ToggleCheck, Switch to Double Menu
  }
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

NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
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
;************************************************************************
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)
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, 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: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, "s64")

;**************************************** H O M E ***********************************
GoSub, Toggle_Switch
CorpusCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1
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
}
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
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 , 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" : 16          ;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" : 16          ;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)>600)
	{
	StringMid, CutTooTip, Tooltip, 1, 600        
	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::
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
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}) ;0xF2F1C5
menu.Add()

ShowClipTemp:=ShowClip
If (ShowClipTemp>Max_Index) 
{
ShowClipTemp:=Max_Index
}
Loop, %ShowClipTemp%
{
	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:= % Floor(Max_Index/2)
Half_Index1:= % Floor(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 and Min_Index>9)
;If Min_Index>=%Half_Index%
   {
   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
}
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
}
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

SaveOnClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

for index, value in ClipBoardHistory
  if (value="")
  {
  ClipBoardHistory.removeAt(index)
  }

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
ExitApp
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

EmptyClean:
Max_Index:=ClipBoardHistory.maxIndex()
Loop, 6 ;%Max_Index% ;This loop is theoretically wrong, because the next one (for index, value) is already in a loop, but the second one doesn't delete all empty arrays at once if there are many of them. It is only solved by adding this loop
  {
  for index, value in ClipBoardHistory
    if (value="")
     {
     ClipBoardHistory.removeAt(index)
     Description.removeAt(index)
     CRC32.removeAt(index)
     }
  }
Return

GuiUtily_Close:
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
UtilButton=1
Gosub, GuiUtily
UtilButton=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, Utily: -Caption HwndHwnd +Owner
Gui1.Hwnd := hwnd
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
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, 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
}

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
If !2Data
   {
   MsgBox, 0x1024,, URL could not be retrieved `nContinue in every way?	
   IfMsgBox No
     {
     MsgBox, 0x30,, Operation Cancelled
     Goto, ReloadMenu
     }
   }
LenText := StrLen(2Data)
StringGetPos, pos, 2Data, /, l2
length := pos+1
StringTrimLeft, OutText2, 2Data, %length%
2Data := OutText2
StringRight, InPDF, 2Data, 3

;MsgBox, %OutText2% — %InPDF%
If InPDF=pdf
  {
  2Data := uriDecode(2Data)
  ;Gosub, ClearName
  ;2Data:=FixStringPDF
  }
If 2Data=Buscar en documento
   {
   2Data:= (ComObjActive("Word.Application").ActiveDocument.FullName)
   }
   else if InPDF = !pdf
   {
   2Data =https://%2Data%
   }
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=" 2Data ">" 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
}
;******************************************************************************************************************
DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
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
}
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_1.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
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, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	Return
	
ResizeH:
vFactorW := 2
vFactorH := 2

pToken := Gdip_Startup()
pBitmap1 := Gdip_CreateBitmapFromFile("Image_Temp.jpg")
Gdip_GetDimensions(pBitmap1, vImgW1, vImgH1)
vImgW2 := Round(vImgW1 / vFactorW)
vImgH2 := Round(vImgH1 / vFactorH)
pBitmap2 := Gdip_CreateBitmap(vImgW2, vImgH2)
pGraphics2 := Gdip_GraphicsFromImage(pBitmap2)

Gdip_DrawImage(pGraphics2, pBitmap1, 0, 0, vImgW2, vImgH2, 0, 0, vImgW1, vImgH1)
Gdip_SaveBitmapToFile(pBitmap2, "Image_Temp_1.jpg")
Gdip_DeleteGraphics(pGraphics2)
Gdip_DisposeImage(pBitmap1)
Gdip_DisposeImage(pBitmap2)
Gdip_Shutdown(pToken)

filePath := "Image_Temp_1.jpg"
size := GetImageSize(filePath)

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

CopyGui:
CopyButton:=1
Gosub, Menu2
Return

ClipDelete:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
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%
	   }
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	ControlThree=1
	Gosub, ReloadMenu
	}
ControlThree=1
Return

^F8::
Menu2:
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 := {}
Gui1.Handles := []
Gui1.Pressed := ""
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, "s16")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s16")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s16")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s16")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s16")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
posyExitSess := posyExit+20
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\Reducedcap.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
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, x427 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui1.Button9 := {} ;Button 9 
Gui1.Button9.DefaultImage := "Resources\Cabinet_2.png"
Gui1.Button9.HoverImage := "Resources\Cabinet_2.png"
Gui1.Button9.PressedImage := "Resources\Cabinet_3.png"
Gui1.Button9.Label := "GuiUtily_Close" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W31 h32 hwndhwnd, % Gui1.Button9.DefaultImage
Gui1.Handles[ hwnd ] := "Button9" ;The name of the control to point at.
Gui1.Button9.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
}
If ControlThree=1
{
xpos1 := xLabel
ypos1 := yLabel
ControlThree:=0
}

If xpos1=0
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}

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
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +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, 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-566
EdYm := pYm-99
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit
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 :=""
Gui, Edit: Destroy
ControlThree=1
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
ControlThree=1
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: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
Gui, ContextClip1: Add, Button, x20 y%posyExit% w420 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x440 y%posyExit% w20 h20 hwndIcon20 gExtendedM
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*25.4)
XPos:= A_ScreenWidth-(460)
YPos:= A_ScreenHeight-AltoT
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, "s20")
GuiButtonIcon(Icon20, "Resources\ArrowArr.png", 1, "s24")
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
GoSub, Toggle_Switch
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
GoSub, Toggle_Switch
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:
GetKeyState, state, Control
if (state = "D")
 {
 StringTrimLeft, GoURL, a_guicontrol, 4
 gURL := "HTMLTemp\Text" GoURL ".html"
 NewURL:="HTMLTemp\URL" GoURL ".txt"
 FileDelete, %NewURL%
 FileRead, ExtracURL, %gURL%
 StringTrimLeft, item, ExtracURL, 154 
 StringTrimRight, item2, item, 32 
 LenText := StrLen(item2)
 StringGetPos, pos, item2, >, r1
 Resta:= LenText-pos
 StringTrimRight, item3, item2, %Resta%
 FileAppend, %item3%, %NewURL%
 If !NewURL or SizeFile=0
   {
   MsgBox, URL could not be retrieved
   }
 Gui, ContextClip: Destroy
 Gosub, RButton
 Return
 }
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
StringRight, OutPDF, WebURL, 3
;MsgBox, %WebURL%
If OutPDF=pdf
  {
  Run, %WebURL%
  }
Else
 {
 Run, %WebURL%, , Max UseErrorLevel
 if (ErrorLevel = "ERROR")
  {
  WebURL:= "https://" WebURL
  Run, %WebURL%
  }
}
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w800 h400, Resources\Help.jpg
Gui, Help: Add, Button, x650 y374 w80 h20 gNextButton, More...
Gui, Help: Show, w800 h400
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h400, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x30 y375 w80 h20 gExitButton, Exit
Gui, Help2: Show, w800 h400
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
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-630
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 h74, 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 h74
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

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-566
DelYm := pYm-32
Gui, 5: Show, x%DelXm% y%DelYm% w563 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
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F5::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nThe mouse cursor will stop working and freeze, due to the need for the operation.`n`n (Press the 'Mays+ESC' key to interrupt the process)
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
MouseGetPos,PosX,PosY, WinUMID
;WinActivate, ahk_id %WinUMID%
run %A_WorkingDir%\Addons\nomousy.exe -freeze ; This program freezes the mouse position, but it doesn't seem to work well with the command "WinActivate"
SystemCursor(0)
WinClip.Clear()

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>———————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;'font-size:24.0pt;color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%, SessionWord.html
html := FileOpen("SessionWord.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()

WinClip.Clear()
html := FileOpen("Resources\WordLine2.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
WinClip.Clear()	
Send, `n

ProgressNum:=100//CorpusCount ;Sets the number of times the progress bar will be updated
KillerLoop:=0

Gui, Barr: -Caption +AlwaysOnTop +Owner
Gui, Barr: Margin, 8, 8
Gui, Barr: Add, Progress, vProgress1 -Smooth w350 h28 Disabled
Gui, Barr: Font, S10 Bold, Verdana
Gui, Barr: Add, Text,, Pasting Clipboards in Process...
Gui Barr: Add, Text, xp+170 yp h20 w180 +center +BackgroundTrans vProgTxt
Gui, Barr: Show

Loop, %CorpusCount% ;Loop Number ;so many loops are given as clipboard exist
   {
     if KillerLoop=1
	  {
	  Break
	  }
	GuiControl, Barr: , Progress1, +%ProgressNum% ; Problem: When updating the progress bar, the focus of the background application is lost.
	GuiControl Barr:, ProgTxt, % "(" A_Index "/" CorpusCount ")"
	WinActivate, ahk_id %WinUMID% ;It is necessary to activate the background window
	Mousemove, PosX, PosY ;Try that the mouse is always in the same position
	run %A_WorkingDir%\Addons\nomousy.exe -freeze ; This program freezes the mouse position, but it doesn't seem to work well with the command "WinActivate"?
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 600
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".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
   }
Gui, Barr: destroy
SystemCursor(1) ; Disable mouse hide
run %A_WorkingDir%\Addons\nomousy.exe ; Disable mouse freeze
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
}
FileDelete, SessionWord.html
WinClip.Clear()
Return

+Esc::
KillerLoop:=1
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F6::
SavePDF:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>————————————————————————————————————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman; color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%<br/>, ToPDF.html

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\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%
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

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>———————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman; color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%<br/>, ToWord.html, CP65001
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
	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::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
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
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, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
Gosub, ButtonLabel
Return

LabelSession:
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return

FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-4

   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
   FileMoveDir %DirectorySess%, %DirectorySess00%, R

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

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  
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:
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,2: Destroy
Gui, Gui1: 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

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
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
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
URLCount ++
FileURL := "Documents\Extracted_Links_" CurrentDate "-" URLCount ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate "-" URLCount ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Sleep, 800
Run, %FileURLImg%
ClipBoardEnabled=1
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

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

^F2::
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
GetText(Txt)
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", "él", "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", "tras"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
PutText(Txt)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
Return

^F1::
CaseMays:
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
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
Menu Mays, Add, &Invert Text, 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", "él", "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", "tras"]
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 
  }
}
Else If (p=8)
{
GetText(Txt)
Flip =
Loop, Parse, Txt
	Flip := A_LoopField Flip
Txt = % Flip
}
PutText(Txt)
If ChangeClipEnable=1
 {
 WinClip.Clear()
 ClipBoardEnabled=1
 ChangeClipEnable=0
 }
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:
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
Gui, MxClips: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, MxClips: Font, S10 Bold, Verdana
Gui, MxClips: Add, Picture, x0 y0 h20 w290 h32, Resources\Fondo_Limp_S.png
Gui, MxClips: Add, Text, cYellow BackgroundTrans x35 y6 W290 h32 GuiMove, Maximum Number of Clipboards
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y43 h28 w200, Maximum Number of Clipboards:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y41 h20 w40 vMaxClipsS, %MaxClips%
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y74 h28 w200, Number of Clipboard to Show:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y73 h20 w40 vShowClipsS, %ShowClip%
Gui, MxClips: Font, S8 Bold, Verdana
Gui MxClips: Add, Button, x35 y110 w70 h20 gMxClipsSave, OK
Gui MxClips: Add, Button, x163 y110 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:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +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, 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
Gui Session:Add, CheckBox, x220 y70 w280 h20 Checked1 vVeryfySession, Activate the New Session when Creating
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
If PosSession=1
{
xSess := pXm-566
ySess := pYm-99
}
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
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%

If VeryfySession=1
{
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1

   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
   FileMoveDir %DirectorySess%, %DirectorySess00%, R

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

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  
FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Gui, ContextClip: Destroy
}

Menu, SessionID, DeleteAll
PosSession:=0
Iniciate:=0
SessEdit :=""
VeryfySession :=""
ControlThree=1
Gosub, ReloadSession
Return

MxClipsSave:
Gui, MxClips: Submit
Max_Index:=ClipBoardHistory.MaxIndex()
If (MaxClipsS<Max_Index)
   {   
   TempNumberClip:= Max_Index-MaxClipsS
   Loop, %TempNumberClip%
     {     
     ClipBoardHistory.removeAt(1)
     Description.removeAt(1)
     CRC32.removeAt(1)
     If OneByOne=1      
      {
      Gosub, RewriteClip
      }
     }
   ;IniWrite, %MaxClipsS%, Config.ini, Setting_Clipboard, MaxClips   
   }

IniWrite, %ShowClipsS%, Config.ini, Setting_Clipboard, ShowClip
Gosub, RelocateClips
ShowClipsS:=""
MaxClipsS:=""
TempNumberClip:=""
Gui, MxClips: Destroy
;Gosub, Style
Gosub, Reloaded
Return

RewriteClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
Return

RelocateClips:
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
If (ShowClip>MaxClips)
  {  
  ShowClip:=MaxClips
  IniWrite, %ShowClip%, Config.ini, Setting_Clipboard, ShowClip
  }
Return

ClipCancel:
Gui, Session: Submit
Gui, MxClips:Destroy
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
PosSession:=0
ControlThree=1
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
GetKeyState, state, Control
if (state = "D")
 {
PosSession:=1
Gosub, NewSession
Return
}

Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
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, 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-566
ySess := pYm-99
}
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 :=""
ControlThree=1
Gosub, RButton
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)
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:
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
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
if A_IsSuspended=0
  {
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, The Application has Been Activated
  xSplash1 := A_ScreenWidth-506
  ySplash1 := A_ScreenHeight-180
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
    ;If ChangeClipEnable=0 ;SuspendHotkeys=1
    ;{
    ;Gosub, SuspendBasicClip
  If (ClipBoardEnabled=0 and ChangeClipEnable=1)
    {
    ;Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
    xSplash1 := A_ScreenWidth-506
    ySplash1 := A_ScreenHeight-180
    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
    ;ChangeClipEnable=1
    }
  }
 if A_IsSuspended=1
  {
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, The Application has Been Deactivated
  xSplash1 := A_ScreenWidth-506
  ySplash1 := A_ScreenHeight-180
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  ;If ChangeClipEnable=1
  ;  {
  ;  Gosub, SuspendBasicClip
  If (ClipBoardEnabled=1 and ChangeClipEnable=1)
   {
   ;Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
   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
   ;ChangeClipEnable=0
   }
  }
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, ^!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, ^!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

BackupOneByOne:
Menu, BasicClipID, ToggleCheck, Backup One by One
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If OneByOne=1
  {
  OneByOne:=0
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Disabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=1
  }
else
  {
  OneByOne:=1
  IniWrite, 1, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Enabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=0
  Gosub, RewriteClip
  }
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
ChangeClipEnable=1
}
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
ChangeClipEnable=0
}
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, 30, Config.ini, Setting_Clipboard, MaxClips
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
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 Double Menu
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

EditFavotites:
Run Notepad.exe TempClip\Favorites.fav
Return
CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
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_1.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

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

;---------------------------------------------------------------
;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 and OneByOne=1)
	  {	  
	  ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	  FileAppend, %Clip%, %ClipTemp%
	  }
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	If OneByOne=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)<60)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-15 
  StringMid, itemTemp1, Descrp, 1, 40
  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=60, 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:
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  If OneByOne=1
   {
   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

;---------------------------------------------------------------------
;by polyethene http://www.autohotkey.com/forum/post-119507.html
;modified by Ageless http://www.autohotkey.com/forum/post-128491.html
uriEncode(str) {
   f = %A_FormatInteger%
   SetFormat, Integer, Hex
   If RegExMatch(str, "^\w+:/{0,2}", pr)
      StringTrimLeft, str, str, StrLen(pr)
   StringReplace, str, str, `%, `%25, All
   Loop
      If RegExMatch(str, "i)[^\w\.~%/:]", char)
         StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All
      Else Break
   SetFormat, Integer, %f%
   Return, pr . str
}

uriDecode(str) {
   Loop
      If RegExMatch(str, "i)(?<=%)[\da-f]{1,2}", hex)
         StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
      Else Break
   Return, str
}

;------------------------------------------------------------------------------------------------
SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
    static AndMask, XorMask, $, h_cursor
        ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
        , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
        , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
    if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
    {
        $ := "h"                                       ; active default cursors
        VarSetCapacity( h_cursor,4444, 1 )
        VarSetCapacity( AndMask, 32*4, 0xFF )
        VarSetCapacity( XorMask, 32*4, 0 )
        system_cursors := "32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650"
        StringSplit c, system_cursors, `,
        Loop %c0%
        {
            h_cursor   := DllCall( "LoadCursor", "Ptr",0, "Ptr",c%A_Index% )
            h%A_Index% := DllCall( "CopyImage", "Ptr",h_cursor, "UInt",2, "Int",0, "Int",0, "UInt",0 )
            b%A_Index% := DllCall( "CreateCursor", "Ptr",0, "Int",0, "Int",0
                , "Int",32, "Int",32, "Ptr",&AndMask, "Ptr",&XorMask )
        }
    }
    if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
        $ := "b"  ; use blank cursors
    else
        $ := "h"  ; use the saved cursors

    Loop %c0%
    {
        h_cursor := DllCall( "CopyImage", "Ptr",%$%%A_Index%, "UInt",2, "Int",0, "Int",0, "UInt",0 )
        DllCall( "SetSystemCursor", "Ptr",h_cursor, "UInt",c%A_Index% )
    }
}
Download all the necessary components: https://mega.nz/file/JBZFWbzZ#4e4o66iKmILnJTSfQ1sfR7TbjSDQa93CP51AnfqHgRw
wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

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

21 Jul 2022, 06:07

Hi! :wave:

I had a pending subject: to delete the current session. It was complicated when I knew little about the program. This is what's new in this revision.

Image

At the same time I have corrected several bugs that became more present when I created this new option.

(For those using this utility, I recommend making backup copies of your current sessions before using this new option. Use the download version first to familiarize yourself with the new option. Sessions are saved in directories, HTMLTemp , HTMLTemp1, HTMLTemp2, ... I imagine whoever used it will have already figured it out.)

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
#SingleInstance, Force
#InstallMousehook
#Persistent
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1

OnExit, SaveOnClip ;, Menu

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, 30, Config.ini, Setting_Clipboard, MaxClips
  IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
  IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  }
Gosub, RelocateClips

Name := "Clipboard Utility - "
Version := "4.6c"
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
Description:=Object()
CRC32:=Object()
previousClip:=clipboard
DirectoryCount := 0
Iniciate := 1
PDFCount := 0
WordCount := 0
URLCount := 0
Global MaxClips, Style, CLipM, FirstTime, ShowTip, DisableWrite, OneByOne
DisableWrite:=0
CLipM:= obj.id()

Filedelete, WorkingDir.txt
FileAppend, %A_ScriptDir%\, WorkingDir.txt
FileRead, ScriptDir, Workingdir.txt

if !FileExist("HTMLTemp")
{
FileCreateDir, HTMLTemp
TextSess:="Empty Test Session"
FileAppend, %TextSess%, %ScriptDir%\HTMLTemp\Session.txt
}

if !FileExist(TempClip)
{
FileCreateDir, TempClip
}

IniRead, OneByOne, Config.ini, Setting_Clipboard, OneByOne
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, ClipBoardEnabled, Config.ini, Setting_Clipboard, ClipBoardEnabled
If ClipBoardEnabled=1
  {
  ChangeClipEnable=1
  }

if FileExist("TempClip\Clip1.clip")
DisableWrite:=1
Loop, TempClip\Clip*.clip
NumberClip0 := A_Index

If (NumberClip0>MaxClips)
{
LastFiles:= (NumberClip0-MaxClips)
Loop, %LastFiles%
  {
  LastFiles++
  ReadClip:= "TempClip\Clip" LastFiles ".clip"
  FileRead, ClipHsy, %ReadClip%
  ClipSave(ClipBoardHistory, ClipHsy, A_Index)
  CRCClip:=LC_CRC32(ClipHsy)
  CRC32.insert(Object())
  Max_CRC:=CRC32.MaxIndex()
  CRC32[Max_CRC]:=CRCClip  
  }
}
Else
If NumberClip0<=MaxClips
{
 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  
  }
}

If OneByOne=1
  {
  DisableWrite:=0
  }
 Else
  {
  FileDelete, TempClip\Clip*.clip
  }
Gosub, EmptyClean

;**************************************************************************************
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\1569.ico
Menu, BasicClipID, Add, Maximum Number of Clipboards: %MaxClips%, MaxClipsGui
Menu, BasicClipID, Icon, Maximum Number of Clipboards: %MaxClips%, Resources\2084.ico
Menu, BasicClipID, Add, Backup One by One, BackupOneByOne
Menu, BasicClipID, Icon, Backup One by One, Resources\2196.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 Double Menu, SwitchStyle
Menu, BasicClipID, Icon, Switch to Double Menu, Resources\1005.ico
Menu, BasicClipID, Add, Edit Favorites Text File, EditFavotites
Menu, BasicClipID, Icon, Edit Favorites Text File, Resources\Notepad.png
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, OneByOne, Config.ini, Setting_Clipboard, OneByOne
  If OneByOne=1
  {
  Menu, BasicClipID, ToggleCheck, Backup One by One
  }
IniRead, Style, Config.ini, Setting_Clipboard, Style
  If Style=0
  {
  Menu, BasicClipID, ToggleCheck, Switch to Double Menu
  }
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

NumberSessTemp := "HTMLTemp\Session.txt"
   FileRead, Session1, %NumberSessTemp%
Menu, SessionID, add, Create New Session, NewSession
Menu, SessionID, Icon, Create New Session, %A_ScriptDir%\Resources\178.ico
Menu, SessionID, add, Delete Actual Session, ActualDelSessions
Menu, SessionID, Icon, Delete Actual Session, %A_ScriptDir%\Resources\Bin-Red 3.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
;************************************************************************
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)
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:
CorpusCount=0
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
}

 IfNotExist, %A_WorkingDir%\SesionName.txt
 {
  FileCopy, %A_WorkingDir%\Resources\SesionName.txt, %A_WorkingDir%\SesionName.txt
  Menu, ClipboardID, add, Empty Clipboard, ButtonLabelTray
  Menu, Tray, add, Clipboard, :ClipboardID
  Menu, Tray, Icon, Clipboard, C:\Windows\system32\shell32.dll,261
 }
Menu, Tray, Default, Basic Clipboard 
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: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, "s64")

;**************************************** H O M E ***********************************
GoSub, Toggle_Switch
CorpusCount := 0
loop, HTMLTemp\Corpus*.html
CorpusCount := % Floor(A_Index)
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
DirectoryCount := A_Index-1

threeRButton=0 ; Previo 1
Max_Index:=ClipBoardHistory.maxIndex()
loop, Documents\*.pdf
PDFCount := A_Index
If PDFCount != 0 
{
PDFCount := PDFCount+1
}
loop, Documents\*.docx
WordCount := A_Index
If WordCount != 0 
{
WordCount := WordCount+1
}
If Iniciate=1
{
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 , 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" : 16          ;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" : 16          ;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)>600)
	{
	StringMid, CutTooTip, Tooltip, 1, 600        
	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::
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
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}) ;0xF2F1C5
menu.Add()

ShowClipTemp:=ShowClip
If (ShowClipTemp>Max_Index) 
{
ShowClipTemp:=Max_Index
}
Loop, %ShowClipTemp%
{
	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:= % Floor(Max_Index/2)
Half_Index1:= % Floor(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 and Min_Index>9)
;If Min_Index>=%Half_Index%
   {
   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
}
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
}
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

SaveOnClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

for index, value in ClipBoardHistory
  if (value="")
  {
  ClipBoardHistory.removeAt(index)
  }

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
ExitApp
Return

ChangeClipState:
If ChangeClipEnable=1
   {
   Clipboard:=""
   ClipBoardEnabled=1
   ChangeClipEnable=0
   }
Return

EmptyClean:
Max_Index:=ClipBoardHistory.maxIndex()
Loop, 6 ;%Max_Index% ;This loop is theoretically wrong, because the next one (for index, value) is already in a loop, but the second one doesn't delete all empty arrays at once if there are many of them. It is only solved by adding this loop
  {
  for index, value in ClipBoardHistory
    if (value="")
     {
     ClipBoardHistory.removeAt(index)
     Description.removeAt(index)
     CRC32.removeAt(index)
     }
  }
Return

GuiUtily_Close:
Gui, ContextClip: Destroy
SoundPlay, Resources\Close Window.mp3
UtilButton=1
Gosub, GuiUtily
UtilButton=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, Utily: -Caption HwndHwnd +Owner
Gui1.Hwnd := hwnd
Gui, Utily: Add, Picture, x0 y0 w739 h167, Resources\Clipboard Utility_p_2.png
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, 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
}

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
If !2Data
   {
   MsgBox, 0x1024,, URL could not be retrieved `nContinue in every way?	
   IfMsgBox No
     {
     MsgBox, 0x30,, Operation Cancelled
     Goto, ReloadMenu
     }
   }
LenText := StrLen(2Data)
StringGetPos, pos, 2Data, /, l2
length := pos+1
StringTrimLeft, OutText2, 2Data, %length%
2Data := OutText2
StringRight, InPDF, 2Data, 3

;MsgBox, %OutText2% — %InPDF%
If InPDF=pdf
  {
  2Data := uriDecode(2Data)
  ;Gosub, ClearName
  ;2Data:=FixStringPDF
  }
If 2Data=Buscar en documento
   {
   2Data:= (ComObjActive("Word.Application").ActiveDocument.FullName)
   }
   else if InPDF = !pdf
   {
   2Data =https://%2Data%
   }
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=" 2Data ">" 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
}
;******************************************************************************************************************
DataReplace := StrReplace(Data, "<h1", "<p")
DataReplace1 := StrReplace(DataReplace, "</h1", "</p")
FileAppend, %DataReplace1%, Temp.html ;, CP65001
;******************************************************************************************************************
FileGetSize, SizeFile2, Temp.html
FileHTML := "Temp.html"
If !FileHTML or SizeFile2=3
{
ErrorType :=1
Gosub, ControlError
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
}
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_1.jpg, %ImageCount%
   ;**********************
   If !ImageCount
     {
     ErrorType :=2
     Gosub, ControlError
     }
   ;**********************
   FileDelete, Image_Temp.jpg
   }
NameCount := "HTMLTemp\Corpus" CorpusCount ".html"
FileMove, Temp2.html, %NameCount%
FileDelete, Temp*.html
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, The clipboard image could not be saved. The clipboard exists, but it will not display an image.`n It can be created later.
	Return
	
ResizeH:
vFactorW := 2
vFactorH := 2

pToken := Gdip_Startup()
pBitmap1 := Gdip_CreateBitmapFromFile("Image_Temp.jpg")
Gdip_GetDimensions(pBitmap1, vImgW1, vImgH1)
vImgW2 := Round(vImgW1 / vFactorW)
vImgH2 := Round(vImgH1 / vFactorH)
pBitmap2 := Gdip_CreateBitmap(vImgW2, vImgH2)
pGraphics2 := Gdip_GraphicsFromImage(pBitmap2)

Gdip_DrawImage(pGraphics2, pBitmap1, 0, 0, vImgW2, vImgH2, 0, 0, vImgW1, vImgH1)
Gdip_SaveBitmapToFile(pBitmap2, "Image_Temp_1.jpg")
Gdip_DeleteGraphics(pGraphics2)
Gdip_DisposeImage(pBitmap1)
Gdip_DisposeImage(pBitmap2)
Gdip_Shutdown(pToken)

filePath := "Image_Temp_1.jpg"
size := GetImageSize(filePath)

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

CopyGui:
CopyButton:=1
Gosub, Menu2
Return

ClipDelete:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
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%
	   }
	Iniciate:=0
	Menu, ClipboardID, DeleteAll
	ControlThree=1
	Gosub, ReloadMenu
	}
ControlThree=1
Return

^F8::
Menu2:
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 := {}
Gui1.Handles := []
Gui1.Pressed := ""
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, "s16")
   GuiButtonIcon(Icon1, "Resources\128.ico", 1, "s16")
   GuiButtonIcon(Icon8, "Resources\ArrowSmall.ico", 1, "s16")
   GuiButtonIcon(Icon10, "Resources\recycle 2.ico", 1, "s16")
   GuiButtonIcon(Icon9, "Resources\pencil 1.ico", 1, "s16")
   } ; Menu3
Alto := CorpusCount*20+20
posyExit:=20*CorpusCount
Gui, ContextClip: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner
posyExitSess := posyExit+20
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\Reducedcap.png"
Gui1.Button7.PressedImage := "Resources\Reducedcap1.png"
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, x427 y%posyExit% W30 h32 hwndhwnd, % Gui1.Button8.DefaultImage
Gui1.Handles[ hwnd ] := "Button8" ;The name of the control to point at.
Gui1.Button8.Hwnd := hwnd
;***********************************************************************
Gui1.Button9 := {} ;Button 9 
Gui1.Button9.DefaultImage := "Resources\Cabinet_2.png"
Gui1.Button9.HoverImage := "Resources\Cabinet_2.png"
Gui1.Button9.PressedImage := "Resources\Cabinet_3.png"
Gui1.Button9.Label := "GuiUtily_Close" 
Gui, ContextClip: Add, Picture, x457 y%posyExit% W31 h32 hwndhwnd, % Gui1.Button9.DefaultImage
Gui1.Handles[ hwnd ] := "Button9" ;The name of the control to point at.
Gui1.Button9.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
}
If ControlThree=1
{
xpos1 := xLabel
ypos1 := yLabel
ControlThree:=0
}

If xpos1=0
{
xpos1 := Floor((A_ScreenWidth/2)-450)
ypos1 := Floor((A_ScreenHeight/2)-200)
}

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
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
StringTrimLeft, REdit, a_guicontrol, 7
FileChange := "HTMLTemp\Name" REdit ".txt"
FileRead, FileCont, %FileChange%
Gui, Edit: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +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, 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-566
EdYm := pYm-99
Gui, Edit:Show, x%EdXm% y%EdYm% w564
Return

TitleSave:
Gui, Edit: Submit
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 :=""
Gui, Edit: Destroy
ControlThree=1
Gosub, RButton
Return

TitleCancel:
Gui, Edit: Destroy
MyEdit :=""
FileCont :=""
FileChange :=""
ControlThree=1
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: -Caption +alwaysontop +ToolWindow +0x400000 +hWndhMainWnd +Owner ;Menu31s
Gui, ContextClip1: color,ffffd6
Gui, ContextClip1: Add, Button, x20 y%posyExit% w420 h20 gExitLabel, Exit Menu
Gui, ContextClip1: Add, Button, x440 y%posyExit% w20 h20 hwndIcon20 gExtendedM
Gui, ContextClip: Font, S9 Bold, Verdana
posyExitSess1 := posyExit+08
Gui, ContextClip1: Add, Text, x0 y%posyExit% w20 h20 GuiMove
Gui, ContextClip1: Add, Button, x0 y%posyExit% w20 h20 hwndIcon21
AltoT := Floor((CorpusCount+1)*25.4)
XPos:= A_ScreenWidth-(460)
YPos:= A_ScreenHeight-AltoT
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, "s20")
GuiButtonIcon(Icon20, "Resources\ArrowArr.ico", 1, "s20")
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
GoSub, Toggle_Switch
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
GoSub, Toggle_Switch
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:
GetKeyState, state, Control
if (state = "D")
 {
 StringTrimLeft, GoURL, a_guicontrol, 4
 gURL := "HTMLTemp\Text" GoURL ".html"
 NewURL:="HTMLTemp\URL" GoURL ".txt"
 FileDelete, %NewURL%
 FileRead, ExtracURL, %gURL%
 StringTrimLeft, item, ExtracURL, 154 
 StringTrimRight, item2, item, 32 
 LenText := StrLen(item2)
 StringGetPos, pos, item2, >, r1
 Resta:= LenText-pos
 StringTrimRight, item3, item2, %Resta%
 FileAppend, %item3%, %NewURL%
 If !NewURL or SizeFile=0
   {
   MsgBox, URL could not be retrieved
   }
 Gui, ContextClip: Destroy
 Gosub, RButton
 Return
 }
StringTrimLeft, TextURL, a_guicontrol, 4
gURL := "HTMLTemp\URL" TextURL ".txt"
FileRead, WebURL, %gURL%
StringRight, OutPDF, WebURL, 3
;MsgBox, %WebURL%
If OutPDF=pdf
  {
  Run, %WebURL%
  }
Else
 {
 Run, %WebURL%, , Max UseErrorLevel
 if (ErrorLevel = "ERROR")
  {
  WebURL:= "https://" WebURL
  Run, %WebURL%
  }
}
Return

HelpButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: New
Gui, Help: -Caption +Owner
Gui, Help: Color, EEAA99
Gui, Help: Margin, 0, 0
Gui, Help: Add, Picture, x0 y0 w800 h400, Resources\Help.jpg
Gui, Help: Add, Button, x650 y374 w80 h20 gNextButton, More...
Gui, Help: Show, w800 h400
Return

NextButton:
SoundPlay, Resources\Close Window.mp3
Gui, Help: Destroy
Gui, Help2: New
Gui, Help2: -Caption +Owner
Gui, Help2: Color, EEAA99
Gui, Help2: Margin, 0, 0
Gui, Help2: Add, Picture, x0 y0 w800 h400, Resources\Clipboard Utility Screenshot.jpg
Gui, Help2: Add, Button, x30 y375 w80 h20 gExitButton, Exit
Gui, Help2: Show, w800 h400
Return

ExitButton:
Gui, Help2: Destroy
Return

!esc::
Gui, 2: Destroy
Gui, ContextClip: Hide
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-630
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 h74, 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 h74
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

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-566
DelYm := pYm-32
Gui, 5: Show, x%DelXm% y%DelYm% w563 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
GuiControl, Move, WB, h%maxBottom%
gui, 7: Show, x%pXm% y%pYm% w62 h60
status_Editing_old:=status_Editing
Return
;*************************************************************************

^F5::
ControlPaste:
MsgBox, 0x1034,, You have requested to paste all the contents of the clipboard.`nDo you have an open text editor?`n`nThe mouse cursor will stop working and freeze, due to the need for the operation.`n`n (Press the 'Mays+ESC' key to interrupt the process)
IfMsgBox No 
Return
Else
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
Sleep, 1000
Gui, Utily: Destroy
MouseGetPos,PosX,PosY, WinUMID
;WinActivate, ahk_id %WinUMID%
run %A_WorkingDir%\Addons\nomousy.exe -freeze ; This program freezes the mouse position, but it doesn't seem to work well with the command "WinActivate"
SystemCursor(0)
WinClip.Clear()

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>———————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;'font-size:24.0pt;color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%, SessionWord.html
html := FileOpen("SessionWord.html", "r").read()
WinClip.SetHTML(html)
WinClip.Paste()
Send, `n

ProgressNum:=100//CorpusCount ;Sets the number of times the progress bar will be updated
KillerLoop:=0

Gui, Barr: -Caption +AlwaysOnTop +Owner
Gui, Barr: Margin, 8, 8
Gui, Barr: Add, Progress, vProgress1 -Smooth w350 h28 Disabled
Gui, Barr: Font, S10 Bold, Verdana
Gui, Barr: Add, Text,, Pasting Clipboards in Process...
Gui Barr: Add, Text, xp+170 yp h20 w180 +center +BackgroundTrans vProgTxt
Gui, Barr: Show

Loop, %CorpusCount% ;Loop Number ;so many loops are given as clipboard exist
   {
     if KillerLoop=1
	  {
	  Break
	  }
	GuiControl, Barr: , Progress1, +%ProgressNum% ; Problem: When updating the progress bar, the focus of the background application is lost.
	GuiControl Barr:, ProgTxt, % "(" A_Index "/" CorpusCount ")"
	WinActivate, ahk_id %WinUMID% ;It is necessary to activate the background window
	Mousemove, PosX, PosY ;Try that the mouse is always in the same position
	run %A_WorkingDir%\Addons\nomousy.exe -freeze ; This program freezes the mouse position, but it doesn't seem to work well with the command "WinActivate"?
	Sleep, 1200
	WinClip.Clear()
	html := FileOpen("HTMLTemp\Text" A_Index ".html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()
	Sleep, 600
	html := FileOpen("Resources\Line1.html", "r").read()
	WinClip.SetHTML(html)
	WinClip.Paste()
	WinClip.Clear()	
	html := FileOpen("HTMLTemp\Corpus" A_Index ".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
   }
Gui, Barr: destroy
SystemCursor(1) ; Disable mouse hide
run %A_WorkingDir%\Addons\nomousy.exe ; Disable mouse freeze
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
}
FileDelete, SessionWord.html
WinClip.Clear()
Return

+Esc::
KillerLoop:=1
Return
 
^F10::
DeleteAll:
MsgBox, 0x1034,, Do you want to delete all stored clipboards?
IfMsgBox Yes 
Gosub, Borrado
Return

^F6::
SavePDF:
SoundPlay, Resources\Close Window.mp3
MsgBox, 0x1024,, Convert %CorpusCount% Clipboard to a PDF File?
IfMsgBox No
Return
Else
Gui, Utily: Destroy
Sleep, 1000

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>————————————————————————————————————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman; color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%<br/>, ToPDF.html

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\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%
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

FileRead, Session1, HTMLTemp\Session.txt
SessionHtml:="<body lang=ES style='tab-interval:35.4pt;word-wrap:break-word'><p class=MsoNormal align=center style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:center;line-height:106%'><b><span style='font-size:20.0pt;line-height:106%;font-family:Times New Roman,serif;mso-fareast-font-family:Calibri;color:#2F5496;mso-themecolor:accent1;mso-themeshade:191;mso-fareast-language:ES'>" Session1 "<br></span></b><b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman;color:#78230C;mso-fareast-language:ES'>———————————————————————————————————————————————————————————</span></b><span style='font-family:Courier New;mso-fareast-font-family:Times New Roman; color:#78230C;mso-fareast-language:ES'><o:p></o:p></span></p></body>"
FileAppend, %SessionHtml%<br/>, ToWord.html, CP65001
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
	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::
DeleteLast:
MsgBox, 0x1034,, Do you want to delete the last entrance of the clipboard?
IfMsgBox Yes
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
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, ReloadMenu
Return

ButtonTwo:
StringTrimLeft, NumberFile, a_guicontrol, 9
Gosub, ButtonLabel
Return

ActualDelSessions:
MsgBox, 0x1034,, Are you sure want to delete the current session? `n`n (Changes Cannot be Reversed)
IfMsgBox No
Return

FileRemoveDir, HTMLTemp , 1
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index

SessMas:=SessionTotal+2
WGroup:=SessMas*29 ;23.5
ButtGroup:=WGroup+29
mWGroup:=WGroup-30

ActTitle:="  Choose the Current Session"
Gui, Choose: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, Choose: Font, S10 Bold, Verdana
Gui, Choose: Add, Picture, x0 y0 h20 w360 h32, Resources\Fondo_Limp_S.png
Gui, Choose: Add, Text, cYellow BackgroundTrans x35 y6 W300 h32 GuiMove, %ActTitle% ;Choose the Current Session...
Gui, Choose: Font, S9, Segoe UI
Gui, Choose: add, Button, disabled x0 y32 w360 h24 ;Create A New Session or Choose From the Available Ones…
Gui, Choose: add, Text, x10 y36 BackgroundTrans, Create A New Session or Choose From the Available Ones…
;Gui, Choose: Add, GroupBox, x0 y12 w360 h24
Gui, Choose: Add, Radio, x10 y60 w280 h20 vRadioNewSession cRed checked, Create A New Session
;Gui, Choose: Add, Radio, x10 y60 w280 h20 vRadioNewSession cRed checked, Create A New Session
Loop, Read, SessionNumber.txt
{
Gui, Choose: Add, Radio, y+1 w320 h20 vMyRadioGroup%A_Index% cBlue, %A_LoopReadLine%
}
Gui, Choose: Add, GroupBox, x5 y52 w350 h%mWGroup%,
Gui, Choose: Add, Button, x8 y%ButtGroup% w80 gChooseOK, OK
Gui, Choose: Show, xCenter yCenter w360 ;AutoSize
Return

ChooseOK:
Gui, Choose: Submit
If RadioNewSession=1
{
RadioNewSession:=""
Gosub, NewDelSession
Return
}

Loop, %SessionTotal%
{
 If MyRadioGroup%A_Index%=1
 {
 NameFull:= A_WorkingDir "\HTMLTemp" A_Index
 ;MsgBox, %A_Index% - %NameFull%
 FileMoveDir %NameFull%, %A_WorkingDir%\HTMLTemp, R
 FileCreateDir, %NameFull%
 FileAppend, %A_ScriptDir%, %NameFull%\Session.txt
 }
}

Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index

;-------------------------------------------------
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)
If FilesCount=0
   {
   FileRemoveDir, %NameDir%, 1
   IndiDir--
   SumDir++
   }
}

;If IndiDir<>DirectoryCount
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

Iniciate:=0
MyRadioGroup%A_Index%:=""
RadioNewSession:=""
Gui, Choose: Destroy
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Gui, Choose: Destroy
Gosub, ReloadSession
}
Return
;-------------------------------------------------

LabelSession:
MsgBox, 0x1024,, You want the session %A_ThisMenuItem% to be the default session?
IfMsgBox No
Return

FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
NumSess := A_Index-1
NumberPos:= A_ThisMenuItemPos-5

   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
   FileMoveDir %DirectorySess%, %DirectorySess00%, R

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

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  
FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Iniciate:=0
threeRButton=1
Gosub, ReloadSession
Return

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

ButtonLabel:
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,2: Destroy
Gui, Gui1: 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

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
Return
}
If Toggle=1
{
Hotkey, +LButton Up, off
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
ClipBoardEnabled=0
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
URLCount ++
FileURL := "Documents\Extracted_Links_" CurrentDate "-" URLCount ".html"
FileURLImg := "Documents\Extracted_Links_Img_" CurrentDate "-" URLCount ".html"
FileMove, Extracted_Links.html, %FileURL%
FileMove, Extracted_Links_Img.html, %FileURLImg%
FileDelete, ToPDF.html
Run, %FileURL% 
Sleep, 800
Run, %FileURLImg%
ClipBoardEnabled=1
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

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

^F2::
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
GetText(Txt)
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", "él", "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", "tras"]
for k, v in lowers
low .= (k = 1 ? "" : "|") . v
Txt := RegExReplace(Txt, "(*UCP)(^|\b(?!(" . low . ")\b))\w|(\.|\?|!)\s*\K\w|-\K\w", "$T0")
PutText(Txt)
If ChangeClipEnable=1
{
WinClip.Clear()
ClipBoardEnabled=1
ChangeClipEnable=0
}
Return

^F1::
CaseMays:
If !ClipBoardEnabled=0
{
ClipBoardEnabled:=0
ChangeClipEnable=1
}
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
Menu Mays, Add, &Invert Text, 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", "él", "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", "tras"]
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 
  }
}
Else If (p=8)
{
GetText(Txt)
Flip =
Loop, Parse, Txt
	Flip := A_LoopField Flip
Txt = % Flip
}
PutText(Txt)
If ChangeClipEnable=1
 {
 WinClip.Clear()
 ClipBoardEnabled=1
 ChangeClipEnable=0
 }
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:
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
Gui, MxClips: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, MxClips: Font, S10 Bold, Verdana
Gui, MxClips: Add, Picture, x0 y0 h20 w290 h32, Resources\Fondo_Limp_S.png
Gui, MxClips: Add, Text, cYellow BackgroundTrans x35 y6 W290 h32 GuiMove, Maximum Number of Clipboards
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y43 h28 w200, Maximum Number of Clipboards:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y41 h20 w40 vMaxClipsS, %MaxClips%
Gui, MxClips: Font, S9, Segoe UI
Gui, MxClips: Add, Text, x20 y74 h28 w200, Number of Clipboard to Show:
Gui, MxClips: Font, S9 Bold, Verdana
Gui, MxClips: Add, Edit, x225 y73 h20 w40 vShowClipsS, %ShowClip%
Gui, MxClips: Font, S8 Bold, Verdana
Gui MxClips: Add, Button, x35 y110 w70 h20 gMxClipsSave, OK
Gui MxClips: Add, Button, x163 y110 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

NewDelSession:
;WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
Gui, SessionDel: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +Owner
Gui, SessionDel: Font, S10 Bold, Verdana
Gui, SessionDel: Add, Picture, x0 y0 h20 w562 h32, Resources\Fondo_Limp.png
Gui, SessionDel: Add, Text, cYellow BackgroundTrans x35 y6 W560 h32 GuiMove, Session Name
Gui, SessionDel: Add, Text, x0 y33 w563 0x10 ; 0x7 Black
Gui, SessionDel: Font, S8 Bold, Verdana
Gui, SessionDel: Add, Edit, x5 y40 vSessDelEdit h20 w544, New Session
Gui SessionDel:Add,  Button, x20 y70 w70 h20 gSessionDelSave, OK
;Gui SessionDel:Add,  Button, x120 y70 w70 h20 gSessCancel, Cancel
;Gui SessionDel:Add, CheckBox, x220 y70 w280 h20 Checked1 vVeryfySession, Activate the New Session when Creating

xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)

Gui, SessionDel: Show, x%xSess% y%ySess% w562
Return

SessionDelSave:
;FileDelete, SessionTemp.txt
FileCreateDir, HTMLTemp
Gui, SessionDel: Submit
;Loop, %A_ScriptDir%\HTMLTemp*, 2, 0

;SessionTotal1 := A_Index
;FileCreateDir, HTMLTemp%SessionTotal1%
;FileAppend, %A_ScriptDir%, SessionTemp.txt
;FileSession := "\HTMLTemp\Session.txt"
;FileAppend, %FileSession%, SessionTemp.txt
;FileRead, Directory, SessionTemp.txt

;FileAppend, %SessDelEdit%, %Directory%
FileAppend, %SessDelEdit%, %A_ScriptDir%\HTMLTemp\Session.txt

Menu, ClipboardID, DeleteAll
Menu, SessionID, DeleteAll
;PosSession:=0
Iniciate:=0
SessDelEdit:=""
MyRadioGroup%A_Index%:=""
RadioNewSession:=""
Gui, Choose: Destroy
Gui, SessionDel: Destroy
threeRButton=1
Gosub, ReloadSession
Return

^!F4::
NewSession:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
Gui, Session: -Caption +alwaysontop +ToolWindow +hWndhMainWnd +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, 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
Gui Session:Add, CheckBox, x220 y70 w280 h20 Checked1 vVeryfySession, Activate the New Session when Creating
xSess := Floor((A_ScreenWidth/2)-448)
ySess := Floor((A_ScreenHeight/2)-200)
If PosSession=1
{
xSess := pXm-566
ySess := pYm-99
}
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
FileRead, Directory, SessionTemp.txt
FileAppend, %SessEdit%, %Directory%

If VeryfySession=1
{
FileDelete, SessionTemp*.txt
FileDelete, SessionTemp00.txt
FileDelete, SessionTemp01.txt
Loop, %A_ScriptDir%\HTMLTemp*, 2, 0
SessionTotal := A_Index-1

   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
   FileMoveDir %DirectorySess%, %DirectorySess00%, R

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

  FileRead, DirectorySess01, SessionTemp01.txt
  FileRead, DirectorySess, SessionTemp.txt
  FileRead, DirectorySess00, SessionTemp00.txt
  
FileMoveDir %DirectorySess01%, %DirectorySess%, R
FileMoveDir %DirectorySess00%, %DirectorySess01%, R
Menu, SessionID, DeleteAll
Menu, ClipboardID, DeleteAll
Gui, ContextClip: Destroy
}

Menu, ClipboardID, DeleteAll
Menu, SessionID, DeleteAll
PosSession:=0
Iniciate:=0
SessEdit :=""
VeryfySession :=""
ControlThree=1
Gosub, ReloadSession
Return

MxClipsSave:
Gui, MxClips: Submit
Max_Index:=ClipBoardHistory.MaxIndex()
If (MaxClipsS<Max_Index)
   {   
   TempNumberClip:= Max_Index-MaxClipsS
   Loop, %TempNumberClip%
     {     
     ClipBoardHistory.removeAt(1)
     Description.removeAt(1)
     CRC32.removeAt(1)
     If OneByOne=1      
      {
      Gosub, RewriteClip
      }
     }
   ;IniWrite, %MaxClipsS%, Config.ini, Setting_Clipboard, MaxClips   
   }

IniWrite, %ShowClipsS%, Config.ini, Setting_Clipboard, ShowClip
Gosub, RelocateClips
ShowClipsS:=""
MaxClipsS:=""
TempNumberClip:=""
Gui, MxClips: Destroy
;Gosub, Style
Gosub, Reloaded
Return

RewriteClip:
FileDelete, TempClip\Clip*.clip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips

Max_Index:=ClipBoardHistory.maxIndex()
Loop, %Max_Index%
   {
   SaveClip:=ClipBoardHistory[A_Index]
   FileSave:= "TempClip\Clip" A_Index ".Clip"
   FileAppend, %SaveClip%, %FileSave%
   }
Return

RelocateClips:
IniRead, ShowClip, Config.ini, Setting_Clipboard, ShowClip
IniRead, MaxClips, Config.ini, Setting_Clipboard, MaxClips
If (ShowClip>MaxClips)
  {  
  ShowClip:=MaxClips
  IniWrite, %ShowClip%, Config.ini, Setting_Clipboard, ShowClip
  }
Return

ClipCancel:
Gui, Session: Submit
Gui, MxClips:Destroy
Return

SessCancel:
Gui, Session:Destroy
Gui, RenSession:Destroy
SessEdit :=""
ReSessEdit :=""
PosSession:=0
ControlThree=1
Gosub, RButton
Return

LabelSessionAct0:
Position :=0
Gosub, LabelSessionAct
Return

LabelSessionAct1:
Position :=1
Gosub, LabelSessionAct
Return

LabelSessionAct:
WinGetPos, xLabel, yLabel,,, ahk_class AutoHotkeyGUI
GetKeyState, state, Control
if (state = "D")
 {
PosSession:=1
Gosub, NewSession
Return
}

Gosub, NewWindow
ReadSess := "HTMLTemp\Session.txt"
FileRead, RenSession, %ReadSess%
Gui, RenSession: -Caption +alwaysontop +ToolWindow +hWndhMainWnd 
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, 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-566
ySess := pYm-99
}
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
Menu, ClipboardID, DeleteAll
Menu, SessionID, DeleteAll
Iniciate:=0
ReSessEdit :=""
ControlThree=1
Gui, RenSession: Destroy
Gosub, ReloadSession
Return

DeleteSessions:
MsgBox, 0x1034,,     Do you Really want to Delete the Empty Sessions? `n`n (If the Current Session is Empty, it Will not be Deleted)
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)
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:
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
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
if A_IsSuspended=0
  {
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, The Application has Been Activated
  xSplash1 := A_ScreenWidth-506
  ySplash1 := A_ScreenHeight-180
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
    ;If ChangeClipEnable=0 ;SuspendHotkeys=1
    ;{
    ;Gosub, SuspendBasicClip
  If (ClipBoardEnabled=0 and ChangeClipEnable=1)
    {
    ;Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
    xSplash1 := A_ScreenWidth-506
    ySplash1 := A_ScreenHeight-180
    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
    ;ChangeClipEnable=1
    }
  }
 if A_IsSuspended=1
  {
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, The Application has Been Deactivated
  xSplash1 := A_ScreenWidth-506
  ySplash1 := A_ScreenHeight-180
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  ;If ChangeClipEnable=1
  ;  {
  ;  Gosub, SuspendBasicClip
  If (ClipBoardEnabled=1 and ChangeClipEnable=1)
   {
   ;Menu, BasicClipID, ToggleCheck, Disable Basic Clipboard
   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
   ;ChangeClipEnable=0
   }
  }
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, ^!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, ^!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

BackupOneByOne:
Menu, BasicClipID, ToggleCheck, Backup One by One
xSplash1 := A_ScreenWidth-506
ySplash1 := A_ScreenHeight-180
If OneByOne=1
  {
  OneByOne:=0
  IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Disabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=1
  }
else
  {
  OneByOne:=1
  IniWrite, 1, Config.ini, Setting_Clipboard, OneByOne
  SoundPlay, Resources\Close Window.mp3
  SplashTextOn,500, 80, Notification, Backup One by One Enabled
  WinMove, Notification,, xSplash1, ySplash1
  Sleep, 1500
  SplashTextOff
  DisableWrite:=0
  Gosub, RewriteClip
  }
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
ChangeClipEnable=1
}
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
ChangeClipEnable=0
}
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, 30, Config.ini, Setting_Clipboard, MaxClips
IniWrite, 1, Config.ini, Setting_Clipboard, ClipBoardEnabled
IniWrite, 15, Config.ini, Setting_Clipboard, ShowClip
IniWrite, 0, Config.ini, Setting_Clipboard, OneByOne
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 Double Menu
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

EditFavotites:
Run Notepad.exe TempClip\Favorites.fav
Return
CreateMissing:
CountImg := 0
Loop, %CorpusCount%
if !FileExist("HTMLTemp\Image" A_Index ".jpg")
{
Corpus := A_ScriptDir "\HTMLTemp\Corpus" A_Index ".html"
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_1.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

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

;---------------------------------------------------------------
;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 and OneByOne=1)
	  {	  
	  ClipTemp:= "TempClip\Clip" Max_Index ".clip"
	  FileAppend, %Clip%, %ClipTemp%
	  }
	Gosub, CreateDescription
   if (Max_Index>MaxClips)
	{
	ClipBoardHistory.removeAt(1)
	If OneByOne=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)<60)
  {
  Description.insert(Object())
  Max_Descr:=Description.MaxIndex()
  Description[Max_Descr]:=Descrp
  ;DescriptionClip:=Description[Max_Descr]  
  }
Else
  {
  toCut:=StrLen(Descrp)-15 
  StringMid, itemTemp1, Descrp, 1, 40
  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=60, 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:
for XClip, element in CRC32
if CRCClip = %element%
{
  Description.removeAt(XClip)
  ClipBoardHistory.removeAt(XClip)
  CRC32.removeAt(XClip)
  If OneByOne=1
   {
   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

;---------------------------------------------------------------------
;by polyethene http://www.autohotkey.com/forum/post-119507.html
;modified by Ageless http://www.autohotkey.com/forum/post-128491.html
uriEncode(str) {
   f = %A_FormatInteger%
   SetFormat, Integer, Hex
   If RegExMatch(str, "^\w+:/{0,2}", pr)
      StringTrimLeft, str, str, StrLen(pr)
   StringReplace, str, str, `%, `%25, All
   Loop
      If RegExMatch(str, "i)[^\w\.~%/:]", char)
         StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All
      Else Break
   SetFormat, Integer, %f%
   Return, pr . str
}

uriDecode(str) {
   Loop
      If RegExMatch(str, "i)(?<=%)[\da-f]{1,2}", hex)
         StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
      Else Break
   Return, str
}

;------------------------------------------------------------------------------------------------
SystemCursor(OnOff=1)   ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
    static AndMask, XorMask, $, h_cursor
        ,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
        , b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13   ; blank cursors
        , h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13   ; handles of default cursors
    if (OnOff = "Init" or OnOff = "I" or $ = "")       ; init when requested or at first call
    {
        $ := "h"                                       ; active default cursors
        VarSetCapacity( h_cursor,4444, 1 )
        VarSetCapacity( AndMask, 32*4, 0xFF )
        VarSetCapacity( XorMask, 32*4, 0 )
        system_cursors := "32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650"
        StringSplit c, system_cursors, `,
        Loop %c0%
        {
            h_cursor   := DllCall( "LoadCursor", "Ptr",0, "Ptr",c%A_Index% )
            h%A_Index% := DllCall( "CopyImage", "Ptr",h_cursor, "UInt",2, "Int",0, "Int",0, "UInt",0 )
            b%A_Index% := DllCall( "CreateCursor", "Ptr",0, "Int",0, "Int",0
                , "Int",32, "Int",32, "Ptr",&AndMask, "Ptr",&XorMask )
        }
    }
    if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
        $ := "b"  ; use blank cursors
    else
        $ := "h"  ; use the saved cursors

    Loop %c0%
    {
        h_cursor := DllCall( "CopyImage", "Ptr",%$%%A_Index%, "UInt",2, "Int",0, "Int",0, "UInt",0 )
        DllCall( "SetSystemCursor", "Ptr",h_cursor, "UInt",c%A_Index% )
    }
}
(This is versión 96DPI. I work on the 150 DPi version. Then through a comparison program, I copy the changes over to the 96 DPI version. I don't review this version much. May contain errors or inconsistencies.)

Download all necessary files: https://mega.nz/file/VRhV1arR#cyA5EUMrA0ZRhlMvD5CSx5ryQo5q2wWU0f627hK_wKY
------------------
Reissued on July 22:

Improved the scaling of the session deletion window. Improved the sticking of the basic clipboard. Now it pastes the clipboard correctly in some small dialogs (the ones that have to be activated previously through a mouse click).

It's not changed in the code, but it is in the following download: https://mega.nz/file/oVIEVC5Y#cCxCDhX4rx4f10MH9MhluowUaECRIQ8bpXUNIwV0JZ8

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kaka2 and 98 guests