#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=icon.ico #AutoIt3Wrapper_Outfile=ExcelTools.exe #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=Custom toolset for Excel #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_LegalCopyright=Ludo Hille Ris Lambers #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Ludo Hille Ris Lambers Script Function: Handy little functions for automating simple tasks #ce ---------------------------------------------------------------------------- ;!Highly recommended for improved overall performance and responsiveness of the GUI effects etc.! (after compiling): #Au3Stripper_On #Au3Stripper_Parameters=/so /rm /pe $iconpath = @AppDataDir&'\ivyicon.bmp' $helppath = @AppDataDir&'\help.txt' FileInstall("C:\Users\Ludo\Desktop\Gate OBS\Programma's\ExcelTools\help.txt", $helppath, 1) FileInstall("C:\Users\Ludo\Desktop\Gate OBS\Programma's\ExcelTools\ivyicon.bmp", $iconpath, 1) ;Required if you want High DPI scaling enabled. (Also requries _Metro_EnableHighDPIScaling()) ;#AutoIt3Wrapper_Res_HiDpi=Y ; Script Start #include #include #include #include #include #include #include #include "MetroGUI-UDF\MetroGUI_UDF.au3" global $code = "%=", $keys, $GUI global $color[3] = [255,255,255] global $delay = 50 AutoItSetOption("SendKeyDelay", 0) AutoItSetOption("SendKeyDownDelay", 0) AutoItSetOption("TrayOnEventMode", 1) AutoItSetOption("TrayMenuMode", 1) TraySetToolTip("Click to show window") ;HotKeySet("\", "_Function1") ;HotKeySet("=", "_Function2") ;HotKeySet("\", "_Function3") TraySetOnEvent(-7, '_Show') $helptext = FileRead($helppath) _SetTheme("IVYGlobal") _Metro_EnableHighDPIScaling() $txtcolor = 0xFFFFFF $ivygreen = 0x95C23D $darkcolor = 0x00000 $width = 650 $height = 560 $Form1 = _Metro_CreateGUI("ExcelTools", $width, $height, -1, -1, True) $Control_Buttons = _Metro_AddControlButtons(True, True, True, True, True) $GUI_BACK_BUTTON = _Metro_AddControlButton_Back() GUICtrlSetState(-1, $GUI_HIDE) $GUI_CLOSE_BUTTON = $Control_Buttons[0] $GUI_MAXIMIZE_BUTTON = $Control_Buttons[1] $GUI_RESTORE_BUTTON = $Control_Buttons[2] $GUI_MINIMIZE_BUTTON = $Control_Buttons[3] $GUI_FULLSCREEN_BUTTON = $Control_Buttons[4] $GUI_FSRestore_BUTTON = $Control_Buttons[5] $GUI_MENU_BUTTON = $Control_Buttons[6] $l = 5 $t = 50 $b = 66 + $t ; Begin pos Toggles $b1 = 105 + $t ; Begin pos Inputs $m = 48 ; Margins Toggles $m1 = 60 ; Margins Inputs $begin = 20 $end = $begin + 35 Global $line = "______________________________" _CreateGUI() _Loop() Func _CreateGUI() $GUI = "Home" #Region ### START Koda GUI section ### Form= Global $Edit = GUICtrlCreateEdit("", 40, 56, 730, 550, $ES_READONLY + $WS_VSCROLL) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetFont(-1, 12, 400, "", "Calibri") GUICtrlSetData($Edit, $helptext) global $aboutlabel = GUICtrlCreateEdit(@CRLF&"Designed and created by"&@CRLF&@CRLF&"Ludo Hille Ris Lambers"&@CRLF&$line&@CRLF&@CRLF&"All rights reserved"&@CRLF&@CRLF&"Ludo Hille Ris Lambers", 100, 120, 600, 400, $ES_READONLY+$SS_CENTER) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetFont(-1, 18, 300,0, "Calibri Light") GUICtrlSetColor(-1, $darkcolor) global $contactlabel = GUICtrlCreateEdit(@CRLF&"Contact Ludo at:"&@CRLF&@CRLF&"lla@ivyglobal.eu"&@CRLF&$line&@CRLF&@CRLF&"Or click the button below", 100, 120, 600, 300, $ES_READONLY+$SS_CENTER) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetFont(-1, 18, 300,0, "Calibri Light") GUICtrlSetColor(-1, $darkcolor) Global $contactbut = _Metro_CreateButton('Contact', $l + 250, 400, 130, 40) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetResizing(-1, 8+768) Global $titlelabel = GUICtrlCreateLabel("ExcelTools", 80, 6, 200, 28) GUICtrlSetFont(-1, 12) GUICtrlSetColor(-1, $txtcolor) Global $Label2 = GUICtrlCreateLabel("Hotkey", $l + 300, $t + 16, 100, 28) GUICtrlSetFont(-1, 14) GUICtrlSetColor(-1, $txtcolor) Global $Label3 = GUICtrlCreateLabel("Tool", $l + 110, $t + 16, 90, 28) GUICtrlSetFont(-1, 14) GUICtrlSetColor(-1, $txtcolor) Global $Label4 = GUICtrlCreateLabel("Instructions", $l + 500, $t + 16, 130, 28) GUICtrlSetFont(-1, 14) GUICtrlSetColor(-1, $txtcolor) $grp = GUICtrlCreateGraphic( $l + 15, $t + 55, 750, 1) GUICtrlSetColor(-1, $txtcolor) Global $Checkbox2 = _Metro_CreateToggle("To UPPERCASE", $l + 40, $b, 180, 30) Global $Hotbut2 = _GUICtrlCreateInput("", $l + 320, $b1, 30, 25, $SS_CENTER) Global $Checkbox3 =_Metro_CreateToggle("To Lowercase", $l + 40, $b + ($m*1), 180, 30) Global $Hotbut3 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*1), 30, 25, $SS_CENTER) Global $Checkbox6 = _Metro_CreateToggle("Prepend text", $l + 40, $b + ($m*2), 180, 30) Global $Hotbut6 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*2), 30, 25, $SS_CENTER) Global $Input11 = GUICtrlCreateInput("", $l + 430, $b1+($m1*2), 200, 24) Global $Checkbox5 = _Metro_CreateToggle("Append text", $l + 40, $b + ($m*3), 180, 30) Global $Hotbut5 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*3), 30, 25, $SS_CENTER) Global $Input10 = GUICtrlCreateInput("", $l + 430, $b1+($m1*3), 200, 24) Global $Checkbox7 = _Metro_CreateToggle("Mark with color", $l + 40, $b + ($m*4), 180, 30) Global $Hotbut7 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*4), 30, 25, $SS_CENTER) Global $pickcolor = _Metro_CreateButton("Pick color", $l + 450, ($b1+($m1*4))/1.25, 80, 20, $ButtonBKColor, $txtcolor, "Arial", 10) Global $Graphic = GUICtrlCreateGraphic($l + 430, $b1+($m1*4), 105, 25) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $c = 0xFFFFFF GUICtrlSetColor(-1, 0x00000) Global $Checkbox1 = _Metro_CreateToggle("Replace", $l + 40, $b + ($m*5), 180, 30) Global $Input1 = GUICtrlCreateInput("", $l + 430, $b1+($m1*5), 120, 24) Global $Label1 = GUICtrlCreateLabel("--->", $l + 575, $b1+($m1*5)+2, 80, 20) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, $txtcolor) Global $Input2 = GUICtrlCreateInput("", $l + 620, $b1+($m1*5), 120, 24) Global $Hotbut1 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*5), 30, 25, $SS_CENTER) Global $Checkbox8 = _Metro_CreateToggle("Replace (RegExp)", $l + 40, $b + ($m*6), 200, 30) Global $Input12 = GUICtrlCreateInput("", $l + 430, $b1+($m1*6), 120, 24) Global $Label1 = GUICtrlCreateLabel("--->", $l + 575, $b1+($m1*6)+2, 80, 20) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, $txtcolor) Global $Input13 = GUICtrlCreateInput("", $l + 620, $b1+($m1*6), 120, 24) Global $Hotbut8 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*6), 30, 25, $SS_CENTER) Global $Checkbox4 = _Metro_CreateToggle("Replace between", $l + 40, $b + ($m*7), 180, 30) Global $Hotbut4 = _GUICtrlCreateInput("", $l + 320, $b1+($m1*7), 30, 25, $SS_CENTER) Global $Input7 = GUICtrlCreateInput("", $l + 430, $b1+($m1*7), 65, 24) Global $Label7 = GUICtrlCreateLabel("AND", $l + 510, $b1+($m1*7)+2, 33, 20) GUICtrlSetColor(-1, $txtcolor) Global $Input8 = GUICtrlCreateInput("", $l + 550, $b1+($m1*7), 65, 24) Global $Label8 = GUICtrlCreateLabel("--->", $l + 635, $b1+($m1*7)+2, 23, 20) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, $txtcolor) Global $Input9 = GUICtrlCreateInput("", $l + 670, $b1+($m1*7), 100, 24) Global $hidebut = _Metro_CreateButton('Hide window', $l + 250, ($b1+($m1*8))/1.25, 130, 40) GUICtrlSetResizing(-1, 8+768) $pic = GUICtrlCreatePic($iconpath, $l + 20, ($b1+($m1*8))-10, 100, 57) GUICtrlSetState(-1, $GUI_HIDE) Global $MenuButtonsArray[4] = ["Help", "About", "Contact", "Exit"] GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### EndFunc Func _Loop() While 1 _Metro_HoverCheck_Loop($Form1) $nMsg = GUIGetMsg() Switch $nMsg Case $contactbut ShellExecute("mailto:lla@ivyglobal.eu") Case $hidebut TrayTip("", "Click on the icon to show the window again", 3) GUISetState(@SW_HIDE, $Form1) Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON Exit Case $GUI_MAXIMIZE_BUTTON GUISetState(@SW_MAXIMIZE) Case $GUI_RESTORE_BUTTON GUISetState(@SW_RESTORE) Case $GUI_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE) Case $GUI_FULLSCREEN_BUTTON, $GUI_FSRestore_BUTTON _Metro_FullscreenToggle($Form1, $Control_Buttons) Case $GUI_MENU_BUTTON Local $MenuSelect = _Metro_MenuStart($Form1, $GUI_MENU_BUTTON, 150, $MenuButtonsArray, "Segoe UI", 9, 0) ; Opens the metro Menu. See decleration of $MenuButtonsArray above. Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" GUISetState(@SW_LOCK) _ShowHelpGUI() GUISetState(@SW_UNLOCK) Case "1" _ShowAboutGUI() Case "2" _ShowContactGUI() Case "3" _Metro_GUIDelete($Form1) Exit EndSwitch Case $GUI_BACK_BUTTON GUISetState(@SW_LOCK) _ShowHomeGUI() GUISetState(@SW_UNLOCK) Case $pickcolor $c = _ChooseColor(2, $c, 2) $color = _ColorGetRGB($c) GUICtrlSetBkColor($Graphic, $c) Case $Checkbox1 _Toggler($Checkbox1, $Hotbut1, "_Function1") Case $Checkbox2 _Toggler($Checkbox2, $Hotbut2, "_Function2") Case $Checkbox3 _Toggler($Checkbox3, $Hotbut3, "_Function3") Case $Checkbox4 _Toggler($Checkbox4, $Hotbut4, "_Function4") Case $Checkbox5 _Toggler($Checkbox5, $Hotbut5, "_Function5") Case $Checkbox6 _Toggler($Checkbox6, $Hotbut6, "_Function6") Case $Checkbox7 _Toggler($Checkbox7, $Hotbut7, "_Function7") Case $Checkbox8 _Toggler($Checkbox8, $Hotbut8, "_Function8") EndSwitch WEnd EndFunc Func _ShowAboutGUI() GUICtrlSetState($GUI_MENU_BUTTON, $GUI_HIDE) GUICtrlSetState($GUI_BACK_BUTTON, $GUI_SHOW) For $i = $begin to $end GUICtrlSetState($i, $GUI_HIDE) Next GUICtrlSetData($titlelabel, "ExcelTools - About") GUICtrlSetState($aboutlabel, $GUI_SHOW) $GUI = "Help" EndFunc Func _ShowContactGUI() GUICtrlSetState($GUI_MENU_BUTTON, $GUI_HIDE) GUICtrlSetState($GUI_BACK_BUTTON, $GUI_SHOW) For $i = $begin to $end GUICtrlSetState($i, $GUI_HIDE) Next GUICtrlSetData($titlelabel, "ExcelTools - Contact") GUICtrlSetState($contactlabel, $GUI_SHOW) GUICtrlSetState($contactbut, $GUI_SHOW) $GUI = "Help" EndFunc Func _ShowHomeGUI() GUICtrlSetState($GUI_MENU_BUTTON, $GUI_SHOW) GUICtrlSetState($GUI_BACK_BUTTON, $GUI_HIDE) For $i = 15 to $begin-2 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $begin to $end GUICtrlSetState($i, $GUI_SHOW) Next GUICtrlSetData($titlelabel, "ExcelTools") $GUI = "Home" EndFunc Func _ShowHelpGUI() GUICtrlSetState($GUI_MENU_BUTTON, $GUI_HIDE) GUICtrlSetState($GUI_BACK_BUTTON, $GUI_SHOW) For $i = $begin to $end GUICtrlSetState($i, $GUI_HIDE) Next GUICtrlSetData($titlelabel, "ExcelTools - Help") GUICtrlSetState($Edit, $GUI_SHOW) $GUI = "Help" EndFunc Func _GUICtrlCreateInput($text, $left, $top, $width, $height, $style="") ;GUICtrlCreateLabel($text, $left-180, $top-2, 150, 20) ;GUICtrlSetColor(-1, $txtcolor) ;GUICtrlSetFont(-1, 11, 400, -1, "Segoe UI") $ret=GUICtrlCreateInput("", $left, $top, $width, $height, $style) GUICtrlSetFont(-1, 10) GUICtrlSetBkColor(-1, $darkcolor) GUICtrlSetColor(-1, $txtcolor) GUICtrlSetState(-1, $GUI_DISABLE) Return $ret EndFunc Func _Toggler($control1, $control2, $func) If not _Metro_ToggleIsChecked($control1) Then _Metro_ToggleCheck($control1) GUICtrlSetBkColor($control2, $ivygreen) GUICtrlSetColor($control2, $txtcolor) GUICtrlSetState($control2, $GUI_FOCUS+$GUI_ENABLE) $good = False Do $on = GUICtrlRead($control2) Sleep(100) $in = GUICtrlRead($control2) If $on <> $in Then If $in = "" or StringLen($in) > 1 Then _ErrorMsg("Incorrect input. You may enter 1 character only.") ElseIf _DoubleKey($in) Then _ErrorMsg("That hotkey is already in use.") Else $good = True EndIf EndIf Until $good GUICtrlSetState($control2, $GUI_DISABLE) GUICtrlSetBkColor($control2, $txtcolor) HotKeySet($in, $func) Else _Metro_ToggleUnCheck($control1) _RemoveKey(GUICtrlRead($control2)) GUICtrlSetData($control2, "") GUICtrlSetState($control2, $GUI_DISABLE) GUICtrlSetBkColor($control2, $darkcolor) EndIf EndFunc Func _DoubleKey($key) If StringInStr($keys, $code&$key) Then $ret = True Else $keys &= $code&$key $ret = False EndIf Return $ret EndFunc Func _RemoveKey($key) $keys = StringReplace($keys, $code&$key, "") HotKeySet($key) EndFunc Func _Function1() Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] $inp = GUICtrlRead($Input1) If $inp = "$ANYTHING$" Then $inp = $lines[$i] If $inp = "$LASTWORD$" Then $a = StringSplit($lines[$i], " ", 1) if not @error Then $inp = " "&$a[$a[0]] Else $inp = "" EndIf EndIf If $inp = "$FIRSTWORD$" Then $a = StringSplit($lines[$i], " ", 1) if not @error Then $inp = $a[1]&" " Else $inp = "" EndIf EndIf If $new = "" Then $new = StringReplace($lines[$i], $inp, GUICtrlRead($Input2)) Else $new &= @CRLF&StringReplace($lines[$i], $inp, GUICtrlRead($Input2)) EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function8() Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] If $new = "" Then $new = StringRegExpReplace($lines[$i], GUICtrlRead($Input12), GUICtrlRead($Input13)) Else $new &= @CRLF&StringRegExpReplace($lines[$i], GUICtrlRead($Input12), GUICtrlRead($Input13)) EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function2() Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] If $new = "" Then $new = StringUpper($lines[$i]) Else $new &= @CRLF&StringUpper($lines[$i]) EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function3() Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] If $new = "" Then $new = StringLower($lines[$i]) Else $new &= @CRLF&StringLower($lines[$i]) EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function4() Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] $1 = StringSplit($lines[$i], GUICtrlRead($Input7), 1) If $1[0] > 1 Then $2 = StringSplit($1[2], GUICtrlRead($Input8), 1) If not @error Then $rep = $2[1] Else $rep = "" EndIf EndIf If $new = "" Then $new = StringReplace($lines[$i], $rep, GUICtrlRead($Input9)) Else $new &= @CRLF&StringReplace($lines[$i], $rep, GUICtrlRead($Input9)) EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function5() $val = GUICtrlRead($Input10) Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] If $new = "" Then $new = $lines[$i]&$val Else $new &= @CRLF&$lines[$i]&$val EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function6() $val = GUICtrlRead($Input11) Send("^c") Sleep($delay) $dat = ClipGet() $lines = StringSplit($dat, @CRLF, 1) $new = "" If $lines[0] = 2 Then If $lines[2] = "" Then $lines[0] = 1 EndIf For $i = 1 to $lines[0] If $new = "" Then $new = $val&$lines[$i] Else $new &= @CRLF&$val&$lines[$i] EndIf Next ClipPut($new) Sleep($delay) Send("^v") EndFunc Func _Function7() Send('!hhm{RIGHT}{TAB}{TAB}{TAB}{TAB}'&$color[0]&'{TAB}'&$color[1]&'{TAB}'&$color[2]&'{ENTER}') ;mark with specific color EndFunc Func _Send($txt, $n) For $i = 1 to $n Send($txt) Next EndFunc Func _ErrorMsg($message) _Metro_MsgBox(0, "ExcelTools", $message, 400, 11, $Form1) EndFunc Func _GUICtrlCreateLabel_ColorBorder($s_text, $i_left, $i_top, $i_width = -1, $i_height = -1, $i_style = -1, $i_exstyle = -1) GUICtrlCreateLabel("", $i_left - 1, $i_top - 1, $i_width + 2, $i_height + 2) GUICtrlSetBkColor(-1, 0x00000) Return GUICtrlCreateLabel($s_text, $i_left, $i_top, $i_width, $i_height, $i_style, $i_exstyle) EndFunc Func _Show() GUISetState(@SW_SHOW, $Form1) EndFunc