MaximusCZ Posted February 5, 2021 Share Posted February 5, 2021 Oh my god thats such a great idea. Cover all "X" (and perhaps minimize) buttons and force each app to go to taskbar/tray/exit.. Finally not having to set it in each app individual settings and hate those apps that dont offer the choice. Link to comment Share on other sites More sharing options...
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 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 Author Share Posted January 20 (edited) Hi, here is a version #1 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 **** #include <Misc.au3> If _Singleton("Memo-Note-Pad00") = 0 Then Exit #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <WinAPI.au3> 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 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 Global $KeyDebug = 0 ;Tray menu definition Global $idPopOutOnTop = TrayCreateItem("Set PopoutYoutube on Top") Global $idPopOutOffTop = TrayCreateItem("Set PopoutYoutube off Top") TrayCreateItem("") Global $idCloseSDLBASC = TrayCreateItem("Close SDL-Basic compiler") Global $idCloseBlitzBasicC = TrayCreateItem("Close Blitzbasic compiler") TrayCreateItem("") Global $idKeyCaptureWin = TrayCreateItem("Show KeyDebugger") 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 (3/4) 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("") Global $idScratchbook = TrayCreateItem("Open Scratchbook") 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) Global $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= $hKeyDebug = GUICreate("KeyDebug", 133, 84, -1, -1, $WS_OVERLAPPED, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_CLIENTEDGE)) $KeyInput1 = GUICtrlCreateInput("", 6, 6, 118, 21, $ES_READONLY) $KeyInput2 = GUICtrlCreateInput("", 6, 31, 118, 21, $ES_READONLY) 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)) $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") 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) 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 If $KeyDebug = 1 Then If $t1 <> 0 Then GUICtrlSetData($KeyInput1, "TkeyHooks=" & $t1) $t1 = 0 EndIf If $t2 <> 0 Then GUICtrlSetData($KeyInput2, "vKode=" & $t2) $t2 = 0 EndIf ;~ GUICtrlSetData($KeyInput1, "IsWinDown1=" & $isWinDown1) ;~ GUICtrlSetData($KeyInput2, "IsWinDown2=" & $isWinDown2) EndIf Switch TrayGetMsg() 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 $idPopOutOnTop SetOnOffTop("Popout for", 1) Case $idPopOutOffTop SetOnOffTop("Popout for", 0) Case $idCloseBlitzBasicC KillProcess("blitzcc.exe") Case $idCloseSDLBASC KillProcess("sdlbrt.exe") Case $idKeyCaptureWin $KeyDebug = Mod($KeyDebug + 1, 2) _TrayCheckUncheck($idKeyCaptureWin, $KeyDebug) If $KeyDebug = 0 Then GUISetState(@SW_HIDE, $hKeyDebug) Else GUISetState(@SW_SHOW, $hKeyDebug) 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, 20000000) 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 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 $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 $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 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) $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 EndSwitch 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 _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, 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 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 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 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) 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 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 Keydebugger - Shows a window which displays the keys catched by the _KeyboardProc function Close SDLBasic/BlitzBasic compiler - Closes all the instances of these running programs, in case of endless loops. 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 now a limited minimum size. Edited March 18 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted March 23 Author Share Posted March 23 (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 by Dan_555 Removed some variables and moved the globals to local ioa747, Zedna and AutoBert 2 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted March 25 Author Share Posted March 25 (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 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 Author Share Posted March 26 (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 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted June 8 Author Share Posted June 8 (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 by Dan_555 swapped WinSetState ($WindowManager,"",@SW_SHOW) with GuiSetState(@sw_show) Some of my script sourcecode Link to comment Share on other sites
Recommended Posts