Jump to content

Glance - GUI library for AutoIt, based on Windows api.


 Share

Recommended Posts

Hi all,

I am happy to introduce my latest AutoIt hobby project. Glance

It is a gui library created with windows api functions. Back end of this library is a dll file created in Nim programming language. So you have to place the dll near to your exe.

Here is a screenshot. Please see the image.

And here is the sample code for the window in the image.

#AutoIt3Wrapper_UseX64=y
#include "glance.au3"

Local $frm = glf_NewForm("My Autoit window in Nim", 1100, 500) ; Create new Form aka Window
glf_FormCreateHwnd($frm) ; Create the form's handle

Local $mbar = glf_FormAddMenuBar($frm, "File|Edit|Help") ; Create a menubar for this form
glf_FormAddMenuItems($frm, "File", "New Job|Remove Job|Exit") ; Add some sub menus for 'File' & 'Edit' menus
glf_FormAddMenuItems($frm, "Edit", "Format|Font")
glf_FormAddMenuItems($frm, "New Job", "Basic Job|Intermediate Job|Review Job") ; Add some submenus to 'New Job'
glf_MainMenuAddHandler($frm, "Basic Job", $gMenuEvents.onClick, "menuClick"); Add an event handler for 'Basic Job'

Local $btn1 = glf_NewButton($frm, "Normal", 15) ; Now create some buttons
Local $btn2 = glf_NewButton($frm, "Flat", 127)
Local $btn3 = glf_NewButton($frm, "Gradient", 240)
glf_ControlSetProperty($btn2, $gControlProps.backColor, 0x90be6d) ; Set back color property
glf_ButtonSetGradient($btn3, 0xf9c74f, 0xf3722c) ; make this button gradient
glf_ControlAddHandler($btn1, $gControlEvents.onClick, "onBtnClick") ; Add an event handler for btn1

Local $cal = glf_NewCalendar($frm, 15, 70) ; A simple calendar control.

Local $cb1 = glf_NewCheckBox($frm, "Compress", 40, 280) ; Create two checkboxes
Local $cb2 = glf_NewCheckBox($frm, "Extract", 40, 310)
glf_ControlSetProperty($cb2, $gControlProps.foreColor, 0xad2831) ; Set the checked property to True

Local $cmb = glf_NewComboBox($frm, 350, 25) ; Create new ComboBox
glf_ComboAddRange($cmb, "Windows|Linux|Mac|ReactOS") ; Add some items. You can use an array also
glf_ControlSetProperty($cmb, $gControlProps.backColor, 0x68d8d6) ; Set the back color

Local $dtp = glf_NewDateTimePicker($frm, 350, 72) ; Create new DateTimePicker aka DTP

Local $gb = glf_NewGroupBox($frm, "My Groupbox", 25, 245, 150, 100) ; Create new GroupBox
glf_ControlSetProperty($gb, $gControlProps.foreColor, 0x1a659e) ; Set the fore color

Local $lbl = glf_NewLabel($frm, "Static Label", 260, 370) ; Create a Label
glf_ControlSetProperty($lbl, $gControlProps.foreColor, 0x008000) ; Set the fore color

Local $lbx = glf_NewListBox($frm, 500, 25) ; Create a ListBox
glf_ListBoxAddRange($lbx, "Windows|Linux|Mac OS|ReactOS") ; Add some items
glf_ControlSetProperty($lbx, $gControlProps.backColor, 0xffc2d4); Set the back color

Local $lv = glf_NewListView($frm, 270, 161, 330, 150) ; Create a ListView
glf_ListViewSetHeaderFont($lv, "Gabriola", 18) ; Set header font
glf_ControlSetProperty($lv, $gListViewProps.headerHeight, 32) ; Set header height
glf_ControlSetProperty($lv, $gListViewProps.headerBackColor, 0x2ec4b6) ; Set header back color
glf_ControlSetProperty($lv, $gControlProps.backColor, 0xadb5bd) ; Set list view back color
glf_ListViewAddColumns($lv, "Windows|Linux|Mac OS", "0") ; Add three columns
glf_ListViewAddRow($lv, "Win 8|Mint|OSx Cheetah") ; Add few rows
glf_ListViewAddRow($lv, "Win 10|Ubuntu|OSx Catalina")
glf_ListViewAddRow($lv, "Win 11|Kali|OSx Ventura")
Local $cmenu = glf_ControlSetContextMenu($lv, "Forums|General|GUI Help|Dev Help") ; Add a context menu to list view

Local $np1 = glf_NewNumberPicker($frm, 385, 114) ; Create two new NumberPicker aka Updown control
Local $np2 = glf_NewNumberPicker($frm, 300, 114)
glf_ControlSetProperty($np2, $gNumberPickerProps.buttonLeft, True) ; Set the buttons position to left. Default is right
glf_ControlSetProperty($np2, $gControlProps.backColor, 0xeeef20) ; Set back color
glf_ControlSetProperty($np2, $gNumberPickerProps.decimalDigits, 2) ; Set the decimal precision to two
glf_ControlSetProperty($np2, $gNumberPickerProps.stepp, 0.25) ; Set the step value to 0.25

Local $pgb = glf_NewProgressBar($frm, 25, 363) ; Create a progressbar
glf_ControlCreateHwnd($pgb)
glf_ControlSetProperty($pgb, $gProgressBarProps.value, 30) ; Set the value to 30%
glf_ControlSetProperty($pgb, $gProgressBarProps.showPercentage, True) ; We can show the percentage in digits

Local $rb1 = glf_NewRadioButton($frm, "Compiled", 655, 25) ; Create new RadioButtons
Local $rb2 = glf_NewRadioButton($frm, "Interpreted", 655, 55)
glf_ControlSetProperty($rb1, $gRadioButtonProps.checked, True) ; Set one of them checked

Local $tb = glf_NewTextBox($frm, "Some text", 270, 326, 150) ; Create a new TextBox
glf_ControlSetProperty($tb, $gControlProps.foreColor, 0xd80032) ; Set the foreColor

Local $tkb1 = glf_NewTrackBar($frm, 760, 351) ; Create new TrackBars
Local $tkb2 = glf_NewTrackBar($frm, 540, 351)
glf_ControlSetProperty($tkb1, $gTrackBarProps.customDraw, True) ; If set to True, we can change lot of aesthetic effects
glf_ControlSetProperty($tkb2, $gTrackBarProps.customDraw, True)
glf_ControlSetProperty($tkb1, $gTrackBarProps.showSelRange, True) ; We can see the selection are in different color.
glf_ControlSetProperty($tkb2, $gTrackBarProps.ticColor, 0xff1654) ; Set tic color
; glf_ControlSetProperty($tkb2, $gTrackBarProps.channelColor, 0x006d77) ; Set channel color.

Local $tv = glf_NewTreeView($frm, 760, 25, 0, 300) ; Create new TreeView
glf_ControlSetProperty($tv, $gControlProps.backColor, 0xa3b18a) ; Set back color
glf_ControlCreateHwnd($tv)
glf_TreeViewAddNodes($tv, "Windows|Linux1|MacOS|ReactOS" ) ; Add some nodes

glf_TreeViewAddChildNodes($tv, 0, "Win 7|Win 8|Win 10|Win 11") ; Add some child nodes
glf_TreeViewAddChildNodes($tv, 1, "Mint|Ubuntu|Red Hat|Kali")
glf_TreeViewAddChildNodes($tv, 2, "OSx Cheetah|OSx Leopard|OSx Catalina|OSx Ventura")


func onBtnClick($c, $e) ; $c = sender of this event aka, the button itself. $e = EventArgs, like in .NET
    print("Calendar view mode", glf_ControlGetProperty($cb1, $gControlProps.width))
EndFunc

func menuClick($m, $e) ; Here $m is menu itself. $e is MenuEventArgs
    print("Menu clicked", $m)
EndFunc

glf_FormShow($frm.ptr) ; All set, just show the form

You can get the files from my git repo. Here is the link

https://github.com/kcvinker/Glance.git

Glance_4.jpg

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Looks nice.  Why do you used an external DLL for this? I'm also interested in the NIM source. 🙂

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ,

Thank you. I have already written a GUI library in Nim. If I don't use an external DLL, then data grouping is a problem AutoIt. More over, I can complete this project by making small changes to the existing UI library I wrote in Nim. Only about 250 more lines of code needed to be added.
Of course I will push glance.dll's source code to the repo.

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Thanks - got the NIM source code now.

 

Why did you not post it in the Example section?

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Yes I agree with @UEZ, this should be posted in the Examples section.

@kcvinu Thanks for making an alternative GUI sub-system, I'm sure this will come in handy to someone :)

By the way, do coloured buttons work in your GUIs? AutoIt GUIs have a critical bug which is currently labelled as "won't fix" due to the amount of complexity involved, coloured buttons don't work properly.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

@UEZ,

Oops ! My bad. I didn't think about the examples forum. Sorry for that.

 

@TheDcoder,

Thank you. 

What do you mean 'buttons don't work properly.` ? AFAIK, my button's are working perfectly. The only single issue I faced was the round corner drawing in win11 and square corner drawing in win10. But that's trivial. 

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@TheDcoder,

The colored button drawing is not that complex even with AUtoIt's own DllCall feature & win api functions. Before writing this Glance library, I have started one with pure autoit code using DllCall. In that project, I created a window & button successfully. The button had colors too. But I dropped that project because of heavy usage of your map. It is a value type we need to keep two maps. One for the user and one for the internal book keeping. That will end up in a heavy bloat code base. So I dropped that and used my nim gui lib "NimForm"'s code. 

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@argumentum,

Thanks for testing. Sadly, I didn't wrote anything related to handle dark theme. There are certain things which you can't change. Calendar back color is one of them. But you can change form's back color to a dark one. Anyhow, I am interested to see the whole window image. I am curious about the flat color button showed in black color. But the same time, gradient button is showing perfect colors.

Edit: @argumentum

Now I see your code

$frm.backColor = 0x...

This will not work. You need to use the 

glf_ControlSetProperty($frm, 0x...)

 

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@argumentum

Sorry, there is a mistake in my last comment.
You should use

glf_ControlSetProperty($frm, $gControlProps.backColor, 0x...)

 

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@argumentum,

Thank you for the image. It seems that the WM_ERASEBKGND is not working as intended in dark themed systems.

Edit: The gray color is the window class's color.

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@argumentum

There are no dependencies except the glance dll. But you can do one thing to spot the problem. Just comment out some code and run. Do that until you found trouble causing line. 

Just comment out all the control creation code. Run with a bare form. If there is no problem, run with some buttons. If it is okay, run with checkboxes. Thus, you can spot the problem. 
I don't have access to win 10 now. 

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

2 hours ago, kcvinu said:

... Thus, you can spot the problem. 

Local $mbar = glf_FormAddMenuBar($frm, "File|Edit|Help") ; Create a menubar for this form <<<<<<<< this is the one
Func glf_FormAddMenuBar(ByRef $frmMap, $baseMenus)
    Local $mbar = DllCall($hDll, "ptr", "newMenuBarPtr", "ptr", $frmMap.ptr, "wstr", $baseMenus)
    if @error Then $frmMap.error = @error
EndFunc

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

@argumentum 

Thank you. I will check this soon and let you know. :)

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

It looks good but I managed to crash the app multiple times just by clicking things. Here are two examples of errors:

Quote

X: 487  Y: 119
MM_NOTIFY_REFLECT TREEVIEW
MM_NOTIFY_REFLECT TREEVIEW
MM_NOTIFY_REFLECT TREEVIEW
!>03:16:01 AutoIt3.exe ended.rc:-1073740771

Quote

MM_NOTIFY_REFLECT TREEVIEW
MM_NOTIFY_REFLECT TREEVIEW
MM_NOTIFY_REFLECT TREEVIEW
virtualFree failing!

 

When the words fail... music speaks.

Link to comment
Share on other sites

@Andreik

Thank you for testing this. Error noted. Let me check. 

 

Edit: @Andreik Applied a temporary fix on that issue. Will work on that later. You can download the latest version of dll from github.

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Still get some crashes in some conditions:

Quote

X: 552  Y: 326
X: 490  Y: 106
X: 443  Y: 69
!>05:29:28 AutoIt3.exe ended.rc:-1073740771

Quote

X: 416  Y: 107
X: 299  Y: 124
X: 325  Y: 357
virtualFree failing!

 

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

@argumentum

Problem found and a temporary fix applied. You can test it with downloading the dll again from my repo. I just pushed it now. :) 

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...