Dan_555 Posted February 6, 2021 Author Share Posted February 6, 2021 (edited) 😀 i'v extracted the hex view code (from BF visualizer, see my previous post) and made a single function of it. Usage: Put something in the $CreateHexString variable, then call the Function CreateHexDataString(). Parameters are Func CreateHexDataString($startnr=0, $collums=10, $rowsize=10, $countwidth=0, $counttype=0, $asciilow=30, $asciihi=255) $startnr is the starting point of the string. It depends on the $collums, and starts from the 0. if $startnr is greater than the length of the $CreateHexString variable, then empty spaces will be displayed as hex/ascii data. $collumns in/decreases the width (amount of displayed letters per row) $rowsize in/decreases the Height. $countwidth ensures that the counter numbers will be equal in size. $counttype Decimal (0) or Hexadecimal (1) counter numbers. $asciilow, $asciihi determine which chars will be displayed. Ascii chars outside these numbers will be displayed as . in the ascii-view part. The function returns a String, which can be placed in a label, editbox or saved to a file. To display the hex-view without the counter and the text, set the $CreateHexStringDisplay variable to 0 This is the how the example script looks like: Save the following script as CreateHexDataString-include.au3 expandcollapse popup#include-once #include <String.au3> Global $CreateHexString = "" Global $CreateHexStringDisplay = 1 ;~ $CreateHexString="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed et ornare sapien. In felis leo, luctus sit amet ligula sed, fringilla feugiat elit. In interdum vestibulum ligula, sed commodo purus fringilla a." ;~ ConsoleWrite( CreateHexDataString($CreateHexString) & @CRLF) Func CreateHexDataString($startnr = 0, $collums = 10, $rowsize = 10, $countwidth = 0, $counttype = 0, $asciilow = 30, $asciihi = 255) ;$startnr = start number 0-99 ;$countwidth - how many 0 will be displayed for the counter ;$counttype = 0 = decimal, 1= hexa Local $tmpString = "", $tmpbin = "", $tmpchr = "" Local $tmpnr = 0, $y = 0, $z = ($startnr * $collums) Local $strlen = StringLen($CreateHexString) Local $d Local $tmphi = $asciilow If $asciilow > $asciihi Then $asciilow = $asciihi $asciihi = $tmphi EndIf If $asciihi < 0 Or $asciihi > 255 Then $asciihi = 0 If $asciilow < 0 Or $asciilow > 255 Then $asciilow = 0 If $countwidth <= 0 Then $countwidth = StringLen($strlen) For $x = 1 To $collums If $CreateHexStringDisplay = 1 Then ;Show counter If $counttype = 0 Then $tmpString = $tmpString & _StringRepeat("0", $countwidth - StringLen($z)) & $z & ": " Else $tmpString = $tmpString & Hex($z, $countwidth) & ": " EndIf EndIf $tmpbin = "" $tmpchr = "" For $y = 0 To $rowsize - 1 If $z <= $strlen - 1 Then $d = StringMid($CreateHexString, $z + 1, 1) $tmpbin = $tmpbin & StringRight(Hex(Asc($d)), 2) & " " ;Show hex If $CreateHexStringDisplay = 1 Then ;Show Ascii If Asc($d) >= $asciilow And Asc($d) <= $asciihi Then $tmpchr = $tmpchr & $d Else $tmpchr = $tmpchr & "." EndIf EndIf Else $tmpbin = $tmpbin & " " $tmpchr = $tmpchr & " " EndIf $z = $z + 1 Next $tmpString = $tmpString & $tmpbin & " " & $tmpchr & @CRLF Next Return $tmpString EndFunc ;==>CreateHexDataString and here is a simple demo script for the above function (I'v named it CreateHexDataString-Example.au3) expandcollapse popup#include "CreateHexDataString-include.au3" #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #Region ### START Koda GUI section ### Form= Global $CTRL[13] $Form1 = GUICreate("Hex Data View", 512, 400, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU)) Global $Edit1 = GUICtrlCreateEdit("", 2, 2, 417, 370) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 9, 400, 0, "Consolas") $CTRL[00] = GUICtrlCreateButton("+Row", 424, 14, 39, 23) $CTRL[01] = GUICtrlCreateButton("-Row", 467, 14, 39, 23) $CTRL[02] = GUICtrlCreateButton("+Col", 424, 63, 39, 23) $CTRL[03] = GUICtrlCreateButton("-Col", 467, 63, 39, 23) $CTRL[04] = GUICtrlCreateLabel("Row", 426, 41, 79, 17) $CTRL[05] = GUICtrlCreateLabel("Col", 425, 91, 79, 17) $CTRL[06] = GUICtrlCreateSlider(425, 116, 28, 255, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_VERT, $TBS_TOP, $TBS_LEFT, $TBS_TOOLTIPS)) $CTRL[07] = GUICtrlCreateCheckbox("Hex", 470, 116, 80, 18) $CTRL[08] = GUICtrlCreateButton("+W", 470, 145, 39, 20) $CTRL[09] = GUICtrlCreateButton("-W", 470, 165, 39, 20) $CTRL[10] = GUICtrlCreateLabel("Col", 470, 185, 40, 17) $CTRL[11] = GUICtrlCreateCheckbox("All", 470, 210, 80, 18) GuiCtrlSetTip (-1,"Switch between normal and hex-data only view") $CTRL[12] = GUICtrlCreateButton("Load", 470, 250, 39, 20) GUICtrlSetState($CTRL[11], $GUI_CHECKED) GUICtrlSetLimit(-1, (1000 / 10), 0) ; change min/max value For $x = 0 To 12 GUICtrlSetResizing($CTRL[$x], $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $collums = 10, $rows = 10, $startnr = 0, $width = 4 $CreateHexString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed et ornare sapien. In felis leo, luctus sit amet ligula sed, fringilla feugiat elit. In interdum vestibulum ligula, sed commodo purus fringilla a." CWE(CreateHexDataString(0)) UpdateLabels() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $CTRL[0] ;Inc Row nr button $rows = $rows + 1 UpdateLabels() Case $CTRL[1] ;Dec Row nr button $rows = $rows - 1 If $rows < 0 Then $rows = 0 UpdateLabels() Case $CTRL[2] ;Inc Col nr button $collums = $collums + 1 UpdateLabels() Case $CTRL[3] ;Dec Col nr button $collums = $collums - 1 If $collums < 0 Then $collums = 0 UpdateLabels() Case $CTRL[6] ;Slider CWE(CreateHexDataString(GUICtrlRead($CTRL[6]), $rows, $collums, $width, _IsChecked($CTRL[7]))) Case $CTRL[7] ;Checkbox UpdateLabels() Case $CTRL[8] ;Width + $width = $width + 1 UpdateLabels() Case $CTRL[9] ;Width - $width = $width - 1 If $width < 0 Then $width = 0 UpdateLabels() Case $CTRL[11] $CreateHexStringDisplay = _IsChecked($CTRL[11]) CWE(CreateHexDataString(GUICtrlRead($CTRL[6]), $rows, $collums, $width, _IsChecked($CTRL[7]))) Case $CTRL[12] Local $sFilePath = FileOpenDialog("Select a file", @ScriptDir & "\", "All Files(*.*)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) If $hFileOpen > 0 Then $CreateHexString = BinaryToString(FileRead($hFileOpen)) FileClose($hFileOpen) CWE(CreateHexDataString(GUICtrlRead($CTRL[6]), $rows, $collums, $width, _IsChecked($CTRL[7]))) EndIf EndSwitch WEnd Func UpdateLabels() GUICtrlSetData($CTRL[4], $rows) GUICtrlSetData($CTRL[5], $collums) GUICtrlSetData($CTRL[10], $width) CWE(CreateHexDataString(GUICtrlRead($CTRL[6]), $rows, $collums, $width, _IsChecked($CTRL[7]))) ;$ctrl[6] = Slider EndFunc ;==>UpdateLabels Func CWE($txt) ;Write text to the edit box GUICtrlSetData($Edit1, $txt) EndFunc ;==>CWE Func _IsChecked($idControlID) ;Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED ;Returns true or false (oneliner) ;The lines below convert true and false to numbers - 1 and 0 Local $x = BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED If $x = True Then Return 1 Return 0 EndFunc ;==>_IsChecked Edited February 6, 2021 by Dan_555 bugfix + Update Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted February 8, 2021 Author Share Posted February 8, 2021 (edited) Hi, here is an alternative to the MsgBox. It displays a Gui with one edit field to the left, and variable number of Buttons to the right. The buttons are defined by text and are separated by |. Button numbers start from 1. To make 2 buttons, yes and no use "yes|no". Yes will have the number 1, and no the number 2 returned by the function. The height of the gui is dependant on the number of buttons. The width of the buttons can be raised by the width of the Gui. expandcollapse popup#include <String.au3> #include <Array.au3> #include <GUIConstants.au3> ;Demo $txt = "Do you want to do this ?" & @CRLF & "or that?" & @CRLF & "click on the " & @CRLF & "Button(s) !" ConsoleWrite(MsgBoxButton("TestBox", $txt) & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", "Do you want to do this or that, then click on one of the buttons" & _StringRepeat(@crlf,30) & "Button(s) !", "Si") & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "Yes|No") & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "Hey|It's|me") & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "Row|Row|Row|Your|Boat") & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "1|2|3|4|5|6") & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "Very long text |is not|adjusted|to|the|window|width") & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "Top|left|corner| |Space is accepted as a button",400,400,0,0) & @CRLF) ConsoleWrite(MsgBoxButton("TestBox", $txt, "One|Two||Four|Five|Six|Seven|One missing button?!",320,50,-1,-1,8) & @CRLF) local $tmptxt="" for $x=1 to 33 $tmptxt=$tmptxt & $x & "|" Next ConsoleWrite(MsgBoxButton("TestBox", $txt, $tmptxt,400,50,0,0,Random(1,33,1)) & @CRLF) ;/demo Func MsgBoxButton($title = "MsgBox", $txt = "", $buttons = "Ok|Cancel", $width = 250, $height = 100, $xpos = -1, $ypos = -1, $defbtn = 1) ;By Dan_555 ;Displays a custom message box with variable number of buttons ;$title = Title text, $txt=info text ;$buttons = Add any number of buttons needed by entering their names. Buttons are separated by | E.g. 'yes|no' will create two buttons. Button numbers start from 1 ;$Width, $height minimum of 250,100. Height is expanded by the amount of buttons. ;Button width is dependant on the Gui-Width ;$defbtn sets a button to act as default button - Acted upon return Local $hParentGui=WinGetHandle("","") GUISetState(@SW_DISABLE,$hParentGui) Local $nMsg Local $btnnr = -1 If StringLeft($buttons, 1) <> "|" Then $buttons = "|" & $buttons If StringRight($buttons, 1) <> "|" Then $buttons = $buttons & "|" Local $a_btn = _StringBetween($buttons, "|", "|") If @error = 0 Then For $x = UBound($a_btn) - 1 To 0 Step -1 If $a_btn[$x] = "" Then _ArrayDelete($a_btn, $x) Next Else ;Error creating button array Local $a_btn[] = ["ok"] EndIf If $height < (UBound($a_btn)) * 20 Then $height = (UBound($a_btn)) * 20 If $width < 250 Then $width = 250 If $height < 100 Then $height = 100 Local $ahBtn[UBound($a_btn)] Local $hMsgBoxGui = GUICreate($title, $width, $height, $xpos, $ypos, BitOR($WS_DLGFRAME, $WS_BORDER, $WS_VISIBLE), BitOR($WS_EX_TOPMOST, $WS_EX_APPWINDOW),$hParentGui) Local $hMsgBoxEdi = GUICtrlCreateEdit($txt, 0, 0, 195, $height, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) ;Local $hMsgBoxEdi = GUICtrlCreateEdit($txt, 0, 0, 195, $height, BitOR($WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) ;Local $hMsgBoxEdi = GUICtrlCreateLabel($txt, 2, 2, 195, $height-4,$SS_SUNKEN) Local $xs = $height - (20 * (UBound($a_btn) - 1)) - 20 For $x = 0 To UBound($a_btn) - 1 $deftyp = -1 If $defbtn = $x + 1 Then $deftyp = $BS_DEFPUSHBUTTON $ahBtn[$x] = GUICtrlCreateButton($a_btn[$x], 198, $xs + ($x * 20), $width - 199, 20, $deftyp) ;~ $ahBtn[$x] = GUICtrlCreateButton($a_btn[$x], 198, (UBound($a_btn)-1 = 0) ? (($height/2)-10)+($x * 20) : (($height/UBound($a_btn))-20)+($x * 20) , $width-199, 20,$deftyp) Next GUISetState(@SW_SHOW) Do $nMsg = GUIGetMsg() If $nMsg > 0 Then For $x = 0 To UBound($ahBtn) - 1 If $nMsg = $ahBtn[$x] Then $btnnr = $x + 1 Next EndIf Until $btnnr > -1 GUIDelete($hMsgBoxGui) GUISetState(@SW_ENABLE,$hParentGui) WinActivate ($hParentGui) Return $btnnr EndFunc ;==>MsgBoxButton Have Fun ! Edited February 8, 2021 by Dan_555 Added lock for the parent gui + bugfix, Set wordwrap to the edit field . Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted February 13, 2021 Author Share Posted February 13, 2021 (edited) Hi, i'm using the CrimsonEditor as my default text editor. It can start user added tools, but it is missing the ability to start the edited thing over it's extension. And so, i got the idea to write the following script: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ShellExec-StopIt.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <TrayConstants.au3> Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1) If StringLen($cmdlineraw) > 0 Then $cmdmenu = _StringSearchSplit($cmdlineraw, "\", "R", "R") $a1 = TrayCreateItem("Running Process:") $a2 = TrayCreateItem($cmdmenu) $menu = TrayCreateItem("Stop it !") TrayItemSetState($a1, $TRAY_DISABLE) TrayItemSetState($a2, $TRAY_DISABLE) $pid = ShellExecute($cmdlineraw) Sleep(1300) While ProcessExists($pid) $tMsg = TrayGetMsg() If $tMsg = $menu Then ProcessClose($pid) WEnd EndIf Func _StringSearchSplit($str, $delimiter, $dir = "L", $ret = "R", $incdel = -1) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringSearchSplit ; Description ...: Search for the first delimiter in a string, with searching direction, Case Sensitive search ; Syntax ........: _StringSearchSplit( $String, $delimiter [, $dir ] [, $ret ] [, $incdel ]) ; Parameters ....: $String - String to be checked. ; $delimiter - 1 char delimiter, has to be defined ; $dir - Search from direction (Left/Right), use "L" or "R" - Left is default ; The first letter will be used for direction, if multiple letters are entered e.g "Lab" = "L" ; $ret - Return side, Left or Right - Right is default. see above for valid entries. ; $incdel - Include delimiter 0 = No, 1 = Yes ; ; Return values .: Success - String ; ; e.g. 1: _StringSearch("c:\bat\test.bb","\","L","L") returns "c:" ; e.g. 2: _StringSearch("c:\bat\test.bb","\","L","L",1) returns "c:\" ; e.g. 3: _StringSearch("c:\bat\test.bb","\","L","R") returns "bat\test.bb" ; e.g. 4: _StringSearch("c:\bat\test.bb","\","L","R",1) returns "\bat\test.bb" ; e.g. 5: _StringSearch("c:\bat\test.bb","\","R","R") returns "test.bb" ; e.g. 6: _StringSearch("c:\bat\test.bb","\","R","R",1) returns "\test.bb" ; ; Failure - Empty string and @error flag as follows: ; @error : 1 - Empty String ; 2 - Delimiter should have a length of 1 char ; 3 - Should not happen, but if it does, search the PANIC button ! ; Author ........: Dan_555 (Autoitscript.com forum) ; =============================================================================================================================== Local $y Local $tmptxt = "" $dir = StringLeft(StringUpper($dir), 1) $ret = StringLeft(StringUpper($ret), 1) SetError(0) If StringLen($str) = 0 Then SetError(1) ;empty string Return "" EndIf If (StringInStr($str, $delimiter) = 0) Or (StringLen($delimiter) <> 1) Then SetError(2) ;invalid delimiter Return "" EndIf If $dir <> "L" And $dir <> "R" Then $dir = "L" ;Set default values If $ret <> "L" And $ret <> "R" Then $ret = "R" If $dir = "L" Then $y = StringInStr($str, $delimiter, 1) ;Search for the delimiter If $dir = "R" Then $y = StringInStr($str, $delimiter, 1, -1) If $incdel = 0 Then $incdel = -1 ;Tricky calculations ;) If $incdel <> -1 Then $incdel = 0 If $ret = "L" Then Return StringMid($str, 1, $y + $incdel) ;DisAssemble the string If $ret = "R" Then Return StringMid($str, $y - $incdel) SetError(3) Return "" EndFunc ;==>_StringSearchSplit It takes, whatever is passed as the parameter and executes is with the shellexec command. Practical example: you can edit html files with the CE, and launch it, automatically, with the assigned browser. (or any other files like au3, nx, bas ... ) The Script then waits in the tray menue, until the launched program is ended. Or, if the Program becomes stuck, you can click on the tray icon, and end it's process. Here are the steps to add this to the CrimsonEditor: Launch CE, Choose Tools/ Conf. user tools. Select an empty user tool slot. Enter a menu text, something like "Shell Exec" Seek the compiled exe for the command by clicking on the ... Add $(FilePath) as Argument. Click on Save before execute. Then save the Tool. From now on, you can edit and launch (e.g. provided launching au3 files runs the script and not the editor) the edited files over the tools menue or over the assigned shortcut. Edit: Here is an updated version of the code. This version does check if the script is running, by setting the filename as a Mutex string. (_Singleton). Therefore if a code is already running, you won't have two icons in the tray. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ShellExec-StopIt.ico #AutoIt3Wrapper_Compression=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <TrayConstants.au3> #include <Misc.au3> Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1) If StringLen($cmdlineraw) > 0 Then $cmdmenu = _StringSearchSplit($cmdlineraw, "\", "R", "R") If _Singleton($cmdmenu,0) > 0 Then $a1 = TrayCreateItem("Running Process:") $a2 = TrayCreateItem($cmdmenu) $menu = TrayCreateItem("Stop it !") TrayCreateItem("") $exit = TrayCreateItem("End this app") TrayItemSetState($a1, $TRAY_DISABLE) TrayItemSetState($a2, $TRAY_DISABLE) $pid = ShellExecute($cmdlineraw) Sleep(1300) While ProcessExists($pid) $tMsg = TrayGetMsg() If $tMsg = $menu Then ProcessClose($pid) If $tMsg = $exit Then Exit WEnd EndIf EndIf Func _StringSearchSplit($str, $delimiter, $dir = "L", $ret = "R", $incdel = -1) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringSearchSplit ; Description ...: Search for the first delimiter in a string, with searching direction, Case Sensitive search ; Syntax ........: _StringSearchSplit( $String, $delimiter [, $dir ] [, $ret ] [, $incdel ]) ; Parameters ....: $String - String to be checked. ; $delimiter - 1 char delimiter, has to be defined ; $dir - Search from direction (Left/Right), use "L" or "R" - Left is default ; The first letter will be used for direction, if multiple letters are entered e.g "Lab" = "L" ; $ret - Return side, Left or Right - Right is default. see above for valid entries. ; $incdel - Include delimiter 0 = No, 1 = Yes ; ; Return values .: Success - String ; ; e.g. 1: _StringSearch("c:\bat\test.bb","\","L","L") returns "c:" ; e.g. 2: _StringSearch("c:\bat\test.bb","\","L","L",1) returns "c:\" ; e.g. 3: _StringSearch("c:\bat\test.bb","\","L","R") returns "bat\test.bb" ; e.g. 4: _StringSearch("c:\bat\test.bb","\","L","R",1) returns "\bat\test.bb" ; e.g. 5: _StringSearch("c:\bat\test.bb","\","R","R") returns "test.bb" ; e.g. 6: _StringSearch("c:\bat\test.bb","\","R","R",1) returns "\test.bb" ; ; Failure - Empty string and @error flag as follows: ; @error : 1 - Empty String ; 2 - Delimiter should have a length of 1 char ; 3 - Should not happen, but if it does, search the PANIC button ! ; Author ........: Dan_555 (Autoitscript.com forum) ; =============================================================================================================================== Local $y Local $tmptxt = "" $dir = StringLeft(StringUpper($dir), 1) $ret = StringLeft(StringUpper($ret), 1) SetError(0) If StringLen($str) = 0 Then SetError(1) ;empty string Return "" EndIf If (StringInStr($str, $delimiter) = 0) Or (StringLen($delimiter) <> 1) Then SetError(2) ;invalid delimiter Return "" EndIf If $dir <> "L" And $dir <> "R" Then $dir = "L" ;Set default values If $ret <> "L" And $ret <> "R" Then $ret = "R" If $dir = "L" Then $y = StringInStr($str, $delimiter, 1) ;Search for the delimiter If $dir = "R" Then $y = StringInStr($str, $delimiter, 1, -1) If $incdel = 0 Then $incdel = -1 ;Tricky calculations ;) If $incdel <> -1 Then $incdel = 0 If $ret = "L" Then Return StringMid($str, 1, $y + $incdel) ;DisAssemble the string If $ret = "R" Then Return StringMid($str, $y - $incdel) SetError(3) Return "" EndFunc ;==>_StringSearchSplit ShellExec-StopIt.ico Edited July 13, 2021 by Dan_555 Added a new/alternate version of the script. Some of my script sourcecode Link to comment Share on other sites More sharing options...
marcgforce Posted June 26, 2021 Share Posted June 26, 2021 dan_555 in you game auto o gram, it should be grate to make a color cycle to change the color of the square (if its grey to black and if its black, to grey, right click should be X ) Link to comment Share on other sites More sharing options...
Dan_555 Posted June 27, 2021 Author Share Posted June 27, 2021 Done. Have fun ! Some of my script sourcecode Link to comment Share on other sites More sharing options...
marcgforce Posted July 4, 2021 Share Posted July 4, 2021 easy peasy 😄 Link to comment Share on other sites More sharing options...
Dan_555 Posted July 30, 2021 Author Share Posted July 30, 2021 (edited) Hi, this is my Note-Memo-Pad script written in Autoit 3: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=NoteMemoPad.ico #AutoIt3Wrapper_Outfile=NoteMemoPad.exe #AutoIt3Wrapper_Outfile_x64=NoteMemoPad_x64.exe #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <Misc.au3> If _Singleton("Memo-Note-Pad00") = 0 Then Exit Global $a_Font, $a_Fontc Dim $a_Font[8] ;Font array definition Dim $a_Fontc[8] Global $f_Italic, $f_Strikethru, $f_Underline Global $f_inifile Opt("TrayMenuMode", 11) TraySetClick(16) Global $closecounter = 0, $TimeHandle = TimerInit(), $TimeDiff = TimerDiff($TimeHandle) Global $formTitle = "Note-memo-pad" Global $inifile = @ScriptDir & "\" & "NoteMemoPad.ini" $f_inifile = $inifile Global $a_BTN[10][9] Global $btnnr = -1 ;Tray menu definition Global $idMenu = TrayCreateMenu("Options") Global $idHideOnSave = TrayCreateItem("Hide on autosave", $idMenu, -1, 1) Global $idSTARTUP = TrayCreateItem("Start Hidden", $idMenu, -1, 1) Global $idBUP = TrayCreateItem("Create Back-Up", $idMenu, -1, 1) Global $idOTYP = TrayCreateItem("Tray single click open/Close", $idMenu, -1, 1) Global $idWW = TrayCreateItem("WordWrap", $idMenu, -1, 1) TrayCreateItem("", $idMenu) Global $idPos = TrayCreateItem("Reset Position", $idMenu) Global $idRPos = TrayCreateItem("Remember Position", $idMenu) TrayCreateItem("", $idMenu) Global $idFont = TrayCreateItem("Set Font", $idMenu) Global $idSave = TrayCreateItem("SaveNow") TrayCreateItem("") Global $idExit = TrayCreateItem("Exit") Local $tmpx, $tmpy $tmpx = IniRead($inifile, "OPTIONS", "POSX", "-1") $tmpy = IniRead($inifile, "OPTIONS", "POSY", "-1") Global $HideOnAutoSave = IniRead($inifile, "OPTIONS", "HideOnAutoSave", "0") If $HideOnAutoSave = 0 Then TrayItemSetState($idHideOnSave, $Tray_Unchecked) Else TrayItemSetState($idHideOnSave, $Tray_checked) EndIf Global $SingleClickOpen = IniRead($inifile, "OPTIONS", "TrayClickSingleOpen", "0") If $SingleClickOpen = 0 Then TrayItemSetState($idOTYP, $Tray_Unchecked) $TRAYCLICK = $TRAY_EVENT_PRIMARYDOUBLE Else TrayItemSetState($idOTYP, $Tray_checked) $TRAYCLICK = $TRAY_EVENT_PRIMARYUP EndIf Global $DoBackup = IniRead($inifile, "OPTIONS", "EnableBackup", "1") If $DoBackup = 0 Then TrayItemSetState($idBUP, $Tray_Unchecked) Else TrayItemSetState($idBUP, $Tray_checked) EndIf Global $WordWrap = IniRead($inifile, "OPTIONS", "Wordwrap", "0") If $WordWrap = 0 Then TrayItemSetState($idWW, $Tray_Unchecked) $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Else TrayItemSetState($idWW, $Tray_checked) $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) EndIf Global $StartHidden = IniRead($inifile, "OPTIONS", "StartHide", "1") If $StartHidden = 0 Then TrayItemSetState($idSTARTUP, $Tray_Unchecked) Else TrayItemSetState($idSTARTUP, $Tray_checked) EndIf Global $GUIVISIBLE = 1 #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate($formTitle, 680, 450, $tmpx, $tmpy, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) $Button1 = GUICtrlCreateButton("Add Button", 508, 2, 82, 19) GUICtrlSetTip(-1, "Add a Copy to Clipboard Button") GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $Button2 = GUICtrlCreateButton("Add Counter", 508, 25, 82, 19) GUICtrlSetTip(-1, "Add counter type buttons") GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $Button3 = GUICtrlCreateButton("Selection", 625, 25, 51, 19) GUICtrlSetTip(-1, "Invert Selection") GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $Button4 = GUICtrlCreateButton("Delete", 625, 2, 51, 19) GUICtrlSetTip(-1, "Delete Selected items") GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) Global $Edit1 = GUICtrlCreateEdit("", 2, 2, 500, 444, $ww) GUICtrlSetData(-1, "") GUICtrlSetResizing(-1, $GUI_DOCKTOP) ;GUICtrlSetFont($Edit1, 8, 0, 0, "JSE_AmigaAMOS", 0) _GUICtrlEdit_SetLimitText($Edit1, 20000000) GetIniFont($Edit1) #EndRegion ### END Koda GUI section ### ReadFromFile() _GUICtrlEdit_SetSel($Edit1, -1, -1) If $StartHidden = 0 Then GUISetState(@SW_SHOW) $GUIVISIBLE = 1 Else GUISetState(@SW_HIDE) $GUIVISIBLE = 0 EndIf CreateButtons() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Global $AutoSaveTimer = TimerInit() Global $AutoSave = 0 While 1 Switch TrayGetMsg() Case $idSave SaveToFile() Case $idExit If $GUIVISIBLE = 1 And _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() Exit Case $idHideOnSave $HideOnAutoSave = $HideOnAutoSave + 1 If $HideOnAutoSave > 1 Then $HideOnAutoSave = 0 If $HideOnAutoSave = 0 Then TrayItemSetState($idHideOnSave, $Tray_Unchecked) Else TrayItemSetState($idHideOnSave, $Tray_checked) EndIf IniWrite($inifile, "OPTIONS", "HideOnAutoSave", $HideOnAutoSave) Case $idSTARTUP $StartHidden = $StartHidden + 1 If $StartHidden > 1 Then $StartHidden = 0 If $StartHidden = 0 Then TrayItemSetState($idSTARTUP, $Tray_Unchecked) Else TrayItemSetState($idSTARTUP, $Tray_checked) EndIf $StartHidden = IniWrite($inifile, "OPTIONS", "StartHide", $StartHidden) Case $idWW $WordWrap = $WordWrap + 1 If $WordWrap > 1 Then $WordWrap = 0 If $WordWrap = 0 Then TrayItemSetState($idWW, $Tray_Unchecked) $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Else TrayItemSetState($idWW, $Tray_checked) $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) EndIf IniWrite($inifile, "OPTIONS", "Wordwrap", $WordWrap) $tmp = GUICtrlRead($Edit1) GUICtrlDelete($Edit1) $Edit1 = GUICtrlCreateEdit("", 2, 2, 500, 444, $ww) _GUICtrlEdit_SetLimitText($Edit1, 20000000) GetIniFont($Edit1) GUICtrlSetData($Edit1, $tmp) $tmp = "" Case $idBUP $DoBackup = $DoBackup + 1 If $DoBackup > 1 Then $DoBackup = 0 If $DoBackup = 0 Then TrayItemSetState($idBUP, $Tray_Unchecked) Else TrayItemSetState($idBUP, $Tray_checked) EndIf IniWrite($inifile, "OPTIONS", "EnableBackup", $DoBackup) Case $idOTYP $SingleClickOpen = $SingleClickOpen + 1 If $SingleClickOpen > 1 Then $SingleClickOpen = 0 If $SingleClickOpen = 0 Then TrayItemSetState($idOTYP, $Tray_Unchecked) $TRAYCLICK = $TRAY_EVENT_PRIMARYDOUBLE Else TrayItemSetState($idOTYP, $Tray_checked) $TRAYCLICK = $TRAY_EVENT_PRIMARYUP EndIf IniWrite($inifile, "OPTIONS", "TrayClickSingleOpen", $SingleClickOpen) Case $idFont SetFont($Edit1, $Form1) Case $idRPos Local $aTmp = WinGetPos($Form1) IniWrite($inifile, "OPTIONS", "POSX", $aTmp[0]) IniWrite($inifile, "OPTIONS", "POSY", $aTmp[1]) $aTmp = "" Case $idPos IniWrite($inifile, "OPTIONS", "POSX", "-1") IniWrite($inifile, "OPTIONS", "POSY", "-1") WinMove($Form1, "", 0, 0) WinActivate($Form1) Case $TRAYCLICK If _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() If $GUIVISIBLE = 0 Then GUISetState(@SW_SHOW, $Form1) $GUIVISIBLE = 1 Tray_Items(1) Else GUISetState(@SW_HIDE, $Form1) $GUIVISIBLE = 0 Tray_Items(2) EndIf EndSwitch $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() GUISetState(@SW_HIDE, $Form1) $GUIVISIBLE = 0 Tray_Items(2) Case $Button1 ;Add Button AddButtons(1) Case $Button2 ;Add Counter AddButtons(2) Case $Button3 ;Invert Selection For $x = 0 To $btnnr $tmp = _IsChecked($a_BTN[$x][3]) If $tmp = 0 Then $tmp1 = 1 Else $tmp1 = 0 EndIf _CheckUncheck($a_BTN[$x][3], $tmp1) Next Case $Button4 ;Delete $tmp1 = 0 For $x = 0 To $btnnr $tmp = _IsChecked($a_BTN[$x][3]) If $tmp = 1 Then IniWrite($inifile, "BUTTON_" & $a_BTN[$x][8], "00", 0) $tmp1 = 1 EndIf Next If $tmp1 = 1 Then CreateButtons() Case Else If $nMsg > 0 Then For $x = 0 To $btnnr If $a_BTN[$x][0] = 1 Then If $nMsg = $a_BTN[$x][4] Then ClipPut($a_BTN[$x][2]) Else $tmp = 0 If $nMsg = $a_BTN[$x][4] Then GUICtrlSetData($a_BTN[$x][5], GUICtrlRead($a_BTN[$x][5]) - 1) $tmp = 1 EndIf If $nMsg = $a_BTN[$x][6] Then GUICtrlSetData($a_BTN[$x][5], GUICtrlRead($a_BTN[$x][5]) + 1) $tmp = 1 EndIf If $tmp = 1 Then IniWrite($inifile, "BUTTON_" & $a_BTN[$x][8], "02", GUICtrlRead($a_BTN[$x][5])) EndIf Next EndIf EndSwitch If TimerDiff($AutoSaveTimer) > 300000 And $AutoSave = 0 And $GUIVISIBLE = 1 Then If _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() $AutoSave = 1 If $HideOnAutoSave = 1 Then GUISetState(@SW_HIDE, $Form1) $GUIVISIBLE = 0 Tray_Items(2) EndIf EndIf EndIf WEnd Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $IdFrom, $iCode $IdFrom = BitAND($wParam, 0x0000FFFF) $iCode = BitShift($wParam, 16) Switch $IdFrom Case $Edit1 Switch $iCode Case $EN_UPDATE $AutoSaveTimer = TimerInit() $AutoSave = 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func Tray_Items($typ) Local $tmp, $tmp1 If $typ = 1 Then $tmp = $TRAY_ENABLE $tmp1 = $TRAY_ENABLE ElseIf $typ = 0 Then $tmp = $TRAY_DISABLE $tmp1 = $TRAY_DISABLE Else $tmp = $TRAY_DISABLE $tmp1 = $TRAY_ENABLE EndIf TrayItemSetState($idWW, $tmp) TrayItemSetState($idPos, $tmp) TrayItemSetState($idRPos, $tmp) TrayItemSetState($idFont, $tmp) TrayItemSetState($idSave, $tmp) TrayItemSetState($idExit, $tmp1) EndFunc ;==>Tray_Items Func AddButtons($typ) If $btnnr < 9 Then Tray_Items(0) $nMsg = GUIGetMsg() Local $InputForm, $Button1, $Button2, $Input1, $Input2, $Label1, $Label2 #Region ### START Koda GUI section ### Form= GUISetState(@SW_DISABLE, $Form1) $InputForm = GUICreate("Button Generator", 237, 135, -1, -1, BitOR($WS_BORDER, $WS_CAPTION), $WS_EX_APPWINDOW, $Form1) $Button1 = GUICtrlCreateButton("Ok", 16, 104, 55, 18, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Cancel", 167, 104, 55, 18) If $typ = 1 Then $Input1 = GUICtrlCreateInput("", 15, 24, 208, 21) $Label1 = GUICtrlCreateLabel("Button Name:", 15, 4, 122, 17) $Input2 = GUICtrlCreateInput("", 15, 74, 208, 21) $Label2 = GUICtrlCreateLabel("Clipboard Text:", 14, 55, 267, 17) GUICtrlSetLimit($Input1, 22) Else $Input1 = GUICtrlCreateInput("", 15, 24, 208, 21) $Label1 = GUICtrlCreateLabel("Descriptional Text:", 15, 4, 122, 17) $Input2 = GUICtrlCreateInput("", 15, 74, 208, 21, $ES_NUMBER) GUICtrlSetLimit($Input1, 28) GUICtrlSetLimit($Input2, 8) $Label2 = GUICtrlCreateLabel("Enter a Number", 14, 55, 267, 17) EndIf GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $Ex = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 If GUICtrlRead($Input1) <> "" And GUICtrlRead($Input2) <> "" Then $Ex = 0 ExitLoop EndIf Case $Button2 $Ex = 1 ExitLoop EndSwitch WEnd If $Ex = 0 Then Local $found = 0 For $x = 0 To 9 $tmp = IniRead($inifile, "BUTTON_" & $x, "00", "-1") If $tmp <= 0 Then IniWrite($inifile, "BUTTON_" & $x, "00", $typ) IniWrite($inifile, "BUTTON_" & $x, "01", GUICtrlRead($Input1)) IniWrite($inifile, "BUTTON_" & $x, "02", GUICtrlRead($Input2)) $found = 1 ExitLoop EndIf Next EndIf GUIDelete($InputForm) GUISetState(@SW_ENABLE, $Form1) WinActivate($Form1) CreateButtons() Tray_Items(1) EndIf EndFunc ;==>AddButtons Func CreateButtons() If $btnnr > -1 Then For $x = 0 To $btnnr $tmp = $a_BTN[$x][0] If $tmp = 1 Then GUICtrlDelete($a_BTN[$x][3]) GUICtrlDelete($a_BTN[$x][4]) ElseIf $tmp = 2 Then GUICtrlDelete($a_BTN[$x][3]) GUICtrlDelete($a_BTN[$x][4]) GUICtrlDelete($a_BTN[$x][5]) GUICtrlDelete($a_BTN[$x][6]) GUICtrlDelete($a_BTN[$x][7]) EndIf Next $btnnr = -1 EndIf For $x = 0 To 9 $tmp = IniRead($inifile, "BUTTON_" & $x, "00", "-1") If $tmp > 0 And $tmp < 9 Then $btnnr = $btnnr + 1 $a_BTN[$btnnr][0] = Int($tmp) $a_BTN[$btnnr][1] = IniRead($inifile, "BUTTON_" & $x, "01", "") $a_BTN[$btnnr][2] = IniRead($inifile, "BUTTON_" & $x, "02", "") $a_BTN[$btnnr][8] = $x EndIf Next For $x = 0 To $btnnr $tmp = $a_BTN[$x][0] If $tmp > 0 Then If $tmp = 1 Then $a_BTN[$x][3] = GUICtrlCreateCheckbox("", 650, 60 + $x * 40, 18, 30) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $a_BTN[$x][4] = GUICtrlCreateButton($a_BTN[$x][1], 510, 60 + $x * 40, 130, 30) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetTip($a_BTN[$x][4], "Click to copy to clipboard") ElseIf $tmp = 2 Then $a_BTN[$x][7] = GUICtrlCreateLabel($a_BTN[$x][1] & ":", 510, 53 + $x * 40, 220, 18) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $a_BTN[$x][3] = GUICtrlCreateCheckbox("", 650, 70 + $x * 40, 18, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $a_BTN[$x][4] = GUICtrlCreateButton("-", 510, 70 + $x * 40, 20, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $a_BTN[$x][5] = GUICtrlCreateInput($a_BTN[$x][2], 540, 70 + $x * 40, 60, 20, BitOR($ES_NUMBER, $ES_READONLY)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) $a_BTN[$x][6] = GUICtrlCreateButton("+", 610, 70 + $x * 40, 20, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) EndIf EndIf Next EndFunc ;==>CreateButtons Func _CheckUncheck($id, $nr) If $nr = 0 Then GUICtrlSetState($id, $GUI_UNCHECKED) Else GUICtrlSetState($id, $GUI_CHECKED) EndIf EndFunc ;==>_CheckUncheck Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func ReadFromFile() If FileExists(@ScriptDir & "\" & "memory.txt") Then Local $hFileOpen = FileOpen(@ScriptDir & "\" & "memory.txt", $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "ReadFromFile", "An error occurred when reading the file." & @CRLF & @ScriptDir & "\" & "memory.txt") Return False EndIf Local $sFileRead = FileRead($hFileOpen) ; Close the handle returned by FileOpen. FileClose($hFileOpen) GUICtrlSetData($Edit1, $sFileRead, 1) EndIf EndFunc ;==>ReadFromFile Func SaveToFile() If $DoBackup = 1 Then If FileExists(@ScriptDir & "\" & "memory.bak") Then FileDelete(@ScriptDir & "\" & "memory.bak") FileCopy(@ScriptDir & "\" & "memory.txt", @ScriptDir & "\" & "memory.bak") EndIf Local $hFileOpen = FileOpen(@ScriptDir & "\" & "memory.txt", $FO_OVERWRITE) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "SaveToFile", "An error occurred whilst writing the temporary file." & @CRLF & @ScriptDir & "\" & "memory.txt") Return False EndIf If FileWrite($hFileOpen, GUICtrlRead($Edit1)) = 0 Then MsgBox($MB_SYSTEMMODAL, "FileWrite", "Failed to write to Memory.txt" & @CRLF & @ScriptDir & "\" & "memory.txt") Return False Else _GUICtrlEdit_SetModify($Edit1, False) EndIf FileClose($hFileOpen) EndFunc ;==>SaveToFile Func SetFont($id, $h_gui, $nr = 0) For $x = 0 To 7 $a_Fontc[$x] = $a_Font[$x] Next $a_Font = _ChooseFont($a_Font[2], $a_Font[3], $a_Font[5], $a_Font[4], $f_Italic, $f_Underline, $f_Strikethru, $h_gui) If $a_Font <> -1 Then ; GUICtrlSetFont ( controlID, size [, weight [, attribute [, fontname [, quality]]]] ) GUICtrlSetFont($id, $a_Font[3], $a_Font[4], $a_Font[1], $a_Font[2], 0) GUICtrlSetColor($id, $a_Font[5]) $f_Italic = BitAND($a_Font[1], 2) $f_Underline = BitAND($a_Font[1], 4) $f_Strikethru = BitAND($a_Font[1], 8) SaveIniFont($nr) ;ConsoleWrite(@CRLF & $a_Font[3] & @CRLF & $a_Font[4] & @CRLF & $a_Font[1] & @CRLF & $a_Font[2] & @CRLF & $a_Font[5]) Else Dim $a_Font[8] ;Font array definition For $x = 0 To 7 $a_Font[$x] = $a_Fontc[$x] Next EndIf EndFunc ;==>SetFont Func GetIniFont($id, $nr = 0) ;Default font definition $a_Font[1] = IniRead($f_inifile, "font", $nr & "1", "0") $a_Font[2] = IniRead($f_inifile, "font", $nr & "2", "Arial") $a_Font[3] = IniRead($f_inifile, "font", $nr & "3", "8") $a_Font[4] = IniRead($f_inifile, "font", $nr & "4", "400") $a_Font[7] = IniRead($f_inifile, "font", $nr & "7", "0") $f_Italic = BitAND($a_Font[1], 2) $f_Underline = BitAND($a_Font[1], 4) $f_Strikethru = BitAND($a_Font[1], 8) GUICtrlSetFont($id, $a_Font[3], $a_Font[4], $a_Font[1], $a_Font[2], 0) GUICtrlSetColor($id, $a_Font[7]) EndFunc ;==>GetIniFont Func SaveIniFont($nr = 0) IniWrite($f_inifile, "font", $nr & "1", $a_Font[1]) IniWrite($f_inifile, "font", $nr & "2", $a_Font[2]) IniWrite($f_inifile, "font", $nr & "3", $a_Font[3]) IniWrite($f_inifile, "font", $nr & "4", $a_Font[4]) IniWrite($f_inifile, "font", $nr & "7", $a_Font[7]) EndFunc ;==>SaveIniFont Func CW($txt) ConsoleWrite($txt & @CRLF) EndFunc ;==>CW It is meant to stay in the Tray menue, so the script will exit only if you choose the Exit from its icon. (Only single instance can run at a time) It has an editor field, its content is saved when the app is hidden (if there was a change in the editor - if the modify flag is set). The text is saved as "memory.txt" in the script folder. The ini file is named "NoteMemoPad.ini" and will be created in the script folder. It has some additional buttons (max 10): You can add a button, which will copy a predefined text into clipboard. You can add a counter. Click on + or - to change it. The counter and the button are saved in the ini file. When you delete a button, its contents are not deleted - The slot is only marked as unused. (In case you deleted it by a mistake) This is how it looks like: The options for this tool are located in the tray menu, and they are saved in the ini file. Some options can be changed only when the Editor Window is visible. Options are: Hide on Autosave: An autosave will be done, if something is typed in the editor field, after 5 minutes. You can let the window be hidden then. Start Hidden: Do not open the window at the first start. Make backup : (Create a backup of the last saved file as memory.bak before saving) Tray Single Click open/close : Open the window with 1 or 2 clicks on the tray menu. WordWrap: Set or Reset the wordwrap mode for the editor. Reset position: Reset the window starting position to center of the screen. (Using this option will set the window to the top left edge, but it will open centered by the next start) Remember Position: Position the window where you like it to be, and it will always open there (if you do not move it). Set Font: Change the used font. Attached is an icon file. Have fun. NoteMemoPad.ico Edited March 18, 2023 by Dan_555 Update: 18.03.2023 - Bug Fix - Word Wrapped Editbox now allows enter key to be used. Loc 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted January 20, 2023 Author Share Posted January 20, 2023 (edited) Hi, here is a version 2 of my Note-Memo-Pad script. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=NoteMemoPad.ico #AutoIt3Wrapper_Outfile=NoteMemoPad.exe #AutoIt3Wrapper_Outfile_x64=NoteMemoPad_x64.exe #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #pragma compile(inputboxres, true) #include <Misc.au3> If @Compiled = 1 Then If _Singleton("Memo-Note-Pad00") = 0 Then Exit EndIf #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <String.au3> #include <WinAPI.au3> #include <GUIListBox.au3> Global $MouseVolume Global $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "LRESULT", "int;wparam;lparam") $hMod = _WinAPI_GetModuleHandle(0) Global $g_hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod) Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global Const $VK_TAB = 0x09 Global Const $VK_CAPSLOCK = 0x14 Global Const $VK_SPACE = 0x20 Global Const $VK_LWIN = 0x5B Global Const $VK_RWIN = 0x5C Global $isWinDown1 = False Global $isWinDown2 = False Global $isWinDown1T = TimerInit(), $isWinDown2T = TimerInit() $hHookProc = DllCallbackRegister("_KeyboardProc", "long", "int;wparam;lparam") $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hHookProc), _WinAPI_GetModuleHandle(0), 0) Global $t1, $t2, $t3 Global $a_Font, $a_Fontc Dim $a_Font[8] ;Font array definition Dim $a_Fontc[8] Global $f_Italic, $f_Strikethru, $f_Underline Global $f_inifile Global $CloseProcess, $tools, $cpc = 10, $toc = 10 ;$cpc = CloseProcces, $toc = Tools menu items count Global $TedX = 0, $TedMaxCount = 0, $TedFile = @ScriptDir, $TedMem1 = "-1", $TedMem2 = "-1" , $TedType Dim $CloseProcess[$cpc][2] Dim $tools[$toc][2] Local $trayMSG Local $xt, $yt, $zt ;temporary variables ResetTrayToolItems($CloseProcess, $cpc) ResetTrayToolItems($tools, $toc) Opt("GUIResizeMode", $GUI_DOCKAUTO) Opt("TrayMenuMode", 11) TraySetClick(16) Global $closecounter = 0, $TimeHandle = TimerInit(), $TimeDiff = TimerDiff($TimeHandle) Global $formTitle = "Note-memo-pad" Global $inifile = @ScriptDir & "\" & "NoteMemoPad.ini" $f_inifile = $inifile Global $vRollCount = 0, $tmpcounter = 0 ;Tray menu definition ;~ Global $idPopOutOnTop = TrayCreateItem("Set PopoutYoutube on Top") ;~ Global $idPopOutOffTop = TrayCreateItem("Set PopoutYoutube off Top") ;~ TrayCreateItem("") Global $idCloseMenu = TrayCreateMenu("Close") IniToTrayMenu($CloseProcess, "CLOSEPROCESS", $idCloseMenu, $cpc) Global $idMenuTools = TrayCreateMenu("Tools") IniToTrayMenu($tools, "TOOLS", $idMenuTools, $toc) TrayCreateItem("") Global $idMenu = TrayCreateMenu("Options") Global $idDisableLWINSPACE = TrayCreateItem("Disable LWIN Space", $idMenu, -1, 1) Global $idDisableCaps = TrayCreateItem("Disable CapsLock", $idMenu, -1, 1) Global $idDisableAltTab = TrayCreateItem("Disable Alt Tab", $idMenu, -1, 1) Global $idMouseVolume = TrayCreateItem("Mouse Buttons (4/5) to Volume", $idMenu, -1, 1) Global $idHideOnSave = TrayCreateItem("Hide on autosave", $idMenu, -1, 1) Global $idSTARTUP = TrayCreateItem("Start Hidden", $idMenu, -1, 1) Global $idBUP = TrayCreateItem("Create Back-Up", $idMenu, -1, 1) Global $idOTYP = TrayCreateItem("Tray single click open/Close", $idMenu, -1, 1) Global $idWW = TrayCreateItem("WordWrap", $idMenu, -1, 1) TrayCreateItem("", $idMenu) Global $idPos0 = TrayCreateItem("Move to 0,0 (does not save)", $idMenu) Global $idPos = TrayCreateItem("Recall Position", $idMenu) TrayCreateItem("-----------------", $idMenu) TrayItemSetState(-1, $TRAY_DISABLE) Global $idRPos = TrayCreateItem("Remember Position", $idMenu) TrayCreateItem("", $idMenu) Global $idFont = TrayCreateItem("Set Font", $idMenu) TrayCreateItem("", $idMenu) Global $idOpenIni = TrayCreateItem("Edit ini", $idMenu) Global $idEDClose = TrayCreateItem("Edit Close Process", $idMenu) Global $idEdTool = TrayCreateItem("Edit Tool", $idMenu) TrayCreateItem("") Global $idScratchbook = TrayCreateItem("Open Scratchbook") Global $idRollCount = TrayCreateItem("Open Counter") Global $idWinOnTop = TrayCreateItem("Open Win-on-Top") TrayCreateItem("") Global $idSave = TrayCreateItem("SaveNow") TrayCreateItem("") Global $idExit = TrayCreateItem("Exit") Local $tmpx, $tmpy $tmpx = IniRead($inifile, "OPTIONS", "POSX", "-1") $tmpy = IniRead($inifile, "OPTIONS", "POSY", "-1") Global $DisableLWINSpace = IniRead($inifile, "OPTIONS", "DisableLWinSPACE", "1") _TrayCheckUncheck($idDisableLWINSPACE, $DisableLWINSpace) Global $DisableCaps = IniRead($inifile, "OPTIONS", "DisableCaps", "1") _TrayCheckUncheck($idDisableCaps, $DisableCaps) Global $DisableAltTab = IniRead($inifile, "OPTIONS", "DisableAltTab", "1") _TrayCheckUncheck($idDisableAltTab, $DisableAltTab) $MouseVolume = IniRead($inifile, "OPTIONS", "MouseVolume", "1") _TrayCheckUncheck($idMouseVolume, $MouseVolume) Global $HideOnAutoSave = IniRead($inifile, "OPTIONS", "HideOnAutoSave", "0") _TrayCheckUncheck($idHideOnSave, $HideOnAutoSave) Global $SingleClickOpen = IniRead($inifile, "OPTIONS", "TrayClickSingleOpen", "0") _TrayCheckUncheck($idOTYP, $SingleClickOpen) If $SingleClickOpen = 0 Then $TRAYCLICK = $TRAY_EVENT_PRIMARYDOUBLE Else $TRAYCLICK = $TRAY_EVENT_PRIMARYUP EndIf Global $DoBackup = IniRead($inifile, "OPTIONS", "EnableBackup", "1") _TrayCheckUncheck($idBUP, $DoBackup) Global $WordWrap = IniRead($inifile, "OPTIONS", "Wordwrap", "0") _TrayCheckUncheck($idWW, $WordWrap) If $WordWrap = 0 Then $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $WS_HSCROLL) Else $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) EndIf Global $StartHidden = IniRead($inifile, "OPTIONS", "StartHide", "1") _TrayCheckUncheck($idSTARTUP, $StartHidden) #Region ### START Koda GUI section ### Form= $ActWin_Form = GUICreate("Window List", 250, 178, -1, -1) Global $AWINList1 = GUICtrlCreateList("", 2, 2, 246, 149) $AWINLButton1 = GUICtrlCreateButton("On", 5, 153, 34, 22) GUICtrlSetTip(-1, "Try to set the selected window on TOP", "On Top") $AWINLButton2 = GUICtrlCreateButton("Off", 40, 153, 34, 22) GUICtrlSetTip(-1, "Remove the topmost attribute", "Off Top") $AWINLButton3 = GUICtrlCreateButton("Move", 75, 153, 44, 22) GUICtrlSetTip(-1, "Move the selected window to 0,0", "Move") $AWINLButton4 = GUICtrlCreateButton("Move Mouse", 120, 153, 70, 22) GUICtrlSetTip(-1, "Move the selected window to Mouse positon" & @CRLF & "in 3 seconds", "Move to mouse") $AWINLButton5 = GUICtrlCreateButton("Refresh", 190, 153, 59, 22) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form= $TEDForm1 = GUICreate("Tools edit", 312, 95, -1, -1) $TEDInputName = GUICtrlCreateInput("", 1, 25, 258, 21) $TEDInputExe = GUICtrlCreateInput("", 2, 72, 309, 21) GUICtrlCreateLabel("Menu Name:", 3, 5, 65, 17) $TEDLabel1 = GUICtrlCreateLabel("Proccess/Tool Name:", 2, 55, 108, 17) $TEDButtonPlus = GUICtrlCreateButton("+", 226, 1, 35, 21) $TEDButtonMimus = GUICtrlCreateButton("-", 124, 1, 35, 21) $TEDLabel = GUICtrlCreateLabel("100/100 ", 168, 2, 54, 17, $SS_CENTER) $TedButtonDel = GUICtrlCreateButton("Clear", 265, 1, 46, 20) $TedButtonCop = GUICtrlCreateButton("Copy", 265, 25, 46, 20) $TedButtonPas = GUICtrlCreateButton("Paste", 265, 50, 46, 20) $TEDButtonSave = GUICtrlCreateButton("Save", 205, 50, 46, 20) $TEDSeek = GUICtrlCreateButton("Seek File", 114, 50, 55, 20) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=Roller Global $CounterForm = GUICreate("Counter", 144, 100, -1, -1, BitOR($WS_SYSMENU, $DS_MODALFRAME), $WS_EX_TOPMOST) Global $CounterButtonMinus = GUICtrlCreateButton("-", 4, 5, 30, 25) GUICtrlSetTip(-1, "Decrease counter") Global $CounterButtonPlus = GUICtrlCreateButton("+", 105, 5, 30, 25) GUICtrlSetTip(-1, "Increase counter") Global $CounterInput = GUICtrlCreateInput("0", 37, 7, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) Global $CounterButtonReset = GUICtrlCreateButton("Reset", 4, 50, 132, 19) GUICtrlSetTip($CounterButtonReset, "Memorize/Reset to 0 or to memorized number.") Global $RollLabel = GUICtrlCreateLabel("Last buttom action:", 4, 33, 101, 17) GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### Global $GUIVISIBLE = 1 #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate($formTitle, 680, 450, $tmpx, $tmpy, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) Global $Edit1 = GUICtrlCreateEdit("", 2, 2, 500, 444, $ww) GUICtrlSetData(-1, "") ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ;GUICtrlSetFont($Edit1, 8, 0, 0, "JSE_AmigaAMOS", 0) _GUICtrlEdit_SetLimitText($Edit1, 200000000) GetIniFont($Edit1) Global $RollInputLow = GUICtrlCreateInput("", 510, 272, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetTip(-1, "Lower number (from)") Global $RollInputHi = GUICtrlCreateInput("", 548, 272, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetTip(-1, "Higher number (to)") Global $RollButton = GUICtrlCreateButton("Roll", 583, 272, 42, 21) GUICtrlSetTip(-1, "Roll (from - to)") Global $RollOutput = GUICtrlCreateInput("0", 628, 272, 50, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetTip(-1, "Rolled Number") GUICtrlSetData($RollInputLow, 1) GUICtrlSetData($RollInputHi, 2) Global $ED2CLS = GUICtrlCreateButton("CLS", 510, 297, 30, 18) Global $ED2CHK = GUICtrlCreateCheckbox("Add Roll", 620, 297, 60, 18) GUICtrlSetTip(-1, "Add Rolls to edit box") Global $Edit2 = GUICtrlCreateEdit("", 510, 316, 165, 130) GUICtrlSetData(-1, "") _GUICtrlEdit_SetLimitText($Edit2, 2000000) $MCountName = GUICtrlCreateButton("Counter Name", 510, 215, 167, 20) $MCountMinus = GUICtrlCreateButton("-", 510, 237, 25, 25) $MCountPlus = GUICtrlCreateButton("+", 651, 237, 25, 25) $McountEd = GUICtrlCreateInput("", 540, 239, 106, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) #EndRegion ### END Koda GUI section ### ReadFromFile() GUICtrlSetData($MCountName, IniRead($inifile, "config", "countername", "counter name")) GUICtrlSetData($McountEd, IniRead($inifile, "config", "counternumber", "0")) If $StartHidden = 0 Then GUISetState(@SW_SHOW) $GUIVISIBLE = 1 Else GUISetState(@SW_HIDE) $GUIVISIBLE = 0 EndIf Global $buttons[17][3] $x = 0 For $xy = 0 To 7 For $xx = 0 To 1 $buttons[$x][0] = GUICtrlCreateButton($x, 509 + ($xx * 85), 2 + ($xy * 25), 84, 24) ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $x = $x + 1 Next Next GetButtons() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO") Global $AutoSaveTimer = TimerInit() Global $AutoSave = 0 Global $SCP_closecounter = 0, $SCP_TimeHandle = TimerInit(), $SCP_TimeDiff = TimerDiff($SCP_TimeHandle) Global $SCP_formTitle = "Simple Scratchbook" Global $SCP_Form1, $SCP_Edit1, $SCP_ButtonCLS, $SCP_ButtonCLSPASTE, $SCP_ButtonPaste, $SCP_ButtonCopy, $SCP_ButtonCopyALL Global $SCP_ButtonUndo, $SCP_ButtonFont, $SCP_CheckLock, $SCP_WInOpen = 0, $SCP_WW, $SCP_WWEdSetting, $SCP_hEdit1 $SCP_WWEdSetting = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) Global $vWinOT = 0 Local $LRMB While 1 If TimerDiff($AutoSaveTimer) > 300000 And $AutoSave = 0 And $GUIVISIBLE = 1 Then If _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() $AutoSave = 1 If $HideOnAutoSave = 1 Then GUISetState(@SW_HIDE, $Form1) $GUIVISIBLE = 0 Tray_Items(2) EndIf EndIf EndIf If $isWinDown1 = True And TimerDiff($isWinDown1T) > 5000 Then $isWinDown1 = False If $isWinDown2 = True And TimerDiff($isWinDown2T) > 5000 Then $isWinDown1 = False $trayMSG = TrayGetMsg() Switch $trayMSG Case $idEDClose TrayItemSetState($idEDClose, $TRAY_DISABLE) TrayItemSetState($idEdTool, $TRAY_DISABLE) $inisection = "CLOSEPROCESS" $TedMaxCount = $cpc $TedX = 0 $TedType = 1 WinSetTitle($TEDForm1, "", "Process closing editor") GUICtrlSetData($TEDInputName, IniRead($inifile, $inisection, "00a", "-1")) GUICtrlSetData($TEDInputExe, IniRead($inifile, $inisection, "00b", "-1")) GUICtrlSetData($TEDLabel, $TedX & "/" & ($TedMaxCount - 1)) GUICtrlSetData($TEDLabel1, "Process name (.exe)") GUISetState(@SW_SHOW, $TEDForm1) Case $idEdTool TrayItemSetState($idEDClose, $TRAY_DISABLE) TrayItemSetState($idEdTool, $TRAY_DISABLE) $inisection = "TOOLS" $TedMaxCount = $toc $TedX = 0 $TedType = 2 WinSetTitle($TEDForm1, "", "Tool editor") GUICtrlSetData($TEDInputName, IniRead($inifile, $inisection, "00a", "-1")) GUICtrlSetData($TEDInputExe, IniRead($inifile, $inisection, "00b", "-1")) GUICtrlSetData($TEDLabel, $TedX & "/" & ($TedMaxCount - 1)) GUICtrlSetData($TEDLabel1, "Path + Filename") GUISetState(@SW_SHOW, $TEDForm1) Case $idOpenIni ShellExecute($inifile) Case $idWinOnTop $vWinOT = Mod($vWinOT + 1, 2) _TrayCheckUncheck($idWinOnTop, $vWinOT) If $vWinOT = 0 Then GUISetState(@SW_HIDE, $ActWin_Form) Else GetActiveWindows() GUISetState(@SW_SHOW, $ActWin_Form) EndIf Case $idScratchbook If $SCP_WInOpen = 0 Then Scratchbook() Else CloseScratchbook() EndIf Case $idSave SaveToFile() Case $idExit If $GUIVISIBLE = 1 And _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() If $SCP_WInOpen = 1 Then CloseScratchbook() Cleanup() Case $idRollCount $vRollCount = Mod($vRollCount + 1, 2) _TrayCheckUncheck($idRollCount, $vRollCount) If $vRollCount = 0 Then GUISetState(@SW_HIDE, $CounterForm) Else GUISetState(@SW_SHOW, $CounterForm) EndIf Case $idDisableLWINSPACE $DisableLWINSpace = Mod($DisableLWINSpace + 1, 2) _TrayCheckUncheck($idDisableLWINSPACE, $DisableLWINSpace) IniWrite($inifile, "OPTIONS", "DisableLWinSPACE", $DisableLWINSpace) Case $idDisableCaps $DisableCaps = Mod($DisableCaps + 1, 2) _TrayCheckUncheck($idDisableCaps, $DisableCaps) IniWrite($inifile, "OPTIONS", "DisableCaps", $DisableCaps) Case $idDisableAltTab $DisableAltTab = Mod($DisableAltTab + 1, 2) _TrayCheckUncheck($idDisableAltTab, $DisableAltTab) IniWrite($inifile, "OPTIONS", "DisableAltTab", $DisableAltTab) Case $idMouseVolume $MouseVolume = Mod($MouseVolume + 1, 2) _TrayCheckUncheck($idMouseVolume, $MouseVolume) IniWrite($inifile, "OPTIONS", "MouseVolume", $MouseVolume) Case $idHideOnSave $HideOnAutoSave = Mod($HideOnAutoSave + 1, 2) _TrayCheckUncheck($idHideOnSave, $HideOnAutoSave) IniWrite($inifile, "OPTIONS", "HideOnAutoSave", $HideOnAutoSave) Case $idSTARTUP $StartHidden = Mod($StartHidden + 1, 2) _TrayCheckUncheck($idSTARTUP, $StartHidden) $StartHidden = IniWrite($inifile, "OPTIONS", "StartHide", $StartHidden) Case $idWW $WordWrap = Mod($WordWrap + 1, 2) _TrayCheckUncheck($idWW, $WordWrap) If $WordWrap = 0 Then TrayItemSetState($idWW, $Tray_Unchecked) $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL) Else TrayItemSetState($idWW, $Tray_checked) $ww = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) EndIf IniWrite($inifile, "OPTIONS", "Wordwrap", $WordWrap) $tmp = GUICtrlRead($Edit1) GUICtrlDelete($Edit1) $Edit1 = GUICtrlCreateEdit("", 2, 2, 500, 444, $ww) _GUICtrlEdit_SetLimitText($Edit1, 200000000) GetIniFont($Edit1) GUICtrlSetData($Edit1, $tmp) $tmp = "" Case $idBUP $DoBackup = Mod($DoBackup + 1, 2) _TrayCheckUncheck($idBUP, $DoBackup) IniWrite($inifile, "OPTIONS", "EnableBackup", $DoBackup) Case $idOTYP $SingleClickOpen = Mod($SingleClickOpen + 1, 2) _TrayCheckUncheck($idOTYP, $SingleClickOpen) If $SingleClickOpen = 0 Then $TRAYCLICK = $TRAY_EVENT_PRIMARYDOUBLE Else $TRAYCLICK = $TRAY_EVENT_PRIMARYUP EndIf IniWrite($inifile, "OPTIONS", "TrayClickSingleOpen", $SingleClickOpen) Case $idFont SetFont($Edit1, $Form1) Case $idRPos Local $aTmp = WinGetPos($Form1) IniWrite($inifile, "OPTIONS", "POSX", $aTmp[0]) IniWrite($inifile, "OPTIONS", "POSY", $aTmp[1]) $aTmp = "" Case $idPos0 WinMove($Form1, "", 0, 0) WinActivate($Form1) Case $idPos WinMove($Form1, "", IniRead($inifile, "OPTIONS", "POSX", "-1"), IniRead($inifile, "OPTIONS", "POSY", "-1")) WinActivate($Form1) Case $TRAYCLICK If _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() If $GUIVISIBLE = 0 Then GUISetState(@SW_SHOW, $Form1) $GUIVISIBLE = 1 Tray_Items(1) Else GUISetState(@SW_HIDE, $Form1) $GUIVISIBLE = 0 Tray_Items(2) EndIf Case $trayMSG > 0 For $x = 0 To $cpc - 1 If $trayMSG = $CloseProcess[$x][0] Then KillProcess($CloseProcess[$x][1]) EndIf Next For $x = 0 To $toc - 1 If $trayMSG = $tools[$x][0] Then ShellExecute($tools[$x][1]) EndIf Next EndSwitch $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array If Not IsHWnd($aMsg[1]) Then ContinueLoop ; preventing subsequent lines from processing when nothing happens $nMsg = $aMsg[0] Switch $aMsg[1] Case $TEDForm1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE TrayItemSetState($idEDClose, $TRAY_ENABLE) TrayItemSetState($idEdTool, $TRAY_ENABLE) GUISetState(@SW_HIDE, $TEDForm1) if $TedType =1 Then DeleteTrayToolItems($CloseProcess, $cpc) ;ResetTrayToolItems($CloseProcess, $cpc) IniToTrayMenu($CloseProcess, "CLOSEPROCESS", $idCloseMenu, $cpc) EndIf If $TedType =2 Then DeleteTrayToolItems($tools, $toc) ;ResetTrayToolItems($tools, $toc) IniToTrayMenu($tools, "TOOLS", $idMenuTools, $toc) EndIf Case $TEDButtonPlus If $TedX < $TedMaxCount - 1 Then $TedX = $TedX + 1 GUICtrlSetData($TEDLabel, $TedX & "/" & ($TedMaxCount - 1)) GUICtrlSetData($TEDInputName, IniRead($inifile, $inisection, _StringRepeat("0", 2 - StringLen($TedX)) & $TedX & "a", "-1")) GUICtrlSetData($TEDInputExe, IniRead($inifile, $inisection, _StringRepeat("0", 2 - StringLen($TedX)) & $TedX & "b", "-1")) EndIf Case $TEDButtonMimus If $TedX > 0 Then $TedX = $TedX - 1 GUICtrlSetData($TEDLabel, $TedX & "/" & ($TedMaxCount - 1)) GUICtrlSetData($TEDInputName, IniRead($inifile, $inisection, _StringRepeat("0", 2 - StringLen($TedX)) & $TedX & "a", "-1")) GUICtrlSetData($TEDInputExe, IniRead($inifile, $inisection, _StringRepeat("0", 2 - StringLen($TedX)) & $TedX & "b", "-1")) EndIf Case $TEDSeek ConsoleWrite($TedFile & @CRLF) $TedFile = FileOpenDialog("File selection", $TedFile, "All (*.*)", $FD_FILEMUSTEXIST) if @error = 0 Then GUICtrlSetData ($TEDInputExe, $TedFile) Case $TedButtonDel GUICtrlSetData($TEDInputExe, "-1") GUICtrlSetData($TEDInputName, "-1") Case $TedButtonCop $TedMem1 = GUICtrlRead($TEDInputExe) $TedMem2 = GUICtrlRead($TEDInputName) Case $TedButtonPas GUICtrlSetData($TEDInputExe, $TedMem1) GUICtrlSetData($TEDInputName, $TedMem2) Case $TEDButtonSave $tmp1 = GUICtrlRead($TEDInputName) $tmp2 = GUICtrlRead($TEDInputExe) IniWrite($inifile, $inisection, _StringRepeat("0", 2 - StringLen($TedX)) & $TedX & "a", $tmp1) IniWrite($inifile, $inisection, _StringRepeat("0", 2 - StringLen($TedX)) & $TedX & "b", $tmp2) EndSwitch Case $Form1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE If _GUICtrlEdit_GetModify($Edit1) = True Then SaveToFile() GUISetState(@SW_HIDE, $Form1) $GUIVISIBLE = 0 Tray_Items(2) Case $MCountMinus $ctmp = GUICtrlRead($McountEd) If $ctmp > 0 Then $ctmp = $ctmp - 1 GUICtrlSetData($McountEd, $ctmp) IniWrite($inifile, "config", "counternumber", $ctmp) EndIf Case $MCountPlus $ctmp = GUICtrlRead($McountEd) $ctmp = $ctmp + 1 GUICtrlSetData($McountEd, $ctmp) IniWrite($inifile, "config", "counternumber", $ctmp) Case $MCountName GUISetState(@SW_DISABLE, $Form1) $sInputBoxAnswer = InputBox("Counter name", "Please enter a desired name:", "", " M25", -1, 130) GUICtrlSetData($MCountName, $sInputBoxAnswer) IniWrite($inifile, "config", "countername", $sInputBoxAnswer) GUISetState(@SW_ENABLE, $Form1) WinActivate($Form1, "") Case $ED2CLS GUICtrlSetData($Edit2, "") Case $RollButton $ctmp3 = _IsChecked($ED2CHK) $ctmp1 = GUICtrlRead($RollInputLow) $ctmp2 = GUICtrlRead($RollInputHi) If Int($ctmp1) > Int($ctmp2) Then $ctmp = $ctmp1 $ctmp1 = $ctmp2 $ctmp2 = $ctmp EndIf If $ctmp1 = 0 And $ctmp2 = 0 Then $ctmp1 = 1 $ctmp2 = 100 EndIf $ctmp = Random($ctmp1, $ctmp2, 1) ;ConsoleWrite ("Roll (" & $ctmp1 & "/" & $ctmp2 & "): " & $ctmp & @CRLF) GUICtrlSetData($RollOutput, $ctmp) If $ctmp3 = 1 Then GUICtrlSetData($Edit2, $ctmp & @CRLF, 1) Case Else $LRMB = 0 If $nMsg <> 0 Then If $nMsg = $GUI_EVENT_PRIMARYUP Then $LRMB = 1 ;Left MB If $nMsg = $GUI_EVENT_SECONDARYUP Then $LRMB = 2 ;Right MB If $LRMB > 0 Then $aCInfo = GUIGetCursorInfo($Form1) $nMsg = $aCInfo[4] $aCInfo = "" EndIf ;process buttons For $x = 0 To 16 If $LRMB = 1 And $nMsg = $buttons[$x][0] And $buttons[$x][2] = 1 Then ClipPut($buttons[$x][1]) If $LRMB = 2 And $nMsg = $buttons[$x][0] Then ButtonEdit($x) EndIf Next EndIf EndSwitch Case $SCP_Form1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE CloseScratchbook() Case $SCP_ButtonCLS ControlSetText("", "", $SCP_Edit1, "") Case $SCP_ButtonCLSPASTE ControlSetText("", "", $SCP_Edit1, "") Local $clp = ClipGet() ControlSetText("", "", $SCP_Edit1, $clp) Case $SCP_ButtonPaste ;Local $clp = ClipGet() ControlFocus($SCP_Form1, "", $SCP_Edit1) Send("^v") Case $SCP_ButtonCopy ControlFocus($SCP_Form1, "", $SCP_Edit1) Send("^c") Case $SCP_ButtonCopyALL ClipPut(_GUICtrlEdit_GetText($SCP_Edit1)) Case $SCP_ButtonUndo ;ControlFocus($SCP_Form1,"",$SCP_Edit1) ;Send("^z") _GUICtrlEdit_Undo($SCP_Edit1) Case $SCP_CheckLock $iStyle = _WinAPI_GetWindowLong($SCP_hEdit1, $GWL_STYLE) If _IsChecked($SCP_CheckLock) = 1 Then GUICtrlSetStyle($SCP_Edit1, BitOR($iStyle, $ES_READONLY)) Else GUICtrlSetStyle($SCP_Edit1, BitXOR($iStyle, $ES_READONLY)) EndIf Case $SCP_WW $tmp1 = GUICtrlRead($SCP_Edit1) $aRect = WinGetPos($SCP_Form1) GUICtrlDelete($SCP_Edit1) $tmp = 0 $tmp2 = 0 If _IsChecked($SCP_CheckLock) = 1 Then $tmp = $ES_READONLY If _IsChecked($SCP_WW) = 0 Then $tmp2 = BitOR($SCP_WWEdSetting, $ES_AUTOHSCROLL, $WS_HSCROLL, $tmp) Else $tmp2 = BitOR($SCP_WWEdSetting, $tmp) EndIf $SCP_Edit1 = GUICtrlCreateEdit("", 3, 30, $aRect[2] - 20, $aRect[3] - 73, $tmp2, 0) _GUICtrlEdit_SetLimitText($SCP_Edit1, 200000000) $SCP_hEdit1 = GUICtrlGetHandle(-1) GetIniFont($SCP_Edit1, 1) GUICtrlSetData(-1, $tmp1) ;GUICtrlSetResizing(-1, $GUI_DOCKTOP) $tmp1 = "" $tmp2 = "" $aRect = "" Case $SCP_ButtonFont SetFont($SCP_Edit1, $SCP_Form1, 1) EndSwitch Case $CounterForm Switch $aMsg[0] Case $GUI_EVENT_CLOSE $vRollCount = 0 _TrayCheckUncheck($idRollCount, $vRollCount) GUISetState(@SW_HIDE, $CounterForm) Case $CounterButtonPlus $ctmp = GUICtrlRead($CounterInput) GUICtrlSetData($CounterInput, $ctmp + 1) GUICtrlSetData($RollLabel, "" & @HOUR & ":" & @MIN & ":" & @SEC & " +") Beep(200, 650) Case $CounterButtonMinus $ctmp = GUICtrlRead($CounterInput) If $ctmp > 0 Then GUICtrlSetData($CounterInput, $ctmp - 1) GUICtrlSetData($RollLabel, "" & @HOUR & ":" & @MIN & ":" & @SEC & " -") Beep(200, 650) Case $CounterButtonReset $tmp3 = GUICtrlRead($CounterInput) If $tmp3 <> 0 Then $tmpcounter = $tmp3 $tmp3 = 0 GUICtrlSetData($RollLabel, "" & @HOUR & ":" & @MIN & ":" & @SEC & " Reset") Else $tmp3 = $tmpcounter $tmpcounter = 0 GUICtrlSetData($RollLabel, "" & @HOUR & ":" & @MIN & ":" & @SEC & " Restore") EndIf GUICtrlSetData($CounterInput, $tmp3) EndSwitch Case $ActWin_Form Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $ActWin_Form) $vWinOT = 0 _TrayCheckUncheck($idWinOnTop, $vWinOT) Case $AWINLButton1 $tmp = GUICtrlRead($AWINList1) If $tmp <> "" Then SetOnOffTop($tmp, 1) Case $AWINLButton2 $tmp = GUICtrlRead($AWINList1) If $tmp <> "" Then SetOnOffTop($tmp, 0) Case $AWINLButton3 $tmp = GUICtrlRead($AWINList1) If $tmp <> "" Then WinMove($tmp, "", 0, 0) Case $AWINLButton4 $tmp = GUICtrlRead($AWINList1) If $tmp <> "" Then $tmp = TimerInit() While TimerDiff($tmp) < 3000 GUIGetMsg() ToolTip(Int(3000 - (TimerDiff($tmp))) / 1000, MouseGetPos(0), MouseGetPos(1) - 20) WEnd ToolTip("") $tmp = GUICtrlRead($AWINList1) If $tmp <> "" Then WinMove($tmp, "", MouseGetPos(0), MouseGetPos(1)) EndIf Case $AWINLButton5 GetActiveWindows() EndSwitch EndSwitch WEnd Func ResetTrayToolItems(ByRef $array, $itemcount) For $x = 0 To $itemcount - 1 $array[$x][0] = -1 Next EndFunc ;==>ResetTrayToolItems Func DeleteTrayToolItems(ByRef $array, $itemcount) For $x=0 to $itemcount - 1 if $array[$x][0] <>"-1" Then TrayItemDelete ($array[$x][0]) $array[$x][0]="-1" EndIf Next EndFunc Func IniToTrayMenu(ByRef $array, $inisection, $menuid, $itemcount) $zt = 0 For $x = 0 To $itemcount -1 $xt = IniRead($inifile, $inisection, _StringRepeat("0", 2 - StringLen($x)) & $x & "a", "-1") $yt = IniRead($inifile, $inisection, _StringRepeat("0", 2 - StringLen($x)) & $x & "b", "-1") If $xt <> "-1" And $yt <> "-1" Then $array[$zt][0] = TrayCreateItem($xt, $menuid) $array[$zt][1] = $yt $zt = $zt + 1 EndIf TrayItemSetState($menuid, $TRAY_ENABLE) Next If $zt = 0 Then IniWrite($inifile, $inisection, "00a", "-1") IniWrite($inifile, $inisection, "00b", "-1") TrayItemSetState($menuid, $TRAY_DISABLE) EndIf EndFunc ;==>IniToTrayMenu Func ButtonEdit($nr) If $nr < 0 Or $nr > 15 Then Return 0 TraySetClick(0) $nMsg = GUIGetMsg() Local $InputForm, $Button1, $Button2, $Button3, $Input1, $Input2, $Label1, $Label2 #Region ### START Koda GUI section ### Form= GUISetState(@SW_DISABLE, $Form1) $InputForm = GUICreate("Button Generator", 237, 135, -1, -1, BitOR($WS_BORDER, $WS_CAPTION), $WS_EX_APPWINDOW, $Form1) $Button1 = GUICtrlCreateButton("Ok", 16, 104, 55, 18, $BS_DEFPUSHBUTTON) $Button3 = GUICtrlCreateButton("Delete", 91, 104, 55, 18) $Button2 = GUICtrlCreateButton("Cancel", 167, 104, 55, 18) $Input1 = GUICtrlCreateInput("", 15, 24, 208, 21) $Label1 = GUICtrlCreateLabel("Button Name:", 15, 4, 122, 17) $Input2 = GUICtrlCreateInput("", 15, 74, 208, 21) $Label2 = GUICtrlCreateLabel("Clipboard Text:", 14, 55, 267, 17) GUICtrlSetLimit($Input1, 22) GUICtrlSetData($Input2, $buttons[$nr][1]) GUICtrlSetData($Input1, IniRead($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($x)) & $x & "a", "")) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 If GUICtrlRead($Input1) <> "" And GUICtrlRead($Input2) <> "" Then IniWrite($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($nr)) & $x, "1") IniWrite($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($nr)) & $x & "a", GUICtrlRead($Input1)) IniWrite($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($nr)) & $x & "b", GUICtrlRead($Input2)) ExitLoop EndIf Case $Button2 ExitLoop Case $Button3 IniWrite($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($nr)) & $x, "0") ExitLoop EndSwitch WEnd GUIDelete($InputForm) GUISetState(@SW_ENABLE, $Form1) WinActivate($Form1) GetButtons() TraySetClick(16) EndFunc ;==>ButtonEdit Func GetButtons() Local $x, $xx, $xy, $btnnr, $ok, $tmp $x = 0 For $xy = 0 To 7 For $xx = 0 To 1 $btnnr = $buttons[$x][0] $ok = IniRead($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($x)) & $x, "0") If $ok = 1 Then $tmp = IniRead($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($x)) & $x & "a", "") GUICtrlSetData($btnnr, $tmp) $buttons[$x][1] = IniRead($inifile, "BUTTONS", _StringRepeat("0", 2 - StringLen($x)) & $x & "b", "") GUICtrlSetTip($btnnr, $tmp) $buttons[$x][2] = 1 Else GUICtrlSetData($btnnr, "") $buttons[$x][2] = 0 EndIf $x = $x + 1 Next Next EndFunc ;==>GetButtons Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $IdFrom, $iCode $IdFrom = BitAND($wParam, 0x0000FFFF) $iCode = BitShift($wParam, 16) Switch $IdFrom Case $Edit1 Switch $iCode Case $EN_UPDATE $AutoSaveTimer = TimerInit() $AutoSave = 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func Tray_Items($typ) Local $tmp, $tmp1 If $typ = 1 Then $tmp = $TRAY_ENABLE $tmp1 = $TRAY_ENABLE ElseIf $typ = 0 Then $tmp = $TRAY_DISABLE $tmp1 = $TRAY_DISABLE Else $tmp = $TRAY_DISABLE $tmp1 = $TRAY_ENABLE EndIf TrayItemSetState($idWW, $tmp) TrayItemSetState($idPos, $tmp) TrayItemSetState($idRPos, $tmp) TrayItemSetState($idFont, $tmp) TrayItemSetState($idSave, $tmp) TrayItemSetState($idExit, $tmp1) EndFunc ;==>Tray_Items Func _TrayCheckUncheck($id, $nr) If $nr = 0 Then TrayItemSetState($id, $Tray_Unchecked) Else TrayItemSetState($id, $Tray_checked) EndIf EndFunc ;==>_TrayCheckUncheck Func _CheckUncheck($id, $nr) If $nr = 0 Then GUICtrlSetState($id, $GUI_UNCHECKED) Else GUICtrlSetState($id, $GUI_CHECKED) EndIf EndFunc ;==>_CheckUncheck Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func ReadFromFile() If FileExists(@ScriptDir & "\" & "memory.txt") Then Local $hFileOpen = FileOpen(@ScriptDir & "\" & "memory.txt", $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "ReadFromFile", "An error occurred when reading the file." & @CRLF & @ScriptDir & "\" & "memory.txt") Return False EndIf Local $sFileRead = FileRead($hFileOpen) ; Close the handle returned by FileOpen. FileClose($hFileOpen) GUICtrlSetData($Edit1, $sFileRead) GUICtrlSetState($Edit1, $GUI_FOCUS) EndIf EndFunc ;==>ReadFromFile Func SaveToFile() If $DoBackup = 1 Then If FileExists(@ScriptDir & "\" & "memory.bak") Then FileDelete(@ScriptDir & "\" & "memory.bak") FileCopy(@ScriptDir & "\" & "memory.txt", @ScriptDir & "\" & "memory.bak") EndIf Local $hFileOpen = FileOpen(@ScriptDir & "\" & "memory.txt", $FO_OVERWRITE) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "SaveToFile", "An error occurred whilst writing the temporary file." & @CRLF & @ScriptDir & "\" & "memory.txt") Return False EndIf If FileWrite($hFileOpen, GUICtrlRead($Edit1)) = 0 Then MsgBox($MB_SYSTEMMODAL, "FileWrite", "Failed to write to Memory.txt" & @CRLF & @ScriptDir & "\" & "memory.txt") Return False Else _GUICtrlEdit_SetModify($Edit1, False) EndIf FileClose($hFileOpen) EndFunc ;==>SaveToFile Func SetFont($id, $h_gui, $nr = 0) For $x = 0 To 7 $a_Fontc[$x] = $a_Font[$x] Next $a_Font = _ChooseFont($a_Font[2], $a_Font[3], $a_Font[5], $a_Font[4], $f_Italic, $f_Underline, $f_Strikethru, $h_gui) If $a_Font <> -1 Then ; GUICtrlSetFont ( controlID, size [, weight [, attribute [, fontname [, quality]]]] ) GUICtrlSetFont($id, $a_Font[3], $a_Font[4], $a_Font[1], $a_Font[2], 0) GUICtrlSetColor($id, $a_Font[5]) $f_Italic = BitAND($a_Font[1], 2) $f_Underline = BitAND($a_Font[1], 4) $f_Strikethru = BitAND($a_Font[1], 8) SaveIniFont($nr) ;ConsoleWrite(@CRLF & $a_Font[3] & @CRLF & $a_Font[4] & @CRLF & $a_Font[1] & @CRLF & $a_Font[2] & @CRLF & $a_Font[5]) Else Dim $a_Font[8] ;Font array definition For $x = 0 To 7 $a_Font[$x] = $a_Fontc[$x] Next EndIf EndFunc ;==>SetFont Func GetIniFont($id, $nr = 0) ;Default font definition $a_Font[1] = IniRead($f_inifile, "font", $nr & "1", "0") $a_Font[2] = IniRead($f_inifile, "font", $nr & "2", "Arial") $a_Font[3] = IniRead($f_inifile, "font", $nr & "3", "8") $a_Font[4] = IniRead($f_inifile, "font", $nr & "4", "400") $a_Font[7] = IniRead($f_inifile, "font", $nr & "7", "0") $f_Italic = BitAND($a_Font[1], 2) $f_Underline = BitAND($a_Font[1], 4) $f_Strikethru = BitAND($a_Font[1], 8) GUICtrlSetFont($id, $a_Font[3], $a_Font[4], $a_Font[1], $a_Font[2], 0) GUICtrlSetColor($id, $a_Font[7]) EndFunc ;==>GetIniFont Func SaveIniFont($nr = 0) IniWrite($f_inifile, "font", $nr & "1", $a_Font[1]) IniWrite($f_inifile, "font", $nr & "2", $a_Font[2]) IniWrite($f_inifile, "font", $nr & "3", $a_Font[3]) IniWrite($f_inifile, "font", $nr & "4", $a_Font[4]) IniWrite($f_inifile, "font", $nr & "7", $a_Font[7]) EndFunc ;==>SaveIniFont Func CW($txt) ConsoleWrite($txt & @CRLF) EndFunc ;==>CW Func _KeyProc($nCode, $wParam, $lParam) If $nCode < 0 Or $MouseVolume = 0 Then Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndIf Local $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) Switch $wParam Case $WM_XBUTTONDOWN, $WM_XBUTTONUP, $WM_XBUTTONDBLCLK, $WM_NCXBUTTONDOWN, $WM_NCXBUTTONUP, $WM_NCXBUTTONDBLCLK If _WinAPI_HiWord(DllStructGetData($info, "mouseData")) = 1 Then Send("{VOLUME_DOWN}") Else Send("{VOLUME_UP}") EndIf Return 1 Case Else Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam) EndSwitch EndFunc ;==>_KeyProc Func _KeyboardProc($nCode, $wParam, $lParam) ;Win Space code part from https://www.autoitscript.com/forum/topic/154094-hotkeyset-for-winspace-does-not-get-trapped/ ;Alt Tab code part from ;https://www.autoitscript.com/forum/topic/87853-disabling-alttab/ If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) Switch $wParam Case $WM_KEYDOWN, $WM_SYSKEYDOWN, $WM_KEYUP, $WM_SYSKEYUP Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) Local $vKode = DllStructGetData($tKEYHOOKS, "vkCode") Local $iFlags = DllStructGetData($tKEYHOOKS, "flags") $t1 = $vKode $t2 = $iFlags Switch $wParam Case $WM_KEYDOWN Switch $vKode Case $VK_SPACE If $isWinDown1 Or $isWinDown2 Then If $DisableLWINSpace Then Return -1 EndIf Case $VK_LWIN $isWinDown1 = True $isWinDown1T = TimerInit() Case $VK_RWIN $isWinDown2 = True $isWinDown2T = TimerInit() EndSwitch Case $WM_KEYUP Switch $vKode Case $VK_LWIN $isWinDown1 = False Case $VK_RWIN $isWinDown2 = False EndSwitch EndSwitch Switch $vKode Case $VK_TAB If BitAND($iFlags, $LLKHF_ALTDOWN) And $DisableAltTab = 1 Then Return -1 Case $VK_CAPSLOCK If $DisableCaps = 1 Then Return -1 EndSwitch EndSwitch Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndFunc ;==>_KeyboardProc Func KillProcess($exename) Local $aProcessList = ProcessList($exename) For $i = 1 To $aProcessList[0][0] ProcessClose($aProcessList[$i][1]) Next EndFunc ;==>KillProcess Func Cleanup() DllCallbackFree($hHookProc) _WinAPI_UnhookWindowsHookEx($hHookKeyboard) _WinAPI_UnhookWindowsHookEx($g_hHook) DllCallbackFree($g_hStub_KeyProc) Exit EndFunc ;==>Cleanup Func CloseScratchbook() TrayItemSetState($idScratchbook, $Tray_Unchecked) GUIDelete($SCP_Form1) $SCP_WInOpen = 0 EndFunc ;==>CloseScratchbook Func Scratchbook() #Region ### START Koda GUI section ### Form= $SCP_Form1 = GUICreate($SCP_formTitle, 616, 440, 208, 165, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) $SCP_Edit1 = GUICtrlCreateEdit("", 3, 30, 610, 406, -1, 0) GUICtrlSetData(-1, "") GUICtrlSetResizing(-1, $GUI_DOCKTOP) $SCP_hEdit1 = GUICtrlGetHandle(-1) $SCP_ButtonCLS = GUICtrlCreateButton("Clear", 2, 0, 33, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_ButtonCLSPASTE = GUICtrlCreateButton("Clear and Paste", 110, 0, 86, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_ButtonPaste = GUICtrlCreateButton("Paste", 45, 0, 54, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_ButtonCopy = GUICtrlCreateButton("Copy", 210, 0, 49, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_ButtonCopyALL = GUICtrlCreateButton("CopyAll", 262, 0, 54, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_ButtonUndo = GUICtrlCreateButton("Undo", 325, 0, 40, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_ButtonFont = GUICtrlCreateButton("Font", 365, 0, 40, 21) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_CheckLock = GUICtrlCreateCheckbox("Read only", 484, 0, 65, 16) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $SCP_WW = GUICtrlCreateCheckbox("WordWrap", 409, 1, 72, 15) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) _GUICtrlEdit_SetLimitText($SCP_Edit1, 200000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $SCP_WInOpen = 1 TrayItemSetState($idScratchbook, $Tray_checked) GetIniFont($SCP_Edit1, 1) EndFunc ;==>Scratchbook Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) If $hWnd = $SCP_Form1 Then ; the main GUI-limited to 640x480 $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, 550) ; min X DllStructSetData($minmaxinfo, 8, 240) ; min Y Return 0 Else ;other dialogs-"no" lower limit Return 0 EndIf EndFunc ;==>MY_WM_GETMINMAXINFO Func GetActiveWindows() GUICtrlSetData($AWINList1, "") ; List all processes $wlist = WinList() For $i = 1 To $wlist[0][0] If $wlist[$i][0] <> "" And BitAND(WinGetState($wlist[$i][1]), 2) Then GUICtrlSetData($AWINList1, $wlist[$i][0] & "|") EndIf Next EndFunc ;==>GetActiveWindows Func SetOnOffTop($wintxt, $top = 1) Local $aWL = WinList($wintxt) If @error = 0 Then For $x = 1 To $aWL[0][0] WinSetOnTop($aWL[$x][1], "", $top) If $top = 1 Then WinActivate($aWL[$x][1]) Next EndIf $aWL = "" EndFunc ;==>SetOnOffTop I've added a few options to this, including the scratchbook(scratchpad) from one of my previous posts. Summary of the new tray menu items: Open Scratchbook - opens a Text editor window, which does not save the text. Show Counter - displays a Counter as tompost window. Show Win-on-Top - Displays a window with list of opened windows. You can set them On/Off top, move to 0,0 or move to the mouse pointer (after 3 seconds delay) Show Keydebugger - Shows a window which displays the keys catched by the _KeyboardProc function Deleted Close - You can add items into the ini file (default 10 items). the [CLOSEPROCESS] the format is 0xa = name 0xb = process.exe (x is a number). If there are no items, the section and two keys will be created at the start. (This Needs a restart to be used !) Tools - You can add some tools in the ini, which could be run from this menu (using Shellexecute). The ini section is [TOOLS] and format: 0xa=Name, 0xb=Filename with path to be executed. (x = number from 0 to 9). (This Needs a restart to be used !) Set PopOut for Youtube On/Off Top - Sets all the window instances of the Chrome extension "Popout for youtube" on or off top. In the Options menu, there are few more items, adding global hotkeys, these are on by default (turn them off once to save these options to the ini file): Disable: LeftWin + Space key, CapsLock, Alt Tab Set Mouse Keys 3+4 to Volume Up/Down Have fun. Edit: 21.01.2023 - Bugfix: After pressing the Win + L key for the lockscreen and returning back, sometime the key got stuck (or the variable did not got reseted by the $wm_keyup). - Added a timer to manually reset the variables after 5 seconds. Edit: 28.01.2023 - Added: Recalling a window position from the saved position, replaced the "Reset Position" with "Move to 0,0" menu item. Edit: 18.03.2023 - Changed: Word Wrapping is now functioning correctly. The Scratchbook window has updated size. Edit: 14.03.2024 - Added: Extra Dice Roll and Counter as topmost window. (toggleable from the Tray menu) Edit: 27.07.2024 - Added: Dice rolls and Counter display the date and time they were clicked and additional information (+ - roll read or reset) Edit: 08.10.2024 - Added: Tools, Close, WIn-On-Top tray menu items. Edit ini in the options. Changed : Removed adding buttons/counters and replaced them with 16 buttons (editable with right mouse click). Added 1 counter. Removed the roller from the extra window and added it to the main window. Added a non saveable editbox which can hold the rolled numbers (if checked). Increased Size on the extra counter window and added beeps on + and - buttons. Edit: 18.10.2024 - Added: A Gui to edit Tools and Close Process menu. There is no error checking, know what you are doing ! (Process close will try close all found instances) Tools need path+filename - no parameters, Process close needs only the .exe (or other runable types.) The Tray menu will update after closing the window. You have to click on the save button before switching to other numbers (or closing the window) or the changes will be lost. Edited October 17 by Dan_555 Updating Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted March 23, 2023 Author Share Posted March 23, 2023 (edited) The following code draws a picture from the clipboard to a gui window. The original code hasn't displayed the picture from the clipboard, and after a lot of trial and errors i found the solution which does work (i'm using windows 10). You have to have a screenshot or a picture in the clipboard for this to work (this script is sending a printscreen key if the clipboard content is not bitmap). Resizing reloads the picture from the clipboard. expandcollapse popup;modified code from https://www.autoitscript.com/forum/topic/57053-updating-a-picture-control-without-a-file/?do=findComment&comment=514735 #include <ScreenCapture.au3> #include <Clipboard.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIHObj.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Draw Image from Clipboard ", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) GUISetState() If Not _ClipBoard_IsFormatAvailable($CF_BITMAP) Then Send("{printscreen}") EndIf ClipDrawBitmap() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESIZED ClipDrawBitmap() EndSwitch WEnd Func ClipDrawBitmap() Local $WPos, $hBitmap, $hImage, $hGraphics $WPos = WinGetPos($hGUI) _ClipBoard_Open($hGUI) $hBitmap = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() If $hBitmap > 0 Then _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_DrawImagePoints($hGraphics, $hImage, 0, 0, $WPos[2], 0, 0, $WPos[3]) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() EndIf EndFunc ;==>ClipDrawBitmap Edited March 23, 2023 by Dan_555 Removed some variables and moved the globals to local ioa747, AutoBert and Zedna 2 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted March 25, 2023 Author Share Posted March 25, 2023 (edited) Ini file, limit tester. This script is mostly useless. The only purpose that it has: is to test if the 64kb limit on the ini files still exists. It will create an ini file (if you click on the "Create ini file" button) after it, you can test if the lines were written. There are two test, one which will show every difference (by using a slightly different test phrase) and the other which will display only the real differences (for e.g. if you manually edit some of the entries in the ini file). You can change the testing phrase and the number of ini sections which will be created. (from 1 to 100000) expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Ini file limit testing", 463, 240, 192, 124, BitOR($WS_SIZEBOX, $WS_SYSMENU)) Global $Edit1 = GUICtrlCreateEdit("", 3, 49, 455, 163) GUICtrlSetData(-1, "") GUICtrlSetLimit(-1, 50000000) GUICtrlSetResizing(-1, 1) Global $input = GUICtrlCreateInput("", 3, 29, 395, 18) GUICtrlSetTip(-1, "Search Phrase") Global $input2 = GUICtrlCreateInput("2000", 408, 29, 50, 18, $ES_NUMBER) GUICtrlSetTip(-1, "Ini sections to create/check" & @CRLF & "Range 1-100000") $Button1 = GUICtrlCreateButton("Test different", 9, 5, 118, 21) GUICtrlSetTip(-1, "Search phrase is different") $Button2 = GUICtrlCreateButton("Test Exact", 269, 5, 118, 21) GUICtrlSetTip(-1, "Search phrase is exact") $Button3 = GUICtrlCreateButton("Create Ini file", 139, 5, 118, 21) GUICtrlSetTip(-1, "Create the ini file") Global $bStop = GUICtrlCreateButton("STOP", 395, 5, 64, 21) GUISetState(@SW_SHOW) GUICtrlSetState($bStop, $GUI_HIDE) #EndRegion ### END Koda GUI section ### Global $test = GUICtrlRead($input2) If $test < 1 Or $test > 100000 Then $test = 100 EndIf Global $inifile = @ScriptDir & "\test.ini" Local $quote = IniRead($inifile, "setting", "quote", " :To Infinity and Beyond!") GUICtrlSetData($input, $quote) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button3 GUICtrlSetState($bStop, $GUI_Show) $quote = GUICtrlRead($input) $test = GUICtrlRead($input2) If $test < 1 Or $test > 100000 Then $test = 100 GUICtrlSetData($input2, $test) EndIf For $x = 1 To $test WinSetTitle($Form1, "", "Writing section: " & $x & "/" & $test) IniWrite($inifile, $x & "testing", "1", $x & " " & $quote) $nMsg = GUIGetMsg() Switch $nMsg Case $bStop ExitLoop EndSwitch Next GUICtrlSetState($bStop, $GUI_HIDE) Case $Button2 $quote = GUICtrlRead($input) memowrite("", 1) IniTestRead($quote) Case $Button1 $quote = GUICtrlRead($input) memowrite("", 1) IniTestRead($quote & "!!") EndSwitch WEnd Func IniTestRead($quote) GUICtrlSetState($bStop, $GUI_Show) For $x = 1 To $test WinSetTitle($Form1, "", "Testing please wait: " & $x & "/" & $test) $tmptxt = IniRead($inifile, $x & "testing", "1", "-1") If $tmptxt = -1 Then memowrite($x & " line does not exist") Else If $tmptxt <> ($x & " " & $quote) Then memowrite($x & " line does not match") memowrite($tmptxt & " /vs/ " & $x & $quote) EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $bStop ExitLoop EndSwitch Next WinSetTitle($Form1, "", "Testing is Done ") GUICtrlSetState($bStop, $GUI_HIDE) EndFunc ;==>IniTestRead Func memowrite($txt, $cls = 0) If $cls = 0 Then GUICtrlSetData($Edit1, $txt & @CRLF, 1) Else GUICtrlSetData($Edit1, "") EndIf EndFunc ;==>memowrite (p.s. it creates 1 section and 1 entry per section, it does not test how many entries are possible per section, although, it can be modified to do that ) (p.p.s.: I have planed to save the phrase and the count of sections to the ini file, but haven't done it (yet)) Edited March 25, 2023 by Dan_555 argumentum 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted March 26, 2023 Author Share Posted March 26, 2023 (edited) This script is a calculator and a bit operation visualizer. You have 2 input boxes where the operations are done and the 3rd where the input is printed out. All operations are displayed in the edit box, with binary output at the left side, so that you can see the bit changes easily. Here is an example output; Quote Results: BitAnd : 0000000000000000000000000010111 = 23 0000000000000000000000001000011 = 67 0000000000000000000000000000011 = 3 BitOr : 0000000000000000000000000010111 = 23 0000000000000000000000001000011 = 67 0000000000000000000000001010111 = 87 BitXor : 0000000000000000000000000010111 = 23 0000000000000000000000001000011 = 67 0000000000000000000000001010100 = 84 + : 0000000000000000000000000010111 = 23 0000000000000000000000001000011 = 67 0000000000000000000000001011010 = 90 Available operations are: BitAnd, BitOr, BitXor, BitNot, Dec to Hex, Dec to Bin, Hex to Dec, Bin To Dec, Dec to Oct, + - * / You can swap the upper and the middle input boxes, and copy the result to either one. p.s.: Read the tooltips of the buttons and input boxes for some hints. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <String.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Bit Operations | Calculation/Comparison only with Decimals", 500, 455, 192, 124) Global $Input1 = GUICtrlCreateInput("1", 6, 3, 224, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_WANTRETURN, $ES_NUMBER)) GUICtrlSetFont(-1, 13, 400, 0, "Terminal") GUICtrlSetTip(-1, "Upper Input box") Global $Input2 = GUICtrlCreateInput("2", 6, 34, 224, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_WANTRETURN, $ES_NUMBER)) GUICtrlSetFont(-1, 13, 400, 0, "Terminal") Global $Input3 = GUICtrlCreateInput("", 5, 82, 224, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_WANTRETURN)) GUICtrlSetFont(-1, 13, 400, 0, "Terminal") GUICtrlSetTip(-1, "Results Input box") $Button1 = GUICtrlCreateButton("BitAnd", 237, 3, 57, 25) $Button2 = GUICtrlCreateButton("BitOr", 237, 30, 57, 25) $Button3 = GUICtrlCreateButton("BitXor", 237, 57, 57, 25) $Button4 = GUICtrlCreateButton("BitNot", 237, 84, 57, 25) GUICtrlSetTip(-1, "Uses the upper input box only") $Button5 = GUICtrlCreateButton("Swap", 307, 3, 57, 25) $tmp = "Uses the Result input box only" & @CRLF $Button6 = GUICtrlCreateButton("DecToHex", 307, 30, 57, 25) GUICtrlSetTip(-1, $tmp) $Button7 = GUICtrlCreateButton("DecToBin", 307, 57, 57, 25) GUICtrlSetTip(-1, $tmp) $Button8 = GUICtrlCreateButton("HexToDec", 307, 84, 57, 25) GUICtrlSetTip(-1, $tmp & "Allowed Chars: 0123456789abcdef") $Button9 = GUICtrlCreateButton("BinToDec", 377, 3, 57, 25) GUICtrlSetTip(-1, $tmp & "Allowed Chars: 01") $Button10 = GUICtrlCreateButton("DecToOct", 377, 30, 57, 25) GUICtrlSetTip(-1, $tmp) $buttonSU = GUICtrlCreateButton("Copy Up", 377, 57, 57, 25) GUICtrlSetTip(-1, "Copy result to upper input box" & @CRLF & "Removes all non numeric chars") $buttonSM = GUICtrlCreateButton("Copy Mid", 377, 84, 57, 25) GUICtrlSetTip(-1, "Copy result to middle input box" & @CRLF & "Removes all non numeric chars") $Button11 = GUICtrlCreateButton("+", 440, 3, 57, 25) $Button12 = GUICtrlCreateButton("-", 440, 30, 57, 25) $Button13 = GUICtrlCreateButton("*", 440, 57, 57, 25) $Button14 = GUICtrlCreateButton("/", 440, 84, 57, 25) $Label1 = GUICtrlCreateLabel("******************************************************", 7, 62, 220, 17) Global $Edit1 = GUICtrlCreateEdit("", 6, 116, 487, 335) GUICtrlSetData(-1, "Results:" & @CRLF & @CRLF) GUICtrlSetFont(-1, 10, 700, 0, "Arial") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Dim $info[] = ["BitAnd", "BitOr", "BitXor", "BitNot", "+", "-", "*", "/"] Local $tmp While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 DoIt(1) Case $Button2 DoIt(2) Case $Button3 DoIt(3) Case $Button4 DoIt(4) Case $Button5 $tmp = GUICtrlRead($Input1) GUICtrlSetData($Input1, GUICtrlRead($Input2)) GUICtrlSetData($Input2, $tmp) Case $Button6 $tmp = Hex(GUICtrlRead($Input3), 8) MemoWrite("Dec to Hex:") MemoWrite(GUICtrlRead($Input3) & " = " & $tmp & @CRLF) GUICtrlSetData($Input3, $tmp) Case $Button7 MemoWrite("Dec to Bin:") $tmp = DecToBin(GUICtrlRead($Input3), 16) MemoWrite(Int(GUICtrlRead($Input3)) & " = " & $tmp & @CRLF) GUICtrlSetData($Input3, $tmp) Case $Button8 $tmp = _StringToUint(GUICtrlRead($Input3), 16) MemoWrite("Hex to Dec:") MemoWrite((GUICtrlRead($Input3)) & " = " & $tmp & @CRLF) GUICtrlSetData($Input3, $tmp) Case $Button9 $tmp = _StringToUint(GUICtrlRead($Input3), 2) MemoWrite("Bin to Dec:") MemoWrite((GUICtrlRead($Input3)) & " = " & $tmp & @CRLF) GUICtrlSetData($Input3, $tmp) Case $Button10 $tmp = _UintToString(GUICtrlRead($Input3), 8) MemoWrite("Dec to Oct:") MemoWrite((GUICtrlRead($Input3)) & " = " & $tmp & @CRLF) GUICtrlSetData($Input3, $tmp) Case $Button11 DoIt(5) Case $Button12 DoIt(6) Case $Button13 DoIt(7) Case $Button14 DoIt(8) Case $buttonSU $tmp = GUICtrlRead($Input3) $tmp = RemoveHex($tmp) GUICtrlSetData($Input1, $tmp) Case $buttonSM $tmp = GUICtrlRead($Input3) $tmp = RemoveHex($tmp) GUICtrlSetData($Input2, $tmp) EndSwitch WEnd Func RemoveHex($txt) Local $s = "0123456789", $tmp = "", $txt1 = "" $txt = StringLower($txt) For $x = 1 To StringLen($txt) $tmp = StringMid($txt, $x, 1) If StringInStr($s, $tmp) Then $txt1 = $txt1 & $tmp Next Return $txt1 EndFunc ;==>RemoveHex Func DoIt($nr) Local $i4 Local $i1 = int(GUICtrlRead($Input1)) Local $i2 = int(GUICtrlRead($Input2)) Switch $nr Case 1 $i3 = BitAND($i1, $i2) Case 2 $i3 = BitOR($i1, $i2) Case 3 $i3 = BitXOR($i1, $i2) Case 4 $i3 = BitNOT($i1) Case 5 $i3 = $i1 + $i2 Case 6 $i3 = $i1 - $i2 Case 7 $i3 = $i1 * $i2 Case 8 $i3 = $i1 / $i2 EndSwitch GUICtrlSetData($Input3, $i3) MemoWrite($info[$nr - 1] & " :") $i4 = _UintToString($i1, 2) MemoWrite(DecToBin($i1, 31) & " = " & $i1) If $nr < 4 Or $nr > 4 Then MemoWrite(DecToBin($i2, 31) & " = " & $i2) EndIf MemoWrite(DecToBin($i3, 31) & " = " & $i3 & @CRLF) ;MemoWrite (_StringRepeat("-",128) & @CRLF) EndFunc ;==>DoIt Func MemoWrite($txt) _GUICtrlEdit_AppendText($Edit1, $txt & @CRLF) EndFunc ;==>MemoWrite Func DecToBin($nr, $len = 8) Local $tmp = _UintToString($nr, 2) Return _StringRepeat("0", $len - StringLen($tmp)) & $tmp EndFunc ;==>DecToBin ;by jchd - Autoitscript forum: Func _UintToString($i, $base) Return DllCall("msvcrt.dll", "wstr:cdecl", "_ui64tow", "uint64", $i, "wstr", "", "int", $base)[0] EndFunc ;==>_UintToString Func _StringToUint($s, $base) Return DllCall("msvcrt.dll", "uint64:cdecl", "_wcstoui64", "wstr", $s, "ptr*", 0, "int", $base)[0] EndFunc ;==>_StringToUint Edited March 26, 2023 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted June 8, 2023 Author Share Posted June 8, 2023 (edited) This is a window manager script. You can do all kind of things with windows. First, select a window then you can try to Enable/disable: close, minimize, maximize buttons and moving the windows (Not all window buttons will work. WhatsApp for e.g. does not allow disabling its close button in this way) (Refresh button sets the Selections to skip) You can Hide, Show, Flash, Bring to front, Set on Top and Off top status. Windows hidden by the Hide button will be added to the list at the last position when you click the refresh button (if clicked without the shift key) You can memorize position and size (2 times) if you need to move/resize a window on the fly. The tray menu has an option to Show the window, in case it was hidden. Holding Shift while clicking on Refresh will populate the Window list with hidden windows. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <MenuConstants.au3> #include <String.au3> #include <GuiListView.au3> #include <EditConstants.au3> #include <ListViewConstants.au3> #include <ComboConstants.au3> #include <Misc.au3> #include <Array.au3> Global $tooltimer=TimerInit(), $toolcounter=250 Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 11) TraySetClick(16) Global $idShow = TrayCreateItem("Show window") TrayCreateItem("") Global $idExit = TrayCreateItem("Exit") Global $wl, $stack[20][3], $List1 MakeActiveWindowList() #Region ### START Koda GUI section ### Form= $WindowManager = GUICreate("WindowManager", 411, 362, 192, 125) $List1 = GUICtrlCreateListView("Nr.|Window Name:| Handle|PiD", 4, 4, 208, 240) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) $Group1 = GUICtrlCreateGroup("Close Button", 219, 5, 185, 37) $Radio1 = GUICtrlCreateRadio("Skip", 232, 20, 42, 18) $Radio2 = GUICtrlCreateRadio("Enable", 286, 20, 54, 18) $Radio3 = GUICtrlCreateRadio("Disable", 340, 20, 54, 18) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Maximize Button", 219, 45, 185, 37) $Radio4 = GUICtrlCreateRadio("Skip", 232, 60, 42, 18) $Radio5 = GUICtrlCreateRadio("Enable", 286, 60, 54, 18) $Radio6 = GUICtrlCreateRadio("Disable", 340, 60, 54, 18) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Minimize Button", 219, 84, 185, 37) $Radio7 = GUICtrlCreateRadio("Skip", 232, 99, 42, 18) $Radio8 = GUICtrlCreateRadio("Enable", 286, 99, 54, 18) $Radio9 = GUICtrlCreateRadio("Disable", 340, 99, 54, 18) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Restore Button", 219, 123, 185, 37) $Radio10 = GUICtrlCreateRadio("Skip", 232, 138, 42, 18) $Radio11 = GUICtrlCreateRadio("Enable", 286, 138, 54, 18) $Radio12 = GUICtrlCreateRadio("Disable", 340, 138, 54, 18) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group5 = GUICtrlCreateGroup("Moveable", 219, 163, 185, 37) $Radio13 = GUICtrlCreateRadio("Skip", 232, 178, 42, 18) $Radio14 = GUICtrlCreateRadio("Enable", 286, 178, 54, 18) $Radio15 = GUICtrlCreateRadio("Disable", 340, 178, 54, 18) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Do it", 364, 203, 40, 20) GUICtrlSetTip(-1, "Enable/Disable window buttons") $Button2 = GUICtrlCreateButton("Refresh", 219, 203, 50, 20) GUICtrlSetTip(-1, "Refresh the widow list" & @CRLF & "hold shift and click to display hidden windows" & @CRLF & "Hidden windows are added at the bottom of the list") $Button3 = GUICtrlCreateButton("To Front", 219, 224, 51, 20) $Button4 = GUICtrlCreateButton("Flash", 271, 224, 44, 20) $Button5 = GUICtrlCreateButton("OnTop", 316, 224, 48, 20) GUICtrlSetTip(-1, "Set window as Topmost") $Button6 = GUICtrlCreateButton("OffTop", 365, 224, 40, 20) GUICtrlSetTip(-1, "Turn off Topmost status") $Button7 = GUICtrlCreateButton("Hide", 269, 203, 34, 20) GUICtrlSetTip(-1, "Hide a window") $Button8 = GUICtrlCreateButton("Show", 304, 203, 34, 20) GUICtrlSetTip(-1, "Unhide/Show a window") $Button9 = GUICtrlCreateButton("Get Info", 309, 254, 50, 22) GUICtrlSetTip(-1, "Fills the Old coordinates") $Button17 = GUICtrlCreateButton("New Info", 309, 277, 50, 22) GUICtrlSetTip(-1, "Fills the New coordinates") $Group1 = GUICtrlCreateGroup("Old", 4, 246, 150, 111) GUICtrlCreateLabel("Width", 9, 262, 32, 15) $Input1 = GUICtrlCreateInput("", 46, 258, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER, $ES_READONLY)) GUICtrlCreateLabel("Height", 9, 284, 35, 17) $Input2 = GUICtrlCreateInput("", 46, 281, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER, $ES_READONLY)) GUICtrlCreateLabel("X Pos", 9, 308, 32, 17) GUICtrlCreateLabel("Y Pos", 8, 331, 32, 17) $Input3 = GUICtrlCreateInput("", 46, 305, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER, $ES_READONLY)) $Input4 = GUICtrlCreateInput("", 46, 329, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER, $ES_READONLY)) $Button12 = GUICtrlCreateButton("Restore", 100, 271, 49, 20) $Button13 = GUICtrlCreateButton("Restore", 99, 318, 49, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("New", 157, 246, 150, 111) GUICtrlCreateLabel("Width", 162, 262, 32, 17) $Input5 = GUICtrlCreateCombo("", 199, 258, 49, 21, BitOR($CBS_AUTOHSCROLL, $CBS_DROPDOWN)) GUICtrlCreateLabel("Height", 162, 284, 35, 17) $Input6 = GUICtrlCreateCombo("", 199, 281, 49, 21, BitOR($CBS_AUTOHSCROLL, $CBS_DROPDOWN)) GUICtrlCreateLabel("X Pos", 162, 308, 32, 17) GUICtrlCreateLabel("Y Pos", 161, 331, 32, 17) $Input7 = GUICtrlCreateCombo("0", 199, 305, 49, 21, BitOR($CBS_AUTOHSCROLL, $CBS_DROPDOWN)) $Input8 = GUICtrlCreateCombo("0", 199, 329, 49, 21, BitOR($CBS_AUTOHSCROLL, $CBS_DROPDOWN)) $Button10 = GUICtrlCreateButton("Resize", 251, 271, 49, 20) $Button11 = GUICtrlCreateButton("Move", 251, 318, 49, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;~ $Button14 = GUICtrlCreateButton("", 330, 293, 80, 20) ;~ $Button15 = GUICtrlCreateButton("", 330, 315, 80, 20) ;~ $Button16 = GUICtrlCreateButton("", 330, 337, 80, 20) GUICtrlSetData($Input5, "1500|1400|1300|1200|1000|900|850|800|700|640|600|500|440|400|320|240|200", "640") GUICtrlSetData($Input6, "1200|1000|900|850|800|700|640|600|500|440|400|320|240|200", "400") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ArrayToList() Global $sLastSel = -1 _GUICtrlListView_SetColumnWidth($List1, 0, 0) _GUICtrlListView_SetColumnWidth($List1, 1, 255) _GUICtrlListView_SetColumnWidth($List1, 2, 100) _GUICtrlListView_SetColumnWidth($List1, 3, 100) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $sLastSel = GetListViewSelection(1) If $sLastSel <> false Then $handle = Number(GetListViewSelection(2)) ;ConsoleWrite('+ Window Handle: ' & $handle & " " & $sLastSel & @CRLF) If _IsChecked($Radio2) = 1 Then EnableButton($handle, $SC_CLOSE) If _IsChecked($Radio3) = 1 Then DisableButton($handle, $SC_CLOSE) If _IsChecked($Radio5) = 1 Then EnableButton($handle, $SC_MAXIMIZE) If _IsChecked($Radio6) = 1 Then DisableButton($handle, $SC_MAXIMIZE) If _IsChecked($Radio8) = 1 Then EnableButton($handle, $SC_MINIMIZE) If _IsChecked($Radio9) = 1 Then DisableButton($handle, $SC_MINIMIZE) If _IsChecked($Radio11) = 1 Then EnableButton($handle, $SC_RESTORE) If _IsChecked($Radio12) = 1 Then DisableButton($handle, $SC_RESTORE) If _IsChecked($Radio14) = 1 Then EnableButton($handle, $SC_MOVE) If _IsChecked($Radio15) = 1 Then DisableButton($handle, $SC_MOVE) EndIf ControlFocus($WindowManager, "", $List1) Case $Button2 GUICtrlSetData($List1, "") MakeActiveWindowList() ArrayToList() Case $Button3 ;To Front $sLastSel = GetListViewSelection() If $sLastSel <> false Then WinActivate($sLastSel) ControlFocus($WindowManager, "", $List1) EndIf Case $Button4 ;Flash window $sLastSel = GetListViewSelection() If $sLastSel <> false Then WinFlash($sLastSel, "", 6, 450) ControlFocus($WindowManager, "", $List1) EndIf Case $Button5 $sLastSel = GetListViewSelection() If $sLastSel <> false Then WinSetOnTop($sLastSel, "", 1) ControlFocus($WindowManager, "", $List1) EndIf Case $Button6 $sLastSel = GetListViewSelection() If $sLastSel <> false Then WinSetOnTop($sLastSel, "", 0) ControlFocus($WindowManager, "", $List1) EndIf Case $Button7 ;Hide $sLastSel = GetListViewSelection() If $sLastSel <> false Then WinSetState($sLastSel, "", @SW_HIDE) $tmp = 0 For $y = 1 To 2 For $x = 0 To UBound($stack) - 1 Select Case $y = 1 ;check if the id is in the array If $stack[$x][1] = GetListViewSelection(2) Then ExitLoop 2 Case $y = 2 If $stack[$x][1] = "" Then $stack[$x][0] = GetListViewSelection(1) $stack[$x][1] = GetListViewSelection(2) $stack[$x][2] = GetListViewSelection(3) ;ConsoleWrite("adding :" & $stack[$x][0] & " / " & $stack[$x][1] & " / " & $stack[$x][2] & " / " & @CRLF) ExitLoop 2 EndIf EndSelect Next Next ControlFocus($WindowManager, "", $List1) EndIf Case $Button8 ;Show $sLastSel = GetListViewSelection() If $sLastSel <> false Then WinSetState($sLastSel, "", @SW_SHOW) ControlFocus($WindowManager, "", $List1) $tmp0 = GetListViewSelection(2) For $x = 0 To UBound($stack) - 1 If $stack[$x][1] = $tmp0 Then $stack[$x][0] = "" $stack[$x][1] = "" $stack[$x][2] = "" EndIf Next EndIf Case $Button9 ;GetInfo $sLastSel = GetListViewSelection() If $sLastSel <> false Then $atmp = WinGetPos($sLastSel) If @error = 0 Then GUICtrlSetData($Input1, $atmp[2]) GUICtrlSetData($Input2, $atmp[3]) GUICtrlSetData($Input3, $atmp[0]) GUICtrlSetData($Input4, $atmp[1]) EndIf $atmp = "" ControlFocus($WindowManager, "", $List1) EndIf Case $Button10 $sLastSel = GetListViewSelection() If $sLastSel <> false Then $tmp0 = GUICtrlRead($Input5) $tmp1 = GUICtrlRead($Input6) $atmp = WinGetPos($sLastSel) If @error = 0 Then WinMove($sLastSel, "", $atmp[0], $atmp[1], $tmp0, $tmp1) EndIf $atmp = "" ControlFocus($WindowManager, "", $List1) EndIf Case $Button11 $sLastSel = GetListViewSelection() If $sLastSel <> false Then $tmp0 = GUICtrlRead($Input7) $tmp1 = GUICtrlRead($Input8) WinMove($sLastSel, "", $tmp0, $tmp1) ControlFocus($WindowManager, "", $List1) EndIf Case $Button12 $sLastSel = GetListViewSelection() If $sLastSel > False Then $tmp0 = GUICtrlRead($Input1) $tmp1 = GUICtrlRead($Input2) $atmp = WinGetPos($sLastSel) If @error = 0 Then WinMove($sLastSel, "", $atmp[0], $atmp[1], $tmp0, $tmp1) EndIf $atmp = "" ControlFocus($WindowManager, "", $List1) EndIf Case $Button13 $sLastSel = GetListViewSelection() If $sLastSel <> false Then $tmp0 = GUICtrlRead($Input3) $tmp1 = GUICtrlRead($Input4) WinMove($sLastSel, "", $tmp0, $tmp1) ControlFocus($WindowManager, "", $List1) EndIf Case $Button17 ;GetInfo $sLastSel = GetListViewSelection() If $sLastSel <> false Then $atmp = WinGetPos($sLastSel) If @error = 0 Then GUICtrlSetData($Input5, $atmp[2], $atmp[2]) GUICtrlSetData($Input6, $atmp[3], $atmp[3]) GUICtrlSetData($Input7, $atmp[0], $atmp[0] ) GUICtrlSetData($Input8, $atmp[1], $atmp[1]) EndIf $atmp = "" ControlFocus($WindowManager, "", $List1) EndIf EndSwitch Switch TrayGetMsg() Case $idExit Exit Case $idShow GuiSetState(@SW_SHOW) EndSwitch if TimerDiff($tooltimer)<100 Then $toolcounter=$toolcounter+1 if $toolcounter<100 then ToolTip ("Select a window" & @CRLF & " from the listbox") $tooltimer=TimerInit() EndIf Else ToolTip ("") EndIf WEnd Func GetListViewSelection($nr = 1) For $x = 0 To _GUICtrlListView_GetItemCount($List1) If _GUICtrlListView_GetItemSelected($List1, $x) Then Return _GUICtrlListView_GetItemText($List1, $x, $nr) Next $toolcounter=0 $tooltimer=TimerInit () Return False EndFunc ;==>GetListViewSelection Func MakeActiveWindowList() Local $y = 0, $x, $tmp0, $tmp1, $tmpwl, $tmps $wl = "" $tmpwl = WinList() For $x = 0 To UBound($stack) - 1 If $stack[$x][2] > 0 And ProcessExists($stack[$x][2]) = 0 Then $stack[$x][0] = "" $stack[$x][1] = "" $stack[$x][2] = "" EndIf Next For $x = 1 To $tmpwl[0][0] If $tmpwl[$x][0] <> "" Then $tmps = WinGetState($tmpwl[$x][0]) ;If $tmps > 1 Then ConsoleWrite($tmpwl[$x][0] & " - " & DecToBin($tmps) & " :: " & WinGetProcess($tmpwl[$x][0]) & @CRLF) $tmp0 = 2 If _IsPressed("10") Then $tmp0 = 3 If BitAND($tmps, $tmp0) Then $y = $y + 1 $tmp0 = $tmpwl[$x][0] $tmp1 = $tmpwl[$x][1] $tmpwl[$y][0] = $tmp0 $tmpwl[$y][1] = $tmp1 EndIf EndIf Next Global $wl[$y][3] For $x = 0 To $y - 1 ;$wl[$x][0] = _StringRepeat("0",2-StringLen($x)) & $x & ": " & $tmpwl[$x + 1][0] $wl[$x][0] = $tmpwl[$x + 1][0] $wl[$x][1] = $tmpwl[$x + 1][1] $wl[$x][2] = WinGetProcess($tmpwl[$x + 1][1]) Next $tmpwl = "" $tmp0 = UBound($wl) - 1 For $x = 0 To UBound($stack) - 1 $tmp1 = 0 For $y = 0 To $tmp0 If $stack[$x][1] = $wl[$y][1] Then $tmp1 = 1 Next If $tmp1 = 0 And $stack[$x][0] > "" Then _ArrayAdd($wl, $stack[$x][0] & "|" & $stack[$x][1] & "|" & $stack[$x][2]) Next EndFunc ;==>MakeActiveWindowList Func ResetCheckboxes() _CheckUncheck($Radio1, 1) _CheckUncheck($Radio4, 1) _CheckUncheck($Radio7, 1) _CheckUncheck($Radio10, 1) _CheckUncheck($Radio13, 1) EndFunc ;==>ResetCheckboxes Func ArrayToList() ResetCheckboxes() _GUICtrlListView_DeleteAllItems($List1) For $x = 0 To UBound($wl) - 1 _GUICtrlListView_AddItem($List1, $x) _GUICtrlListView_AddSubItem($List1, $x, $wl[$x][0], 1) _GUICtrlListView_AddSubItem($List1, $x, $wl[$x][1], 2) _GUICtrlListView_AddSubItem($List1, $x, $wl[$x][2], 3) ;ConsoleWrite($x & " " & $wl[$x][0] & @CRLF) Next $wl = "" EndFunc ;==>ArrayToList ; Part of code from - https://www.autoitscript.com/forum/topic/147424-disable-or-remove-close-minimize-maximize-buttons-on-any-window-in-runtime/ ; Original script: http://www.autoitscript.com/forum/topic/100125-disable-close-button/#entry716490 ; USer32.dll functions: http://msdn.microsoft.com/en-us/library/ms647985(v=vs.85).aspx Func DisableButton($hWnd, $iButton) $hSysMenu = _GUICtrlMenu_GetSystemMenu($hWnd, 0) _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) _GUICtrlMenu_DrawMenuBar($hWnd) EndFunc ;==>DisableButton Func EnableButton($hWnd, $iButton) $hSysMenu = _GUICtrlMenu_GetSystemMenu($hWnd, 1) _GUICtrlMenu_RemoveMenu($hSysMenu, $iButton, False) _GUICtrlMenu_DrawMenuBar($hWnd) EndFunc ;==>EnableButton Func DecToBin($nr, $len = 8) Local $tmp = _UintToString($nr, 2) Return _StringRepeat("0", $len - StringLen($tmp)) & $tmp EndFunc ;==>DecToBin ;by jchd - Autoitscript forum: Func _UintToString($i, $base) Return DllCall("msvcrt.dll", "wstr:cdecl", "_ui64tow", "uint64", $i, "wstr", "", "int", $base)[0] EndFunc ;==>_UintToString Func _IsChecked($idControlID) ;Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED ;Returns true or false (oneliner) ;The lines below convert true and false to numbers - 1 and 0 Local $x = BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED If $x = True Then Return 1 Return 0 EndFunc ;==>_IsChecked Func _CheckUncheck($id, $nr) If $nr = 0 Then GUICtrlSetState($id, $GUI_UNCHECKED) Else GUICtrlSetState($id, $GUI_CHECKED) EndIf EndFunc ;==>_CheckUncheck Edited June 22, 2023 by Dan_555 swapped WinSetState ($WindowManager,"",@SW_SHOW) with GuiSetState(@sw_show) Some of my script sourcecode Link to comment Share on other sites More sharing options...
TheDcoder Posted June 9, 2023 Share Posted June 9, 2023 @Dan_555 Did you try @KaFu's HMW program? I think it functions similar to your window manager EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
argumentum Posted June 9, 2023 Share Posted June 9, 2023 ...there are over 1,500,000 posts in this site. It's hard to know everything there's ever been. 😅 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
TheDcoder Posted June 9, 2023 Share Posted June 9, 2023 (edited) Sure but KaFu is an MVP and this program is mentioned in his signature Also I was sharing the info because if Dan had not seen it, now maybe a good time to do so. He might save on additional work or learn something new, win win! Edited June 9, 2023 by TheDcoder argumentum 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Dan_555 Posted June 9, 2023 Author Share Posted June 9, 2023 (edited) 5 hours ago, TheDcoder said: if Dan had not seen it No, i haven't. I have had visited many other signature-links, but this one i do not recall. Maybe because i already have a tool which i use (well it looks like (at least) 2 times in a week) - WinScraper (when you start my app, you may notice the similarities) I started my app with the idea (see previous post about whatapp) to remotely disable the close button without the need to have a script running in background and checking the window positioning ... Recently, by a mistake, i clicked the x button which made an online game close ... but it did not closed right away, but has crashed it ... which made the chance to get back to where i was even harder (as it already is). And so i found a working script somewhere on this forum (see the links in the sourcecode), built a gui around it and then added some buttons JFF. Ofc, it had to have the resizing functions ! Edited June 9, 2023 by Dan_555 TheDcoder 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted May 10 Author Share Posted May 10 (edited) Here is an easy way to add menu items to the system menu. This code is useable only on 1 window (once per script). The Example is at the end: sysmenu_include.au3 expandcollapse popup#include-once ;# Example code is at the end ; modified code from https://www.autoitscript.com/forum/topic/119546-how-to-handle-sys-menu-button-click/?do=findComment&comment=830763 ; SysMenu Include ; Commands: SysmenuInitialize(GuiHandle) - Initializes the system menu handling. Only 1 window is supported (It is useable only once) ; Sysmenu_AddSeparator() - Adds an separator item to the sysmenue ; SysMenu_AddItem("menu name") - Adds an System menu item, returns the created menu number ; Sysmenu_GetSelectedMenuItem() use it in the main loop to get the selected menu item number ; supported menu numbers are starting from 1 to max 30 ; Returns 0 if no menu was selected #include <WinAPIConv.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <MenuConstants.au3> Global $v__SysMenuInitialise = 0, $h__SystemMenu, $v__SysMenuSelection = "" ;_GUICtrlMenu_GetItemCount($h__SystemMenu) Func SysmenuInitialize($h__sysmenuGUI) If $v__SysMenuInitialise = 0 Then Global $a__sysmenuarray[31][2] $a__sysmenuarray[0][0] = 0 $a__sysmenuarray[0][1] = 12288 $h__SystemMenu = _GUICtrlMenu_GetSystemMenu($h__sysmenuGUI) GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSMCOMMAND") $v__SysMenuInitialise = 1 EndIf EndFunc ;==>SysmenuInitialize Func Sysmenu_AddSeparator() If $v__SysMenuInitialise = 1 Then _GUICtrlMenu_AppendMenu($h__SystemMenu, $MF_SEPARATOR, 0, "") EndFunc ;==>Sysmenu_AddSeparator Func SysMenu_AddItem($v__SystemMenuItemName = "") If $v__SysMenuInitialise = 1 Then If $a__sysmenuarray[0][0] <= 30 Then $a__sysmenuarray[0][0] = $a__sysmenuarray[0][0] + 1 $a__sysmenuarray[0][1] = $a__sysmenuarray[0][1] + 1 $tmp = $a__sysmenuarray[0][0] $tmp1 = $a__sysmenuarray[0][1] $a__sysmenuarray[$tmp][0] = $v__SystemMenuItemName $a__sysmenuarray[$tmp][1] = $tmp1 ;_GUICtrlMenu_AppendMenu($hSystemMenu, $MF_STRING, 0x3000, "About") ; You need to set the CmdID value here _GUICtrlMenu_AppendMenu($h__SystemMenu, $MF_STRING, $tmp1, $a__sysmenuarray[$tmp][0]) ; You need to set the CmdID value here Return $a__sysmenuarray[0][0] EndIf EndIf EndFunc ;==>SysMenu_AddItem ;For $x = 6 To 0 Step -1 ; _GUICtrlMenu_DeleteMenu($h__SystemMenu, $x, True) ;Next Func Sysmenu_GetSelectedMenuItem() Local $tmp = 0 If $v__SysMenuInitialise = 1 Then If $v__SysMenuSelection <> 0 Then $tmp = $v__SysMenuSelection $v__SysMenuSelection = "" EndIf EndIf Return $tmp EndFunc ;==>Sysmenu_GetSelectedMenuItem Func _WM_SYSMCOMMAND($hGUI, $iMsg, $wParam, $lParam) Local $tmp = -1, $tmp1 = -1 If $v__SysMenuInitialise = 1 Then If $iMsg = $WM_SYSCOMMAND Then $tmp = _WinAPI_LoWord($wParam) For $x = 1 To $a__sysmenuarray[0][0] $tmp1 = $a__sysmenuarray[$x][1] If $tmp = $tmp1 and $tmp>0 Then $v__SysMenuSelection = $x ExitLoop EndIf Next EndIf EndIf EndFunc ;==>_WM_SYSCOMMAND ;EXAMPLE ********************************************************************************************************** ;~ #include <sysmenu_include.au3> ;~ #include <GUIConstantsEx.au3> ;~ ;Create a test gui ;~ $Form1 = GUICreate("Form1", 369, 192, 192, 124) ;~ GUISetState(@SW_SHOW) ;~ ;Initialize the system menu and add some menu items: ;~ SysmenuInitialize($Form1) ;Initialize the system menu with a handle to the gui ;~ if Random(0,1,1)=1 then Sysmenu_AddSeparator() ;Adds an optional separator ;~ $sm1=SysMenu_AddItem("Exit") ;Add an menu item ;~ for $x=2 to Random(2,5,1) ;~ SysMenu_AddItem($x & " Test") ;~ Next ;~ ;Handling example: ;~ While 1 ;~ $nmsg=GUIGetMsg() ;~ $tmp=Sysmenu_GetSelectedMenuItem() ;~ If $nmsg=$GUI_EVENT_CLOSE or $tmp=$sm1 then Exit ;~ if $tmp>0 then WinSetTitle ($Form1,"","Menu Clicked: " & $tmp & @CRLF) ;~ WEnd Edited May 10 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted July 27 Author Share Posted July 27 (edited) Here is my new script. I'm using it to make the ffmpeg.exe easier to use. You can save up to 99 commands into the ini file, and reuse them later without the need to type them again. Interface explanation: The GO button executes the command. The output is displayed in the edit box below the Go button. Next to the Go button is an input field, in which you can drag and drop a filename into (or write a filename into it) Next to it is an Button, which displays the output location. If you click it, you can choose a folder into which the file should be written. The CLS button clears the output. Stop button kills the executable (in case of a hang up). it is active only when the process is running (when the GO button was pressed) On the Right side there is a drop down box, from which you can select the active command. The DEF button makes the selected command default (it will be automatically selected on the next start) Below is an edit box with the contents of the ini file. Here you can edit/add/delete the commands as needed. Reload button loads the ini file again. Save button saves the changes to the ini file and applies them to the program. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiStatusBar.au3> #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <NamedPipes.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <String.au3> #include <GuiComboBox.au3> #include <FontConstants.au3> ; =============================================================================================================================== ; Description ...: This was the server side of the pipe demo ; Author ........: Paul Campbell (PaulIA) ; Notes .........: CMD-Mod by dan_555 ; =============================================================================================================================== Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayIconHide", 1) ; =============================================================================================================================== ; Global constants ; =============================================================================================================================== Global Const $BUFSIZE = 1024 * 4 Global Const $PIPE_NAME = "\\.\\pipe\\MyFFmpegConverter" Global Const $TIMEOUT = 5000 Global Const $WAIT_TIMEOUT = 250 Global Const $ERROR_IO_PENDING = 997 Global Const $ERROR_PIPE_CONNECTED = 535 Global $locktimer = 0, $lockexit = 0, $inp1Txt Global $h_PID = 0 Global $closingdelay = 1000, $closecounter = 0, $TimeHandle = TimerInit(), $TimeDiff = TimerDiff($TimeHandle) ;Used for CloseGuiOnDoubleClick() Global $formTitle = "FFMPEG process File" Global $inifile = @ScriptDir & "\FFMPEGC.ini" Global $SettingNr = 1, $SettingNrDef = 1 Global $comboarray[100][2] Global $testoutput = IniRead($inifile, "settings", "outputfolder", "r:\") ; =============================================================================================================================== ; Global variables ; =============================================================================================================================== Global $g_hEvent, $g_idMemo, $g_pOverlap, $g_tOverlap, $g_hPipe, $g_hReadPipe, $g_iState, $g_iToWrite ; =============================================================================================================================== ; Main ; =============================================================================================================================== GUIRegisterMsg($WM_SIZE, "WM_SIZE") CreateGUI() InitPipe() MsgLoop() ; =============================================================================================================================== ; Creates a GUI ; =============================================================================================================================== Func CreateGUI() Global $hGUI = GUICreate($formTitle, 814, 404, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME), BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) Global $Button1 = GUICtrlCreateButton("Go", 2, 1, 37, 29) GUICtrlSetTip(-1, "Execute the command from the input box") Global $StatusBar1 = _GUICtrlStatusBar_Create($hGUI) Global $g_idMemo = GUICtrlCreateEdit("", 0, 31, 499, 349) Global $Input1 = GUICtrlCreateInput("", 40, 2, 191, 24) ;GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;GUICtrlSetStyle ($Input1, -1, 16) GUICtrlSetTip(-1, "Filename to be processed" & @CRLF & "Drag'n'Drop a file here and click GO") Global $BInput1 = GUICtrlCreateButton("R:\", 238, 5, 181, 21) GUICtrlSetTip(-1, "Output folder." & @CRLF & "Please enter a valid folder" & @CRLF & " leave blank for the same folder as Source.") Global $Button2 = GUICtrlCreateButton("CLS", 423, 1, 30, 29) GUICtrlSetTip(-1, "Clear the output") Global $Button3 = GUICtrlCreateButton("STOP", 461, 1, 35, 29) GUICtrlSetTip(-1, "Emergency stop, works only if a command is running." & @CRLF & "This will close the running Proccess !!!") Global $labelpreview = GUICtrlCreateLabel("Saved Filename preview", 500, 2, 270, 29) GUICtrlSetTip (-1,"Preview of the saved filename") Global $ButtonSetDef = GUICtrlCreateButton("DEF", 775, 1, 35, 29) GUICtrlSetTip(-1, "Set the chosen command as default" & @CRLF & "Reloads the ini file" & @CRLF & "unsaved changes may be lost") GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState() GUICtrlSetLimit($g_idMemo, 555555555) GUICtrlSetState($Button3, $GUI_DISABLE) Global $EditIni = GUICtrlCreateEdit("", 500, 67, 309, 289) GUICtrlSetFont(-1, 10, $FW_BOLD) Global $ButtonReloadIni = GUICtrlCreateButton("Reload", 500, 358, 44, 23) GUICtrlSetTip(-1, "Reloads the ini file" & @CRLF & "Unsaved changes may be lost") Global $ButtonSaveIni = GUICtrlCreateButton("Save", 765, 358, 44, 23) GUICtrlSetTip(-1, "Save the changes to the ini file") Global $Combo1 = GUICtrlCreateCombo("", 504, 32, 306, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData($EditIni, FileRead($inifile)) GetIniSettings() $droplabel = GUICtrlCreateLabel('', 0, 0, 814, 404) GUICtrlSetBkColor($droplabel, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState($droplabel, $GUI_DROPACCEPTED) EndFunc ;==>CreateGUI ; =============================================================================================================================== ; This function creates an instance of a named pipe ; =============================================================================================================================== Func InitPipe() ; Create an event object for the instance $g_tOverlap = DllStructCreate($tagOVERLAPPED) $g_pOverlap = DllStructGetPtr($g_tOverlap) $g_hEvent = _WinAPI_CreateEvent() If $g_hEvent = 0 Then LogMsg("ERR:InitPipe ..........: API_CreateEvent failed") Return EndIf DllStructSetData($g_tOverlap, "hEvent", $g_hEvent) ; Create a named pipe $g_hPipe = _NamedPipes_CreateNamedPipe($PIPE_NAME, _ ; Pipe name 2, _ ; The pipe is bi-directional 2, _ ; Overlapped mode is enabled 0, _ ; No security ACL flags 1, _ ; Data is written to the pipe as a stream of messages 1, _ ; Data is read from the pipe as a stream of messages 0, _ ; Blocking mode is enabled 1, _ ; Maximum number of instances $BUFSIZE, _ ; Output buffer size $BUFSIZE, _ ; Input buffer size $TIMEOUT, _ ; Client time out 0) ; Default security attributes If $g_hPipe = -1 Then LogMsg("ERR:InitPipe ..........: _NamedPipes_CreateNamedPipe failed") EndIf EndFunc ;==>InitPipe ; =============================================================================================================================== ; This function loops, waiting for user input or the GUI to close ; =============================================================================================================================== Func MsgLoop() GUICtrlSetData($Input1, "") While 1 CloseGuiOnDoubleClick("loop") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE CloseGuiOnDoubleClick("button") Case $Button1 ;Execute the command from the edit field Go() Case $Button2 ;Clear the Edit field MemoWrite("", 1) Case $GUI_EVENT_DROPPED Local $dname = @GUI_DragFile Local $te0 = StringRight($dname, 3) Local $te1 = StringRight($dname, 4) GUICtrlSetData($Input1, $dname) $inp1Txt = GUICtrlRead($Input1) ;Begin extracting the filename from the string $tmpf = _StringSearchSplit($inp1Txt, "\", "R") $fname = _StringSearchSplit($tmpf, ".", "R", "L") ;Extracted filename without path and extension if StringLen($fname)>51 then $fname="..." & StringRight($fname,45) GUICtrlSetData ($labelpreview,$fname & "f") Case $Combo1 $sComboRead = _GUICtrlComboBox_GetCurSel($Combo1) + 1 $SettingNr = $comboarray[$sComboRead][1] Case $ButtonSetDef $sComboRead = _GUICtrlComboBox_GetCurSel($Combo1) + 1 IniWrite($inifile, "settings", "default", $comboarray[$sComboRead][1]) GUICtrlSetData($EditIni, "", 1) GUICtrlSetData($EditIni, FileRead($inifile)) Case $ButtonReloadIni GUICtrlSetData($EditIni, "", 1) GUICtrlSetData($EditIni, FileRead($inifile)) GetIniSettings() Case $ButtonSaveIni Local $fo = FileOpen($inifile, $FO_OVERWRITE) FileWrite($fo, GUICtrlRead($EditIni)) FileClose($fo) $fo = "" GetIniSettings() Case $BInput1 $tmp = FileSelectFolder("Select a folder to save", $testoutput, 3) If $tmp <> "" Then If StringRight($tmp, 1) <> "\" Then $tmp = $tmp & "\" GUICtrlSetData($BInput1, $tmp) GUICtrlSetTip($BInput1, "Saving to:" & @CRLF & $tmp) EndIf $testoutput = $tmp IniWrite($inifile, "settings", "outputfolder", $tmp) EndSwitch WEnd EndFunc ;==>MsgLoop Func Go() Local $cmd, $inp1Txt, $iFNM, $st = 1, $en = 1, $x, $sl, $fname, $fpath, $bs, $cl Local $dq = Chr(34) Local $tmpnr = "", $tmpf = "" $tmpnr = "Command_" & _StringRepeat("0", 2 - StringLen($SettingNr)) & $SettingNr ;Read out the commandline construct from the ini file ! Local $inicmd1 = IniRead($inifile, $tmpnr, "1", "c:\bat\ffmpeg.exe") Local $inicmd2 = IniRead($inifile, $tmpnr, "2", "-i ") Local $inicmd3 = IniRead($inifile, $tmpnr, "3", "") Local $inicmd4 = IniRead($inifile, $tmpnr, "4", ".mp4") $inp1Txt = GUICtrlRead($Input1) ;Begin extracting the filename from the string $tmpf = _StringSearchSplit($inp1Txt, "\", "R") $fname = _StringSearchSplit($tmpf, ".", "R", "L") ;Extracted filename without path and extension ;Check the destination folder: $inp2Txt = GUICtrlRead($BInput1) If FileExists($inp2Txt) And IsDir($inp2Txt) Then $fpath = $inp2Txt Else $sl = StringLen($inp2Txt) $st = 1 $en = 1 $bs = StringInStr($inp2Txt, "\") $cl = StringInStr($inp2Txt, ":") If $cl > 0 Then $tmp = ":" If $bs > 0 Then $tmp = "\" If $cl > 0 Or $bs > 0 Then For $x = $sl To 1 Step -1 If StringMid($inp2Txt, $x, 1) = "\" And $en = 1 Then $en = 0 $st = $x + 1 EndIf Next $fpath = StringMid($inp2Txt, 1, $st) Else Return False EndIf EndIf If $inp1Txt <> "" And FileExists($inp1Txt) Then $tmpfname = $fpath & $fname & "f" & $inicmd4 $cmd = $inicmd1 & " " & $inicmd2 & " " & $dq & $inp1Txt & $dq & " " & $inicmd3 & " " & $dq & $tmpfname & $dq ;IniWrite ($inifile,"dbg","1",$CMD) ;Debug: Commandline information saved to the ini MemoWrite($cmd) If FileExists($tmpfname) Then MemoWrite("Error: Destination file exists") MemoWrite($fpath & $fname & $inicmd4) MemoWrite("Please delete or rename the file to continue") LogMsg("Error: Output filename exists.") Return False EndIf If ExecuteCmd($cmd) Then GUICtrlSetState($Button3, $GUI_ENABLE) While $lockexit = 0 ;Exits the loop when the ReadOutput() stops receiving data. If GUIGetMsg() = $Button3 Then ProcessClose($h_PID) ;Stop Button, closes the proccess id - in case it is stuck _GUICtrlEdit_BeginUpdate($g_idMemo) ;This allows the edit field to be scrolled via scrollbars, while getting data. ReadOutput() ;Read the pipe and set the output into the edit field _GUICtrlEdit_EndUpdate($g_idMemo) WEnd $lockexit = 0 GUICtrlSetState($Button3, $GUI_DISABLE) LogMsg("done") EndIf EndIf EndFunc ;==>Go Func ReadOutput() Local $pBuffer, $tBuffer, $sLine, $iRead, $bSuccess, $iWritten $tBuffer = DllStructCreate("char Text[" & $BUFSIZE & "]") $pBuffer = DllStructGetPtr($tBuffer) ; Read data from console pipe _WinAPI_ReadFile($g_hReadPipe, $pBuffer, $BUFSIZE, $iRead) If $iRead = 0 Then _WinAPI_CloseHandle($g_hReadPipe) _WinAPI_FlushFileBuffers($g_hPipe) $lockexit = 1 $h_PID = 0 Return EndIf ; Get the data and strip out the extra carriage returns $sLine = StringLeft(DllStructGetData($tBuffer, "Text"), $iRead) $sLine = StringReplace($sLine, @CR & @CR, @CR) If $sLine <> "" Then MemoWrite($sLine) EndFunc ;==>ReadOutput ; =============================================================================================================================== ; Executes a command and returns the results ; =============================================================================================================================== Func ExecuteCmd($sCmd) Local $tProcess, $tSecurity, $tStartup, $hWritePipe ; Set up security attributes $tSecurity = DllStructCreate($tagSECURITY_ATTRIBUTES) DllStructSetData($tSecurity, "Length", DllStructGetSize($tSecurity)) DllStructSetData($tSecurity, "InheritHandle", True) ; Create a pipe for the child process's STDOUT If Not _NamedPipes_CreatePipe($g_hReadPipe, $hWritePipe, $tSecurity) Then LogMsg("ERR: ExecuteCmd ........: _NamedPipes_CreatePipe failed") Return False EndIf ; Create child process $tProcess = DllStructCreate($tagPROCESS_INFORMATION) $tStartup = DllStructCreate($tagSTARTUPINFO) DllStructSetData($tStartup, "Size", DllStructGetSize($tStartup)) DllStructSetData($tStartup, "Flags", BitOR($STARTF_USESTDHANDLES, $STARTF_USESHOWWINDOW)) DllStructSetData($tStartup, "StdOutput", $hWritePipe) DllStructSetData($tStartup, "StdError", $hWritePipe) If Not _WinAPI_CreateProcess("", $sCmd, 0, 0, True, 0, 0, "", DllStructGetPtr($tStartup), DllStructGetPtr($tProcess)) Then LogMsg("ERR: ExecuteCmd ........: _WinAPI_CreateProcess failed") _WinAPI_CloseHandle($g_hReadPipe) _WinAPI_CloseHandle($hWritePipe) Return False EndIf $h_PID = DllStructGetData($tProcess, "ProcessID") _WinAPI_CloseHandle(DllStructGetData($tProcess, "hProcess")) _WinAPI_CloseHandle(DllStructGetData($tProcess, "hThread")) ; Close the write end of the pipe so that we can read from the read end _WinAPI_CloseHandle($hWritePipe) LogMsg("ExecuteCommand ....: " & $sCmd) Return True EndFunc ;==>ExecuteCmd Func MemoWrite($sMessage = "", $clr = 0) Local $CRLF = "" If $clr = 1 Then GUICtrlSetData($g_idMemo, "") Else $CRLF = @CRLF EndIf GUICtrlSetData($g_idMemo, $sMessage & $CRLF, 0) EndFunc ;==>MemoWrite Func LogMsg($msg) _GUICtrlStatusBar_SetText($StatusBar1, $msg) EndFunc ;==>LogMsg ; Resize the status bar when GUI size changes Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GUICtrlStatusBar_Resize($StatusBar1) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func CloseGuiOnDoubleClick($typ) $typ = StringLower($typ) Select Case $typ = "button" If $closecounter = 1 And TimerDiff($TimeHandle) <= $closingdelay Then GUIDelete() Exit EndIf If $closecounter = 0 Then $closecounter = 1 $TimeHandle = TimerInit() WinSetTitle($hGUI, "", "To close, use Slow doubleclick on the X ! Or (2* Alt F4) or (2*Esc)") EndIf Case $typ = "loop" If $closecounter = 1 And TimerDiff($TimeHandle) > $closingdelay Then $closecounter = 0 WinSetTitle($hGUI, "", $formTitle) EndIf EndSelect EndFunc ;==>CloseGuiOnDoubleClick ; Check if the filepath is a directory/folder. Does not validate if the directory/folder exists. Func IsDir($sFilePath) Return StringInStr(FileGetAttrib($sFilePath), "D") > 0 EndFunc ;==>IsDir Func GetIniSettings() Local $tmpn, $tmptxt Local $y = 0 $SettingNrDef = IniRead($inifile, "settings", "default", "1") _GUICtrlComboBox_ResetContent($Combo1) For $x = 1 To 99 $tmpn = "Command_" & _StringRepeat("0", 2 - StringLen($x)) & $x $tmptxt = IniRead($inifile, $tmpn, "0", "") $comboarray[$x][0] = "" $comboarray[$x][1] = "" If $tmptxt <> "" Then $y = $y + 1 $comboarray[$y][0] = $tmptxt $comboarray[$y][1] = $x EndIf Next If $SettingNrDef > $y Then $SettingNrDef = $y $tmptxt = "" If $y > 0 Then For $x = 1 To $y $tmptxt = $tmptxt & $comboarray[$x][0] & "|" Next GUICtrlSetData($Combo1, $tmptxt, $comboarray[$SettingNrDef][0]) EndIf EndFunc ;==>GetIniSettings ;Example is at the bottom ! Func _StringSearchSplit($str, $delimiter, $dir = "L", $ret = "R", $incdel = -1) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringSearchSplit ; Description ...: Search for the first delimiter in a string, with searching direction, Case Sensitive search ; Syntax ........: _StringSearchSplit( $String, $delimiter [, $dir ] [, $ret ] [, $incdel ]) ; Parameters ....: $String - String to be checked. ; $delimiter - 1 char delimiter, has to be defined ; $dir - Search from direction (Left/Right), use "L" or "R" - Left is default ; The first letter will be used for direction, if multiple letters are entered e.g "Lab" = "L" ; $ret - Return side, Left or Right - Right is default. see above for valid entries. ; $incdel - Include delimiter 0 = No, 1 = Yes ; ; Return values .: Success - String ; ; e.g. 1: _StringSearch("c:\bat\test.bb","\","L","L") returns "c:" ; e.g. 2: _StringSearch("c:\bat\test.bb","\","L","L",1) returns "c:\" ; e.g. 3: _StringSearch("c:\bat\test.bb","\","L","R") returns "bat\test.bb" ; e.g. 4: _StringSearch("c:\bat\test.bb","\","L","R",1) returns "\bat\test.bb" ; e.g. 5: _StringSearch("c:\bat\test.bb","\","R","R") returns "test.bb" ; e.g. 6: _StringSearch("c:\bat\test.bb","\","R","R",1) returns "\test.bb" ; ; Failure - Empty string and @error flag as follows: ; @error : 1 - Empty String ; 2 - Delimiter should have a length of 1 char ; 3 - Should not happen, but if it does, search the PANIC button ! ; Author ........: Dan_555 (Autoitscript.com forum) ; =============================================================================================================================== Local $y Local $tmptxt = "" $dir = StringLeft(StringUpper($dir), 1) $ret = StringLeft(StringUpper($ret), 1) SetError(0) If StringLen($str) = 0 Then SetError(1) ;empty string Return "" EndIf If (StringInStr($str, $delimiter) = 0) Or (StringLen($delimiter) <> 1) Then SetError(2) ;invalid delimiter Return "" EndIf If $dir <> "L" And $dir <> "R" Then $dir = "L" ;Set default values If $ret <> "L" And $ret <> "R" Then $ret = "R" If $dir = "L" Then $y = StringInStr($str, $delimiter, 1) ;Search for the delimiter If $dir = "R" Then $y = StringInStr($str, $delimiter, 1, -1) If $incdel = 0 Then $incdel = -1 ;Tricky calculations ;) If $incdel <> -1 Then $incdel = 0 If $ret = "L" Then Return StringMid($str, 1, $y + $incdel) ;DisAssemble the string If $ret = "R" Then Return StringMid($str, $y - $incdel) SetError(3) Return "" EndFunc ;==>_StringSearchSplit Here is an example of the ini file: [settings] Default=1 outputfolder=R:\ ;[Command_01] to [Command_99] ;0=Description ;1=Commandline ;2=argument 1 before the 1st filename ;3=argument 2 after the 1st filename ;4=new extension, uses the filename without extension [Command_01] 0=FFMPEG To Mp4 1=c:\bat\ffmpeg.exe 2=-i 3= 4=.mp4 [Command_02] 0=FFmpeg to Gif 1=c:\bat\ffmpeg.exe 2=-i 3=-filter_complex fps=10,scale=320:-1:flags=lanczos,split[x][z];[z]palettegen[y];[x][y]paletteuse 4=.gif The output filename is the same as the input filename (without extension) but with added "F" (to avoid overwriting stuff) e.g. if the filename is Picture01.bmp the output would be Picture01f.jpg Here is the example of the executed command line (for the FFMPEG to Mp4) c:\bat\ffmpeg.exe -i "R:\holliday.mp4" "R:\hollidayf.mp4" Edited July 27 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted October 8 Author Share Posted October 8 (edited) Last night i have updated my Note memo pad script. It got many changes, including this standalone script : expandcollapse popupOpt("TrayMenuMode", 11) Opt("TrayIconHide",1) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $ActWin_Form = GUICreate("Window List", 250, 178, -1, -1) Global $AWINList1 = GUICtrlCreateList("", 2, 2, 246, 149) $AWINLButton1 = GUICtrlCreateButton("On", 5, 153, 34, 22) GUICtrlSetTip (-1,"Try to set the selected window on TOP","On Top") $AWINLButton2 = GUICtrlCreateButton("Off", 40, 153, 34, 22) GUICtrlSetTip (-1,"Remove the topmost attribute","Off Top") $AWINLButton3 = GUICtrlCreateButton("Move", 75, 153, 44, 22) GUICtrlSetTip (-1,"Move the selected window to 0,0","Move") $AWINLButton4 = GUICtrlCreateButton("Move Mouse", 120, 153, 70, 22) GUICtrlSetTip (-1,"Move the selected window to Mouse positon" & @crlf & "in 3 seconds" ,"Move to mouse") $AWINLButton5 = GUICtrlCreateButton("Refresh", 190, 153, 59, 22) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GetActiveWindows() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState (@SW_HIDE, $ActWin_Form) Exit Case $AWINLButton1 $tmp=GUICtrlRead($AWINList1) if $tmp<>"" then SetOnOffTop($tmp,1) Case $AWINLButton2 $tmp=GUICtrlRead($AWINList1) if $tmp<>"" Then SetOnOffTop($tmp,0) Case $AWINLButton3 $tmp=GUICtrlRead($AWINList1) if $tmp<>"" then WinMove ($tmp,"",0,0) Case $AWINLButton4 $tmp=TimerInit() While TimerDiff($tmp)<3000 GUIGetMsg() ToolTip (int(3000-(TimerDiff($tmp)))/1000,MouseGetPos(0),MouseGetPos(1)-20) WEnd ToolTip ("") $tmp=GUICtrlRead($AWINList1) if $tmp<>"" then WinMove ($tmp,"",MouseGetPos(0),MouseGetPos(1)) Case $AWINLButton5 GetActiveWindows() EndSwitch WEnd Func GetActiveWindows() GUICtrlSetData($AWINList1, "") ; List all processes $wlist = WinList() For $i = 1 To $wlist[0][0] If $wlist[$i][0] <> "" And BitAND(WinGetState($wlist[$i][1]), 2) Then GUICtrlSetData($AWINList1, $wlist[$i][0] & "|") EndIf Next EndFunc Func SetOnOffTop($wintxt, $top = 1) Local $aWL = WinList($wintxt) If @error = 0 Then For $x = 1 To $aWL[0][0] WinSetOnTop($aWL[$x][1], "", $top) If $top = 1 Then WinActivate($aWL[$x][1]) Next EndIf $aWL = "" EndFunc ;==>SetOnOffTop It opens a window with a listbox and adds all opened window titles into it. You can Set the windows on/off the always on top attribute and move the windows to either top left side position (0,0) or to the Mouse cursor (after 3 seconds) A sidenote: While working with the notememo pad script, i have noticed that the text in the editbox was selected, and the _GUICtrlEdit_SetSel() seemed to have no effect (it did not removed the selection). After a ~ hour of searching the internet, i found someone saying (here on autoit forum) that you need to first set the focus on the editbox before you can use the _GUICtrlEdit_SetSel() on it ... Well apparently, after loading text into the editbox , to deselect the text you simply need to give it focus ... (the _GUICtrlEdit_SetSel() is not needed for the simple ediboxes created by GuiCtrlCreateEdit command...) something like this: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 308, 152, 192, 114) $Edit1 = GUICtrlCreateEdit("", 6, 5, 295, 141) for $x=1 to 1000 GUICtrlSetData($Edit1, "ABCD Ef Ghij",1) Next GUICtrlSetState($Edit1, $GUI_FOCUS) GUISetState(@SW_SHOW) While 1 if GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Edited October 17 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted November 14 Author Share Posted November 14 (edited) While toying with my NoteMemoPad script, i thought to use a base64 coder and decoder in it ... Because i haven't found a code that is working with pure auto it code (e.g not using com objects ... etc) i searched online for other basic sourcecode. I found an encoder on the Rosettacode and the decoder from the ex Blitbasic.com forum and converted these into autoit code. Here is it, with a test gui: expandcollapse popupGlobal $_Base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" #include <GUIConstantsEx.au3> #include <GuiEdit.au3> DemoGui() Func DemoGui() Global $tmpsels, $tmpsele, $tmpEditText Global $hGUI = GUICreate("My GUI", 320, 286) Global $edit = GUICtrlCreateEdit("", 2, 22, 316, 120) GUICtrlCreateLabel("Source:", 250, 4, 40, 18) GUICtrlCreateLabel("Destination:", 250, 147, 60, 18) Global $edit1 = GUICtrlCreateEdit("", 2, 165, 316, 120) Local $cm1 = GUICtrlCreateButton("Decode", 1, 1, 65, 20) GUICtrlSetTip(-1, "Base64 to Text", "Decode") Local $cm2 = GUICtrlCreateButton("Endcode", 70, 1, 65, 20) GUICtrlSetTip(-1, "Text to Base64", "Encode") Local $cm3 = GUICtrlCreateButton("Copy ^", 1, 144, 65, 20) GUICtrlSetTip(-1, "Bottom into top editbox", "Copy text") _GUICtrlEdit_SetLimitText($edit, 200000000) _GUICtrlEdit_SetLimitText($edit1, 200000000) GUISetState(@SW_SHOW, $hGUI) GUICtrlSetData($edit, "SGVsbG8gV29ybGQ=") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cm1 $tmp = GUICtrlRead($edit) $tmp = Base64_Decode($tmp) GUICtrlSetData($edit1, $tmp) $tmp = "" Case $cm2 $tmp = GUICtrlRead($edit) $tmp = Base64_Encode($tmp) GUICtrlSetData($edit1, $tmp) $tmp = "" Case $cm3 $tmp = GUICtrlRead($edit1) GUICtrlSetData($edit, $tmp) EndSwitch WEnd EndFunc ;==>DemoGui ;Encoding section ********************************* Func e64K($nr) Return StringMid($_Base64code, $nr + 1, 1) EndFunc ;==>e64K Func Base64_Encode($e) ;used from the ex. Blitzbasic.com forum: "Any File to b64 BB data statements by Andy_A" $f = "" $g = StringLen($e) $rm = $g - Floor($g / 3) * 3 For $i = 1 To $g - $rm - 1 Step 3 $a = Asc(StringMid($e, $i, 1)) $b = Asc(StringMid($e, $i + 1, 1)) $c = Asc(StringMid($e, $i + 2, 1)) $w = BitShift(BitAND($a, 252), 2) $x = BitShift(BitAND($a, 3), -4) + BitShift(BitAND($b, 240), 4) $y = BitShift(BitAND($b, 15), -2) + BitShift(BitAND($c, 192), 6) $z = BitAND($c, 63) $f = $f & e64K($w) & e64K($x) & e64K($y) & e64K($z) Next If $rm = 1 Then $a = Asc(StringRight($e, 1)) $w = BitShift(BitAND($a, 252), 2) $x = BitShift(BitAND($a, 3), -4) $f = $f + Chr(e64K($w)) + Chr(e64K($x)) + "==" EndIf If $rm = 2 Then $a = Asc(StringMid($e, $g - 1, 1)) $b = Asc(StringRight($e, 1)) $w = BitShift(BitAND($a, 252), 2) $x = BitShift(BitAND($a, 3), -4) $x = $x + BitShift(BitAND($b, 240), 4) $y = BitShift(BitAND($b, 15), -2) $f = $f & e64K($w) & e64K($x) & e64K($y) & "=" EndIf Return $f EndFunc ;==>Base64_Encode ;Decoding section ********************************* Func _Base64MIMEDecode($s) If StringLen($s) > 0 Then Return (StringInStr($_Base64code, $s, 1) - 1) Return -1 EndFunc ;==>_Base64MIMEDecode Func Base64_Decode($s) Local $w1, $w2, $w3, $w4, $mD For $n = 1 To StringLen($s) Step 4 $w1 = _Base64MIMEDecode(StringMid($s, ($n + 0), 1)) $w2 = _Base64MIMEDecode(StringMid($s, ($n + 1), 1)) $w3 = _Base64MIMEDecode(StringMid($s, ($n + 2), 1)) $w4 = _Base64MIMEDecode(StringMid($s, ($n + 3), 1)) If $w2 > -1 Then $mD = $mD & Chr(BitAND(($w1 * 4 + Int($w2 / 16)), 255)) If $w3 > -1 Then $mD = $mD & Chr(BitAND(($w2 * 16 + Int($w3 / 4)), 255)) If $w4 > -1 Then $mD = $mD & Chr(BitAND(($w3 * 64 + $w4), 255)) Next Return $mD EndFunc ;==>Base64_Decode p.s. there is no error checking ... Edited November 14 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now