;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; AutoIt Version: 3.1.1.0 ;; ;; ;; ;; Template AutoIt script. ;; ;; ;; ;; AUTHOR: TheSaint ;; ;; ;; ;; SCRIPT FUNCTION: Set default AutoIt template in ShellNew folder or modify a script ;; ;; ;; ;; THANKS: Ebenezer & Smoke_N from the AutoIt Forum for solving Button_11 issues, ;; ;; especially Smoke_N for the _IsPressed & _IsPressedMouseButton functions ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.5 Prototype #include #Include Global $IsPressed_Primary _IsPressedMouseButton($IsPressed_Primary) Opt("MouseCoordMode", 2) Dim $Button_1, $Button_2, $Button_ap, $Button_b1, $Button_cnt, $Button_i, $Button_S, $Button_sd Dim $Button_ud, $Button_V, $Button_vc, $Button_x, $Checkbox_bk, $Checkbox_cn Dim $Combo_au, $Combo_em, $Combo_v, $Group_1, $Group_2, $Group_3, $Group_3b Dim $Input_11, $Input_a1, $Input_e1, $Input_fs, $Input_rn, $Input_sc, $Input_v1, $Input_v2 Dim $Label_a1, $Label_au, $Label_e1, $Label_rn, $Label_v1, $Label_v2 Dim $Radio_1, $Radio_2, $Radio_ra, $Radio_rn, $Updown_rn, $Updown_11 ; Dim $ans, $auth, $authors, $begin, $bkup, $blank, $blnk3, $blnk7, $blnk9, $Button Dim $cmdln, $cnt, $cntx, $def, $defined, $Dialog, $diff, $email, $end, $frame, $height Dim $i, $icofle, $icoB, $icoC, $icoI, $icoX, $inifle, $lena, $lend, $lene Dim $line, $line3, $line5, $line7, $line9, $lne3a, $lne7a, $lne9a, $lngcmd, $long Dim $new, $num, $prog, $rdfle, $rem, $rgky, $shell, $suc, $te, $tmpcmd, $tmpfl, $tmpfle Dim $tmpl1, $tmpl2, $tplate, $typ, $user, $vers, $versions, $width, $xtra ;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 $inifle = @ScriptDir & "\Template.ini" $tplate = "C:\WINDOWS\SHELLNEW\Template.au3" $Dialog = $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS $width = 450 $height = 480 GuiCreate("Script Templates v2.2", $width, $height, _ (@DesktopWidth-$width)/2, (@DesktopHeight-$height-30)/2 , $Dialog + $WS_MINIMIZEBOX) ; CONTROLS $Group_1 = GuiCtrlCreateGroup("Default Script Template", 20, 20, 270, 150) $Radio_1 = GUICtrlCreateRadio("", 40, 60, 20, 20) GUICtrlSetTip($Radio_1, "Select Template 1 settings!") $Button_1 = GuiCtrlCreateButton("", 60, 50, 135, 40) GUICtrlSetFont($Button_1, 10, 600) GUICtrlSetTip($Button_1, "Set as the default template!") $Label_v1 = GUICtrlCreateLabel('"Version"', 215, 50, 55, 20, $SS_CENTER) $Input_v1 = GUICtrlCreateInput("", 215, 70, 55, 20, $ES_CENTER) ;;;;;; $Radio_2 = GUICtrlCreateRadio("", 40, 120, 20, 20) GUICtrlSetTip($Radio_2, "Select Template 2 settings!") $Button_2 = GuiCtrlCreateButton("", 60, 110, 135, 40) GUICtrlSetFont($Button_2, 10, 600) GUICtrlSetTip($Button_2, "Set as the default template!") $Label_v2 = GUICtrlCreateLabel('"Version"', 215, 110, 55, 20, $SS_CENTER) $Input_v2 = GUICtrlCreateInput("", 215, 130, 55, 20, $ES_CENTER) ; $Group_2 = GuiCtrlCreateGroup("Default Template Details", 20, 180, 410, 80) $Label_a1 = GUICtrlCreateLabel('"Author"', 40, 200, 110, 20, $SS_CENTER) $Input_a1 = GUICtrlCreateInput("", 40, 220, 110, 20) GUICtrlSetTip($Input_a1, "Author of currently selected template!") $Label_e1 = GUICtrlCreateLabel('"Email"', 160, 200, 200, 20, $SS_CENTER) $Input_e1 = GUICtrlCreateInput("", 160, 220, 200, 20) GUICtrlSetTip($Input_e1, "Email address of currently selected template!") $Button_S = GuiCtrlCreateButton("Save", 370, 200, 40, 40, $BS_ICON) GUICtrlSetImage($Button_S, "moricons.dll", 64, 1) GUICtrlSetFont($Button_S, 8, 600) GUICtrlSetTip($Button_S, "Save settings for currently selected template!") ; $Group_3 = GuiCtrlCreateGroup("Modify Currently Selected Script", 20, 270, 410, 175) $Input_sc = GUICtrlCreateInput("", 40, 290, 340, 20) GUICtrlSetTip($Input_sc, "Path of currently selected script file!") $Button_b1 = GuiCtrlCreateButton("", 390, 290, 20, 20, $BS_ICON) GUICtrlSetTip($Button_b1, "Browse for script file!") ;;;; $Combo_v = GUICtrlCreateCombo("", 40, 320, 70, 100) GUICtrlSetTip($Combo_v, "AutoIt Versions!") $Combo_au = GUICtrlCreateCombo("", 120, 320, 90, 100) GUICtrlSetTip($Combo_au, "Script Author!") $Combo_em = GUICtrlCreateCombo("", 220, 320, 190, 100) GUICtrlSetTip($Combo_em, "Author's Email address!") ;;;; $Input_fs = GUICtrlCreateInput("", 40, 350, 305, 20) GUICtrlSetTip($Input_fs, "Script Function / Summary!") $Button_cnt = GuiCtrlCreateButton("Count", 350, 350, 20, 20, $BS_ICON) GUICtrlSetTip($Button_cnt, "Number Of Definition Characters!") $Button_i2 = GuiCtrlCreateButton("Info", 385, 350, 25, 20, $BS_ICON) GUICtrlSetTip($Button_i2, "Script Values!") ; $Group_3b = GuiCtrlCreateGroup("Replace Lines at Top", 40, 380, 205, 50) $Radio_ra = GUICtrlCreateRadio("ALL", 60, 400, 40, 20) GUICtrlSetTip($Radio_ra, "Replace ALL lines in a script!") $Radio_rn = GUICtrlCreateRadio("", 115, 400, 18, 20) GUICtrlSetTip($Radio_rn, "Replace a specified number of lines at top of script!") $Input_rn = GUICtrlCreateInput("0", 133, 400, 36, 20, $ES_NUMBER) GUICtrlSetTip($Input_rn, "Specific number of top lines to replace!") $Updown_rn = GUICtrlCreateUpdown($Input_rn) GUICtrlSetLimit($Updown_rn, 99, 0) GUICtrlSetTip($Updown_rn, "Adjust the specified number!") $Label_rn = GUICtrlCreateLabel("lines", 173, 403, 40, 20) $Button_ud = GUICtrlCreateButton("", 200, 400, 25, 20) GUICtrlSetTip($Button_ud, "Use or Save a default number!") ;;;; $Button_vc = GUICtrlCreateButton("View", 265, 385, 60, 45) GUICtrlSetFont($Button_vc, 8, 600) GUICtrlSetTip($Button_vc, "View the currently selected script file!") $Button_ap = GUICtrlCreateButton("Apply", 345, 385, 65, 45) GUICtrlSetFont($Button_ap, 8, 600) GUICtrlSetTip($Button_ap, "Apply details to the currently selected script!") ; $Button_V = GuiCtrlCreateButton("View", 310, 25, 120, 75) GUICtrlSetFont($Button_V, 10, 600) GUICtrlSetTip($Button_V, "View the currently set default template!") ; $Button_i = GuiCtrlCreateButton("Info", 310, 120, 50, 50, $BS_ICON) GUICtrlSetTip($Button_i, "Program Information!") $Button_x = GuiCtrlCreateButton("EXIT", 380, 120, 50, 50, $BS_ICON) GUICtrlSetTip($Button_x, "Close the program!") ; $Checkbox_cn = GUICtrlCreateCheckbox("Context menu entry", 30, $height-28, 110, 20) GUICtrlSetTip($Checkbox_cn, "Enable / Disable a Windows context menu entry!") ; $Label_au = GuiCtrlCreateLabel("© TheSaint (May 2006)", _ $width/2 - (140 / 2), $height-25, 140, 17, $SS_SUNKEN + $SS_CENTER + $SS_NOPREFIX) GUICtrlSetColor($Label_au, 0xffffff) ; White GUICtrlSetBkColor($Label_au, 0x000000) ; Black GUICtrlSetTip($Label_au, "Program Author!") ; $Checkbox_bk = GUICtrlCreateCheckbox("Backup script files", 315, $height-28, 110, 20) GUICtrlSetTip($Checkbox_bk, "Enable / Disable a Windows context menu entry!") ; SETTINGS $shell = @SystemDir & "\shell32.dll" $user = "User.exe" $icoX = 6 $icoI = 4 $icoC = 0 If StringLeft(@OSVersion, 5) = "WIN_9" Then $icofle = $user $icoB = 78 ElseIf @OSVersion = "WIN_ME" Then $icofle = $user $icoB = 81 Else ; WIN_NT4, WIN_2000, WIN_XP, WIN_2003 $user = "User32.dll" $icofle = $shell $icoB = 84 $icoX = 27 EndIf GUICtrlSetImage($Button_b1, $shell, $icoB, 0) GUICtrlSetImage($Button_cnt, "calc.exe", $icoC, 0) GUICtrlSetImage($Button_i, $user, $icoI, 1) GUICtrlSetImage($Button_i2, $user, $icoI, 0) GUICtrlSetImage($Button_x, $icofle, $icoX, 1) ; $te = IniRead($inifle, "Last Default", "template", "") If $te = "" Or $te = 1 Then GUICtrlSetState($Radio_1, $GUI_CHECKED) ElseIf $te = 2 Then GUICtrlSetState($Radio_2, $GUI_CHECKED) EndIf ; $auth = IniRead($inifle, "Template 1", "author", "") If $auth = "" Then $auth = "Template 1" IniWrite($inifle, "Template 1", "author", $auth) EndIf GUICtrlSetData($Button_1, $auth) $email = IniRead($inifle, "Template 1", "email", "") If $email = "" Then $email = "" IniWrite($inifle, "Template 1", "email", $email) EndIf If $te = "" Or $te = 1 Then GUICtrlSetData($Input_a1, $auth) GUICtrlSetData($Input_e1, $email) EndIf ; $authors = $auth $emails = $email ; $auth = IniRead($inifle, "Template 2", "author", "") If $auth = "" Then $auth = "Template 2" IniWrite($inifle, "Template 2", "author", $auth) EndIf GUICtrlSetData($Button_2, $auth) $email = IniRead($inifle, "Template 2", "email", "") If $email = "" Then $email = "" IniWrite($inifle, "Template 2", "email", $email) EndIf If $te = 2 Then GUICtrlSetData($Input_a1, $auth) GUICtrlSetData($Input_e1, $email) EndIf ; $vers = IniRead($inifle, "Template 1", "version", "") If $vers = "" Then $vers = "3.1.0" IniWrite($inifle, "Template 1", "version", $vers) EndIf GUICtrlSetData($Input_v1, $vers) ; $versions = $vers ; $vers = IniRead($inifle, "Template 2", "version", "") If $vers = "" Then $vers = "3.1.0" IniWrite($inifle, "Template 2", "version", $vers) EndIf GUICtrlSetData($Input_v2, $vers) ; $versions = $versions & "|" & $vers GUICtrlSetData($Combo_v, $versions, $vers) ; If $CmdLine[0] <> 0 Then $cmdln = $CmdLine[1] $typ = FileGetAttrib($cmdln) If StringInStr($typ, "D") Then ErrorMsg() Else $lngcmd = FileGetLongName($cmdln) GUICtrlSetData($Input_sc, $lngcmd) EndIf Else GUICtrlSetState($Button_ap, $GUI_DISABLE) GUICtrlSetState($Button_vc, $GUI_DISABLE) EndIf ; GUICtrlSetState($Radio_rn, $GUI_CHECKED) ; $authors = $authors & "|" & $auth GUICtrlSetData($Combo_au, $authors, $auth) $emails = $emails & "|" & $email GUICtrlSetData($Combo_em, $emails, $email) ; $num = IniRead($inifle, "Line Count", "default", "") If $num = "" Then $num = "11" IniWrite($inifle, "Line Count", "default", $num) EndIf GUICtrlSetData($Button_ud, $num) ; $bkup = IniRead($inifle, "Script Files", "backup", "") If $bkup = "" Then $bkup = 1 IniWrite($inifle, "Script Files", "backup", $bkup) EndIf GUICtrlSetState($Checkbox_bk, $bkup) ; $cntx = IniRead($inifle, "Windows Context", "menu", "") If $cntx = "" Then $cntx = 4 IniWrite($inifle, "Windows Context", "menu", $cntx) EndIf GUICtrlSetState($Checkbox_cn, $cntx) ; VARIABLES $frame = ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" $blank = ";; ;;" $lne3a = ";; AutoIt Version: " $blnk3 = 67 $line5 = ";; Template AutoIt script. ;;" $lne7a = ";; AUTHOR: " $blnk7 = 74 $lne9a = ";; SCRIPT FUNCTION: " $blnk9 = 65 GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_x ; Close program GUIDelete() ExitLoop Case $msg = $Button_vc ; View Currently Selected Script If FileExists($lngcmd) Then Run(@WindowsDir & "\Notepad.exe " & $lngcmd, "", @SW_MAXIMIZE) Case $msg = $Button_V ; View Current Template If FileExists($tplate) Then Run(@WindowsDir & "\Notepad.exe " & $tplate, "", @SW_MAXIMIZE) Case $msg = $Button_S ; Save If GUICtrlRead($Radio_1) = $GUI_CHECKED Then $te = 1 $Button = $Button_1 Else $te = 2 $Button = $Button_2 EndIf $auth = GUICtrlRead($Input_a1) IniWrite($inifle, "Template " & $te, "author", $auth) GUICtrlSetData($Button, $auth) $email = GUICtrlRead($Input_e1) IniWrite($inifle, "Template " & $te, "email", $email) If $te = 1 Then $vers = GUICtrlRead($Input_v1) ElseIf $te = 2 Then $vers = GUICtrlRead($Input_v2) EndIf IniWrite($inifle, "Template " & $te, "version", $vers) ; UpdtScrDialogValues() Case $msg = $Button_i2 ; Script Values $ans = MsgBox(65, "Script Author Values", _ "Selecting an 'Author' updates both 'Email' & 'Version', but" & @LF & _ "they can both still be changed independently anyway!" & @LF & @LF & _ "If the definition is > 65 characters, you will be notified," & @LF & _ "as more than one definition line is not yet supported!" & @LF & @LF & _ "BE CAREFUL using the 'ALL' option, as the script file gets" & @LF & _ "completely wiped! However if you use the backup option," & @LF & _ "a copy of the script with '.bkup' as extension is created!" & @LF & @LF & _ "Click 'OK' to copy to the clipboard the current version of" & @LF & _ "AutoIt - " & @AutoItVersion & " (is running this program)!") If $ans = 1 Then ClipPut(@AutoItVersion) Case $msg = $Button_i ; Program Information MsgBox(0, "Program Info", _ "This program has 2 main purposes -" & @LF & @LF & _ "Set a default AutoIt script template for the ShellNew folder." & @LF & _ "Before setting a default template, you need to have entered" & @LF & _ "and then saved the details, for that template. Use the 'View'" & @LF & _ "button to look at the currently set default template." & @LF & @LF & _ @TAB & @TAB & " &/or" & @LF & @LF & _ "Modify a selected script, by -" & @LF & _ "1) Selecting a script file (browse or right-click)." & @LF & _ "2) Selecting the Author & Email you want to insert." & @LF & _ "3) Entering a definition/summary of the main script function." & @LF & _ "4) Selecting the number of lines at the top of the script, that" & @LF & _ "you wish to replace (if any). You can use the number button" & @LF & _ "to enter a saved default line count. Clicking on the number" & @LF & _ "button for more than 1.5 seconds, means you can save the" & @LF & _ "currently entered number as the new default!" & @LF & _ "5) Clicking on the 'Apply' button, to make the changes!" & @LF & _ "6) Using the 'View' button, if you wish to check the changes" & @LF & _ "or just to copy & paste some of the originals before step 5!" & @LF & @LF & _ "REMEMBER: this program replaces lines only, it does not do" & @LF & _ "any importing from scripts or templates - so be careful. It" & @LF & _ "also only supports lines after these lines, not (yet) before!" & @LF & @LF & _ "Thanks to Smoke_N, Ebenezer & others at the AutoIt forum," & @LF & _ "for assistance with the number button function!") Case $msg = $Button_cnt ; COUNT NUMBER OF DEFINITION CHARACTERS $defined = GUICtrlRead($Input_fs) $lend = StringLen($defined) $xtra = $lend - $blnk9 If $xtra > 0 Then $long = " which is " & $xtra & " too long!" Else $long = " which is Ok!" EndIf MsgBox(0, "Definition Character Count", _ "Needs to be 65 characters or less, and" & @LF & _ "is currently " & $lend & $long) Case $msg = $Button_b1 ; BROWSE FOR A SCRIPT FILE If $lngcmd = "" Then If $tmpcmd = "" Then $tmpcmd = IniRead($inifle, "Script File", "path", "") If $tmpcmd = "" Then $tmpcmd = @MyDocumentsDir Else If $tmpcmd = "" Then $tmpcmd = $lngcmd EndIf $tmpcmd = FileOpenDialog("Browse for Script File", $tmpcmd, "AutoIt Script file (*.au3)", 11, "") If @error <> 1 And $tmpcmd <> "" Then If FileExists($tmpcmd) <> 1 Then If StringRight($tmpcmd, 4) <> ".au3" Then $tmpcmd = $tmpcmd & ".au3" $tmpfle = FileOpen($tmpcmd, 2) FileClose($tmpfle) EndIf $lngcmd = $tmpcmd GUICtrlSetData($Input_sc, $lngcmd) IniWrite($inifle, "Script File", "path", $lngcmd) GUICtrlSetState($Button_ap, $GUI_ENABLE) GUICtrlSetState($Button_vc, $GUI_ENABLE) EndIf Case $msg = $Button_ap ; APPLY CHANGES TO CURRENTLY SELECTED SCRIPT FILE If FileExists($lngcmd) Then SplashTextOn("", @CRLF & @CRLF & "Please Wait!", 150, 100, -1, -1, 1) $defined = GUICtrlRead($Input_fs) $lend = StringLen($defined) If $lend > $blnk9 Then $xtra = $lend - $blnk9 MsgBox(16, "Function Of The Script", _ "The definition for your script is " & $xtra & " characters too long!" _ & @LF & @LF & "It is suggested that you either edit it, or shorten it" _ & @LF & "and then manually add any extra text afterwards," _ & @LF & "using the 'View' option!" _ & @LF & @LF & "APPLICATION OF CHANGES HAS BEEN CANCELLED!") Else If $lend = "" Then $ans = MsgBox(262177, "Empty Value", "You have not specified a definition." & @LF & _ "Do you wish to continue?") EndIf If GUICtrlRead($Checkbox_bk) = $GUI_CHECKED And $ans <> 2 Then ; Backup script file $suc = FileCopy($lngcmd, StringReplace($lngcmd, ".au3", ".bkup")) If $suc <> 1 Then $ans = 2 EndIf If GUICtrlRead($Radio_ra) = $GUI_CHECKED And $ans <> 2 Then $tmpfle = FileOpen($lngcmd, 2) If $tmpfle <> -1 Then WriteToScriptFile() FileClose($tmpfle) ElseIf $ans <> 2 Then $tmpfl = $lngcmd & ".tmp" $suc = FileMove($lngcmd, $tmpfl, 1) If $suc = 1 Then $rdfle = FileOpen($tmpfl, 0) If $rdfle <> -1 Then $num = GUICtrlRead($Input_rn) $tmpfle = FileOpen($lngcmd, 2) If $tmpfle <> -1 Then $end = 0 For $i = 1 To $num $line = FileReadLine($rdfle) If $line = -1 Then ExitLoop Next WriteToScriptFile() Do $line = FileReadLine($rdfle) If @error = -1 Then $end = 1 Else FileWriteLine($tmpfle, $line) EndIf Until $end = 1 FileClose($rdfle) FileClose($tmpfle) If FileExists($lngcmd) Then If FileExists($tmpfl) Then FileDelete($tmpfl) EndIf EndIf EndIf EndIf Else MsgBox(262160, "No Changes Made", "Process cancelled or backup already exists?") EndIf $ans = "" EndIf Sleep(1000) SplashOff() EndIf Case $msg = $Button_2 ; Template 2 $te = 2 $tmpfle = FileOpen($tplate, 2) $vers = GUICtrlRead($Input_v2) PartOne() PartTwo() PartThree() PartFour(1) FileClose($tmpfle) IniWrite($inifle, "Last Default", "template", $te) GUICtrlSetState($Radio_1, $GUI_UNCHECKED) GUICtrlSetState($Radio_2, $GUI_CHECKED) Case $msg = $Button_1 ; Template 1 $te = 1 $tmpfle = FileOpen($tplate, 2) $vers = GUICtrlRead($Input_v1) PartOne() PartTwo() PartThree() PartFour(1) FileClose($tmpfle) IniWrite($inifle, "Last Default", "template", $te) GUICtrlSetState($Radio_2, $GUI_UNCHECKED) GUICtrlSetState($Radio_1, $GUI_CHECKED) Case $msg = $Checkbox_cn ; Context menu entry If GUICtrlRead($Checkbox_cn) = $GUI_CHECKED Then $cntx = 1 Else $cntx = 4 EndIf IniWrite($inifle, "Windows Context", "menu", $cntx) ContextEntry() Case $msg = $Checkbox_bk ; Backup the selected script file If GUICtrlRead($Checkbox_bk) = $GUI_CHECKED Then $bkup = 1 Else $bkup = 4 EndIf IniWrite($inifle, "Script Files", "backup", $bkup) Case $msg = $Combo_au ; Select Author If GUICtrlRead($Combo_au) = IniRead($inifle, "Template 2", "author", "") Then GUICtrlSetData($Combo_em, IniRead($inifle, "Template 2", "email", "")) GUICtrlSetData($Combo_v, IniRead($inifle, "Template 2", "version", "")) ElseIf GUICtrlRead($Combo_au) = IniRead($inifle, "Template 1", "author", "") Then GUICtrlSetData($Combo_em, IniRead($inifle, "Template 1", "email", "")) GUICtrlSetData($Combo_v, IniRead($inifle, "Template 1", "version", "")) EndIf Case $msg = $Radio_rn GUICtrlSetData($Group_3b, "Replace Lines at Top") Case $msg = $Radio_ra GUICtrlSetData($Group_3b, "Replace All Entries") Case $msg = $Radio_2 ; Template 2 $auth = IniRead($inifle, "Template 2", "author", "") GUICtrlSetData($Input_a1, $auth) $email = IniRead($inifle, "Template 2", "email", "") GUICtrlSetData($Input_e1, $email) Case $msg = $Radio_1 ; Template 1 $auth = IniRead($inifle, "Template 1", "author", "") GUICtrlSetData($Input_a1, $auth) $email = IniRead($inifle, "Template 1", "email", "") GUICtrlSetData($Input_e1, $email) Case Else ;;; EndSelect ; ; This code provided by Smoke_N & Ebenezer - modified by me If _IsPressed($IsPressed_Primary) Then $vCoordinates = ControlGetPos("Script Templates v2.2", "", $Button_ud) $vMouse = MouseGetPos() $begin = TimerInit() If $vMouse[0] >= $vCoordinates[0] AND $vMouse[0] <= ($vCoordinates[0]+$vCoordinates[2]) AND $vMouse[1] >= $vCoordinates[1] _ AND $vMouse[1] <= ($vCoordinates[1]+$vCoordinates[3]) Then While _IsPressed($IsPressed_Primary) Sleep(10) $diff = TimerDiff($begin) If $diff > 1500 Then ; more than 1.5 seconds $new =GUICtrlRead($Input_rn) IniWrite($inifle, "Line Count", "default", $new) GUICtrlSetData($Button_ud, $new) EndIf WEnd If $diff < 1500 Then ; less than 1.5 seconds $num = IniRead($inifle, "Line Count", "default", "") GUICtrlSetData($Input_rn, $num) EndIf GUICtrlSetState($Radio_ra, $GUI_UNCHECKED) GUICtrlSetState($Radio_rn, $GUI_CHECKED) EndIf EndIf ; end of provision WEnd Exit #endregion --- GuiBuilder generated code End --- Func PartOne() FileWriteLine($tmpfle, $frame) FileWriteLine($tmpfle, $blank) $lenv = StringLen($vers) $rem = $blnk3 - $lenv $line3 = $lne3a & $vers & _StringRepeat(" ", $rem) & " ;;" FileWriteLine($tmpfle, $line3) FileWriteLine($tmpfle, $blank) FileWriteLine($tmpfle, $line5) FileWriteLine($tmpfle, $blank) EndFunc Func PartTwo() $auth = IniRead($inifle, "Template " & $te, "author", "") GUICtrlSetData($Input_a1, $auth) $email = IniRead($inifle, "Template " & $te, "email", "") GUICtrlSetData($Input_e1, $email) EndFunc Func PartThree() $lena = StringLen($auth) $lene = StringLen($email) $len = $lena + 1 + $lene $rem = $blnk7 - $len $line7 = $lne7a & $auth & " " & $email & _StringRepeat(" ", $rem) & " ;;" FileWriteLine($tmpfle, $line7) EndFunc Func PartFour($new) FileWriteLine($tmpfle, $blank) If $new = 1 Then $line9 = $lne9a & _StringRepeat(" ", $blnk9) & " ;;" Else $rem = $blnk9 - $lend $line9 = $lne9a & $defined & _StringRepeat(" ", $rem) & " ;;" EndIf FileWriteLine($tmpfle, $line9) FileWriteLine($tmpfle, $blank) FileWriteLine($tmpfle, $frame) EndFunc Func ErrorMsg() MsgBox(16, "Program Error", "You need to right-click on a script file!") EndFunc Func WriteToScriptFile() $vers = GUICtrlRead($Combo_v) PartOne() $auth = GUICtrlRead($Combo_au) $email = GUICtrlRead($Combo_em) PartThree() PartFour(0) EndFunc Func UpdtScrDialogValues() $auth = IniRead($inifle, "Template 1", "author", "") $email = IniRead($inifle, "Template 1", "email", "") $vers = IniRead($inifle, "Template 1", "version", "") $authors = $auth $emails = $email $versions = $vers $auth = IniRead($inifle, "Template 2", "author", "") $email = IniRead($inifle, "Template 2", "email", "") $vers = IniRead($inifle, "Template 2", "version", "") GUICtrlSetData($Combo_au, "") GUICtrlSetData($Combo_em, "") GUICtrlSetData($Combo_v, "") $authors = $authors & "|" & $auth $emails = $emails & "|" & $email $versions = $versions & "|" & $vers GUICtrlSetData($Combo_au, $authors, $auth) GUICtrlSetData($Combo_em, $emails, $email) GUICtrlSetData($Combo_v, $versions, $vers) EndFunc Func ContextEntry() $rgky = "HKEY_CLASSES_ROOT\.au3" $def = RegRead($rgky, "") If $def = "AutoIt3Script" Then $rgky = "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Author" $def = RegRead($rgky, "") If $cntx = 1 Then If $def <> "Author Script" Then RegWrite($rgky, "", "REG_SZ", "Author Script") $rgky = $rgky & "\Command" $prog = '"' & @ScriptDir & "\Script Templates.exe" & '"' & " " &'"' & "%1" & '"' RegWrite($rgky, "", "REG_SZ", $prog) MsgBox(0, "Registry Entry Enabled", _ "You should now have an entry on your context" & @LF & _ "menu for .au3 files, called - 'Author Script'.") EndIf Else If $def = "Author Script" Then RegDelete($rgky) EndIf EndIf EndIf EndFunc Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') ; This function provided by Smoke_N Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc Func _IsPressedMouseButton(ByRef $IsPressed_Primary) ; This function provided by Smoke_N Local $ReadMouseReg = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons") If $ReadMouseReg Then $IsPressed_Primary = "01" Else $IsPressed_Primary = "02" EndIf EndFunc