Recently Browsing 0 members
No registered users viewing this page.
The more projects I work on, the harder it is to find old scripts I created with certain techniques in them. I'd like to leave this here for others to get an idea from and it will be available now by keyword searching in this forum.
This project needed an evenly distributed button grid setup on a touch screen with half decent sized buttons and spacing so the user would be less likely to press the key beside it. Here is one quick example to give anyone an idea of a way to handle it.
#include <GUIConstants.au3> GUICreate("Button Grid", 1080, 100) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ;--Create and Position Controls Dim $btnActivated ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed Dim $btnArray ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed $num = 0 $btnActivated = GUICtrlCreateButton("Activated", 0, 0, 100, 100) ;x,y,w,h $btnActivated = True GUICtrlSetBkColor(-1,0x00ff00) GUICtrlSetColor(-1,0x005500) GUICtrlSetFont(-1,14) For $Y = 0 To 1 For $X = 0 To 7 ConsoleWrite( ($X * 100) + ($X*20) + 120 & @CRLF) If $Y=0 Then $btnArray[$num] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, 0, 100, 40) ;x,y,w,h Else $btnArray[$num] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, ($Y * 40) + $Y*20, 100, 40) ;x,y,w,h EndIf GUICtrlSetBkColor($btnArray[$num], 0xFFFFFF) $num += 1 Next Next ;--Set Button Names GUICtrlSetData($btnArray,"Autoit") GUICtrlSetData($btnArray,"Is") GUICtrlSetData($btnArray,"Cool") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $btnActivated $btnActivated = NOT $btnActivated If $btnActivated Then GUICtrlSetBkColor($btnActivated,0x00ff00) GUICtrlSetColor($btnActivated,0x005500) GUICtrlSetData($btnActivated,"Activated") GUICtrlSetFont($btnActivated,14) Else GUICtrlSetBkColor($btnActivated,0xFF9999) GUICtrlSetColor($btnActivated,0x550000) GUICtrlSetData($btnActivated,"DeActivated") GUICtrlSetFont($btnActivated,13) EndIf Case $btnArray If $btnActivated Then MsgBox(0,"Notice","Btn1",1) EndIf Case $btnArray If $btnActivated Then MsgBox(0,"Notice","Btn2",1) EndIf Case $btnArray If $btnActivated Then MsgBox(0,"Notice","Btn3",1) EndIf EndSwitch WEnd I couldn't find one of my old projects that broke the button array into more columns that included the actual button name in the field. Feel free to share your own or share a more flexible version of this simple example.
I am making some GUI with combobox for the Baudrates communications and I listed 9600, 57600, 115200.
I wrote the code to be defaulted to 57600 like this:
GUICtrlSetData($comboBox_opticalBaudRate, "9600|57600|115200", "57600")
But I wanted the GUI to remember the last item the user picks so the baudrates will NOT be defaulted to 57600.
Example, I pick 9600 as my baudrates, then I close the GUI, after opening it, it always prompt 57600 since that is what I did in my code. But I want that if I choose 9600 and close the GUI, opening it again will show 9600 now instead of 57600.
Is there a way to do it in GUI setting?
#Region ### START Koda GUI section ### Form=C:\Users\Engr. Ashraful\Videos\koda_22.214.171.124\Forms\ProgramPlayer\FormProgamToOpen.kxf
$FormInput = GUICreate("Input", 302, 205, 454, 285)
$Resolution = GUICtrlCreateCombo("Resolution", 80, 24, 145, 25)
$ComboProgramType = GUICtrlCreateCombo("Program Type Selection", 80, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$ButtonEnter = GUICtrlCreateButton("Enter", 104, 104, 75, 25)
#EndRegion ### END Koda GUI section ###
$nMsg = GUIGetMsg()
please help me to read combo box input and use the value for another function/ work
I am having a problem properly saving the Width of a resizable Gui.
When a user resizes the Gui it gets saved in an ini when the Gui closes to then restore the new Width upon reopening the app.
WinGetPos($hGUI) returns 314, and WinGetClientSize($hGUI) returns 298
when its then saved in the ini the gui keeps expanding or shrinking every time its opened by +14 or -2
I figure it has to do with borders etc, but i also guess borders depend on the window theme and whatnot or is user specific, so i can't just do $GuiWidth = $GetGuiWidth[arr] -14 or +2 right?
is there a proper way of doing this?
Thanks in advance,
In the display settings, in the advanced settings on the General tab is more or less the setting: The translation from GOOGLE: "If the resolution makes items are too small to achieve visual comfort, you can to offset this effect increase the resolution dpi. To change only the font size, click Cancel and go to the Appearance tab." EDIT: Here there is a possibility to choose: Default size 96 dpi Big size 120 dpi When I Change this option to 120 dpi, this causes display problems with elements such as Button. The problem is manifested by the fact that the text does not fit within the limits set by the size of the button. Of course, if you set 96 dpi, the text looks normal. Does anyone know a solution to this problem. I note that the solution like this: GUICtrlSetResizing(-1, $GUI_DOCKALL) unfortunately does not help.