All Activity
- Past hour
-
Resizable status bar without SBARS_SIZEGRIP
WildByDesign replied to WildByDesign's topic in AutoIt GUI Help and Support
This quick fix works quite well for my current purpose. I haven't noticed any negative effects either. Thank you again for your help with this. -
WildByDesign reacted to a post in a topic: Statusbar coloring issue with _GUICtrlStatusBar_EmbedControl
- Today
-
I noticed that a couple of days ago but did not report, after we saw the issue in _GUICtrlStatusBar_EmbedControl which did not let you embed controls in your script, because of _WinAPI_SetParent() which change the parent of the embedded controls, then their background colors were not the ones you wanted. I'm sure other examples in the help file would need the same fix, e.g. to take care of the messages WM_SIZE / WM_MOVE when the GUI is resized, minimized etc... and calculate the position of these controls during the registered messages functions.
-
Resizable status bar without SBARS_SIZEGRIP
pixelsearch replied to WildByDesign's topic in AutoIt GUI Help and Support
@WildByDesign Example 3 was designed with a custom sizebox window (composed of dots) and plenty of code in the script refers to it, assuming that if it is here, then the GUI is created to be resizable etc... Nevertheless, if you don't want to use it at all and have a non-resizable GUI, then I just tested a simple way to keep all the code of example 3 untouched, except these 2 lines : ; $g_hGui = GUICreate("Resize corner", $iW, $iH, -1, -1, $WS_OVERLAPPEDWINDOW) $g_hGui = GUICreate("Resize corner", $iW, $iH) ; Next line to be commented out in Func WM_SIZE ; WinMove($g_hSizebox, "", $aSize[0] - $g_iHeight, $aSize[1] - $g_iHeight, $g_iHeight, $g_iHeight) I tested it quickly and the size box doesn't appear after we minimize the GUI and restore it. And If one day, who knows, you'll need a resizable GUI again, then you'll know what to do Let's hope there won't be side effects with this minimal change. If side effects should appear, then we'll consider what to do, having in mind that the safest thing to do should be to delete all code parts concerning the sizebox, but that's plenty of lines, the ScrollbarProc function, the CreateDots function etc... For now, please just try to comment out the WinMove line in Func WM_SIZE as indicated above, then the sizebox will stay where it was first created (e.g at coords 0,0 with a size of 0,0) . Let's hope that variables like $bIsSizeBoxShown etc... won't interfere with this minimal change. - Yesterday
-
I just found out the hard way that the _GUICtrlStatusBar_EmbedControl function has a terrible bug that renders it essentially useless. If you use the same example from (Function _GUICtrlStatusBar_EmbedControl), if you run the example, minimize the GUI and restore the GUI, the majority of the parts disappear and/or move to another area of the GUI. I wish that I noticed this a few days ago before I went all-in on it. Thank you for this information. The fact that your UDF function provides an array with all of those details is fantastic. This might just save me from the broken statusbar situation that I currently have right now. I'm going to try your UDF now.
-
Resizable status bar without SBARS_SIZEGRIP
WildByDesign replied to WildByDesign's topic in AutoIt GUI Help and Support
@pixelsearch I just ran into a bug on your 3rd example. Or at least it might be a bug. If you remove the $WS_OVERLAPPEDWINDOW from GuiCreate to create a non-resizable GUI, it starts correctly at first. As expected, the sizebox is not there and you cannot resize the window. However, if you simply minimize the window and restore it, the sizebox comes back and you can actually resize the window now. Do you know if there is something that I can change to fix this? In my current project, I would like the window to remain non-resizable. Thank you. -
argumentum reacted to a post in a topic: Statusbar coloring issue with _GUICtrlStatusBar_EmbedControl
-
Making GUI's open on a particular monitor
LWC replied to PartyPooper's topic in AutoIt GUI Help and Support
I know it's an ancient topic, but with many people working with multiple monitors a full answer was still sorely missing - every single answer here was manual. Here's my fully automated UDF I came up with, which allows simply giving a monitor number and utilizing it via Windows API. You can also use it for your default monitor but with a quick way to maximize or center it. GUICreateMonitor.au3 #include-once #include <GUIConstantsEx.au3> ; for $GUI_EVENT_CLOSE #include <WinAPIGdi.au3> ; #FUNCTION# ==================================================================================================================== ; Description ...: Create a GUI on a specific monitor ; Parameters ....: $iMonitorNumber - Monitor number (1-based index) or 0 for Primary or empty for Windows to decide ; $iCreate - Actually create the GUI, otherwise just return an array of its potential values ; $sTitle - Title to use for GUI ; $iWidth - Width to use for GUI - can be number or "max" ; $iHeight - Height to use for GUI - can be number or "max" ; $oLeft - Left side to use for GUI - can be number or "center" or "max" ; $oTop - Top side to use for GUI - can be number or "center" or "max" ; $iStyle - Style to use for GUI ; $iExStyle - Extended style to use for GUI ; $iParent - Parent to use for GUI ; Return values .: See GUICreate ; Author ........: LWC <https://lior.weissbrod.com> ; Modified ......: ; ================================================================================================================== Func GUICreateOnMonitor($iMonitorNumber, $iCreate, $sTitle, $iWidth = 0, $iHeight = 0, $oLeft = 0, $oTop = 0, $iStyle = "", $iExStyle = "", $iParent = "") if IsNumber($iMonitorNumber) then ; Get monitor information Local $aMonitorData = GetMonitorInfo() Local $aMonitors = $aMonitorData[0] Local $iPrimaryMonitorIndex = $aMonitorData[1] Local $iMonitorCount = UBound($aMonitors) EndIf ; Fallback for an non exising monitor If IsNumber($iMonitorNumber) and ($iMonitorNumber < 1 Or $iMonitorNumber > $iMonitorCount) Then If $iPrimaryMonitorIndex >= 0 Then $iMonitorNumber = $iPrimaryMonitorIndex + 1 ; Convert to 1-based index Else $iMonitorNumber = 1 EndIf EndIf ; Get monitor position Local $iMonitorIndex = IsNumber($iMonitorNumber) ? $iMonitorNumber - 1 : "" ; (1-based index to 0-based array) Local $iMonitorWidth = IsNumber($iMonitorNumber) ? $aMonitors[$iMonitorIndex][3] : @DesktopWidth Local $iMonitorHeight = IsNumber($iMonitorNumber) ? $aMonitors[$iMonitorIndex][4] : @DesktopHeight Local $iLeft = IsNumber($iMonitorNumber) ? $aMonitors[$iMonitorIndex][1] : 0 Local $iTop = IsNumber($iMonitorNumber) ? $aMonitors[$iMonitorIndex][2] : 0 ; Position window on monitor If $iWidth == "max" Then $iWidth = $iMonitorWidth If $iHeight == "max" Then $iHeight = $iMonitorHeight Local $iWindowLeft = $iLeft + (($oLeft == "max") ? $iMonitorWidth : (($oLeft == "center") ? ($iMonitorWidth - $iWidth) / 2 : $oLeft)) Local $iWindowTop = $iTop + (($oTop == "max") ? $iMonitorHeight : (($oTop == "center") ? ($iMonitorHeight - $iHeight) / 2 : $oTop)) Local $iSimulate = False If $iSimulate Then MsgBox($MB_ICONINFORMATION, "Simulation", "GUICreate(" & Chr(34) & $sTitle & Chr(34) & ", " & (($iWidth == "") ? "Default" : $iWidth) & ", " & (($iHeight == "") ? "Default" : $iHeight) & ", " & $iWindowLeft & ", " & $iWindowTop & " ," & (($iStyle == "") ? "Default" : $iStyle) & ", " & (($iExStyle == "") ? "Default" : $iExStyle) & ", " & (($iParent == "") ? "Default" : $iParent) & ")") EndIf Local $return = [IsNumber($iMonitorNumber) ? $iMonitorNumber : "", $iMonitorWidth, $iMonitorHeight, $iWindowLeft, $iWindowTop] Return $iCreate ? ($iSimulate ? 0 : GUICreate($sTitle, ($iWidth == "") ? Default : $iWidth, ($iHeight == "") ? Default : $iHeight, $iWindowLeft, $iWindowTop, ($iStyle == "") ? Default : $iStyle, ($iExStyle == "") ? Default : $iExStyle, ($iParent == "") ? Default : $iParent)) : $return EndFunc ; #FUNCTION# ==================================================================================================================== ; Description ...: Get monitor information (filtered for physical monitors) ; Parameters ....: None ; Return values .: Array (empty if no info) ; Author ........: LWC <https://lior.weissbrod.com> ; Modified ......: ; ================================================================================================================== Func GetMonitorInfo() Local $aMonitors[0][5] ; [index][0=handle, 1=left, 2=top, 3=width, 4=height] Local $iMonitorCount = 0 Local $aResult = _WinAPI_EnumDisplayMonitors() If @error Or Not IsArray($aResult) Then Return $aMonitors EndIf $iMonitorCount = UBound($aResult) ; Filter out virtual monitors (those with very small dimensions or zero dimensions) Local $aFilteredMonitors[0][5] Local $iFilteredCount = 0 Local $iPrimaryMonitorIndex = -1 ; Track which monitor is primary For $i = 0 To $iMonitorCount - 1 ; Get monitor handle from the enumeration result Local $hMonitor = $aResult[$i][0] ; Skip null/invalid handles If $hMonitor = 0 Then ContinueLoop EndIf Local $aMonitorInfo = _WinAPI_GetMonitorInfo($hMonitor) If @error Then ContinueLoop EndIf ; Extract rectangle data from the monitor info ; $aMonitorInfo[0] = $tagRECT structure for monitor rectangle Local $tRect = $aMonitorInfo[0] Local $iLeft = DllStructGetData($tRect, 1) Local $iTop = DllStructGetData($tRect, 2) Local $iRight = DllStructGetData($tRect, 3) Local $iBottom = DllStructGetData($tRect, 4) Local $iWidth = $iRight - $iLeft Local $iHeight = $iBottom - $iTop ; Filter out monitors with dimensions less than 100x100 (likely virtual) If $iWidth >= 100 And $iHeight >= 100 Then ReDim $aFilteredMonitors[$iFilteredCount + 1][5] $aFilteredMonitors[$iFilteredCount][0] = $hMonitor ; handle $aFilteredMonitors[$iFilteredCount][1] = $iLeft ; left $aFilteredMonitors[$iFilteredCount][2] = $iTop ; top $aFilteredMonitors[$iFilteredCount][3] = $iWidth ; width $aFilteredMonitors[$iFilteredCount][4] = $iHeight ; height ; Check if this is the primary monitor If $aMonitorInfo[2] = 1 Then ; Primary flag $iPrimaryMonitorIndex = $iFilteredCount EndIf $iFilteredCount += 1 EndIf Next ; Store primary monitor index in the first element for easy access Local $aResult[2] $aResult[0] = $aFilteredMonitors $aResult[1] = $iPrimaryMonitorIndex Return $aResult EndFunc ; #FUNCTION# ==================================================================================================================== ; Description ...: Create a sample GUI on a specific monitor ; Parameters ....: See CreateGUIOnMonitor ; Return values .: None ; Author ........: LWC <https://lior.weissbrod.com> ; Modified ......: ; ================================================================================================================== Func sampleGUICreateOnMonitor($iMonitorNumber, $iCreate, $sTitle, $iWidth = 0, $iHeight = 0, $oLeft = 0, $oTop = 0, $iStyle = "", $iExStyle = "", $iParent = "") Local $hGUI = GUICreateOnMonitor($iMonitorNumber, $iCreate, $sTitle, $iWidth, $iHeight, $oLeft, $oTop, $iStyle, $iExStyle, $iParent) if $hGUI <> 0 then GUISetState(@SW_SHOW, $hGUI) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($hGUI) ExitLoop EndSwitch WEnd EndIf EndFunc ; sampleGUICreateOnMonitor(1, True, "Sample GUI", 400, 300, "center", "center") ; sampleGUICreateOnMonitor(1, True, "Sample GUI", "max", "max") -
By default, embedding other controls in my status bar is not provided. But some thoughts on this: The function "_StatusbarCreate" returns an array that contains, among other things, the IDs of all parts. The ID can be used to query the part's rectangle. One option would be to hide the original label and overlay it with another control at the determined position. Some optical corrections may still be necessary to achieve a uniform appearance. That is the solution I would choose. Good luck with your attempts.
-
Does AutoIt support the special ‘This’ keyword
TwoCanoe replied to TwoCanoe's topic in AutoIt General Help and Support
You are absolutely right Nine. I didn't realize that the control ID could be used like that. Thanks again Nine. Amended, working example: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("{Esc}", "Terminate") Local $gShowChild = False Local $gForm1, $gButton1, $gButton2, $gButton3, $gButton4, $gButton5, $gButton6, $gButton7, $gButton8, $gButton9 StartGUI() ; Main GUI Func StartGUI() Local $GuiW = 260 Local $GuiH = 260 Local $GuiX = @DesktopWidth/2 - $GuiW/2 Local $GuiY = @DesktopHeight/2 - $GuiH/2 $gForm1 = GUICreate("Transparent Test", $GuiW, $GuiH, $GuiX, $GuiY) $gButton1 = GUICtrlCreateButton("1", 20, 20, 60, 60) $gButton2 = GUICtrlCreateButton("2", 100, 20, 60, 60) $gButton3 = GUICtrlCreateButton("3", 180, 20, 60, 60) $gButton4 = GUICtrlCreateButton("4", 20, 100, 60, 60) $gButton5 = GUICtrlCreateButton("5", 100, 100, 60, 60) $gButton6 = GUICtrlCreateButton("6", 180, 100, 60, 60) $gButton7 = GUICtrlCreateButton("7", 20, 180, 60, 60) $gButton8 = GUICtrlCreateButton("8", 100, 180, 60, 60) $gButton9 = GUICtrlCreateButton("9", 180, 180, 60, 60) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $gButton1 To $gButton9 ShowInfo($iMsg) ; CHANGED HERE Case $GUI_EVENT_MINIMIZE, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($gForm1) EndFunc ; Child GUI Func ShowInfo($controlID) $gShowChild = True Local $Pos = ControlGetPos($gForm1, "", $controlID) Local $GuiX = $Pos[0] Local $GuiY = $Pos[1] Local $GuiW = 235 Local $GuiH = 125 Local $info = GUICtrlRead($controlID) $gForm2 = GUICreate("Show Info: " & $info, $GuiW, $GuiH, $GuiX, $GuiY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gForm1) GUISetBkColor(0xABCDEF); $gBordersLabel = GUICtrlCreateLabel("", 0, 0, $GuiW, $GuiH) GUICtrlSetBkColor(-1, 0x44BB00) GUICtrlSetState(-1, $GUI_DISABLE) $gTransLabel1 = GUICtrlCreateLabel("", 60, 0, 180, 55) ; Upper right transparency GUICtrlSetBkColor(-1, 0xABCDEF) $gTransLabel2 = GUICtrlCreateLabel("", 0, 60, 55, 140) ; Lower left transparency GUICtrlSetBkColor(-1, 0xABCDEF) $gTransLabel3 = GUICtrlCreateLabel("", 5, 5, 50, 50) ; Target button transparency GUICtrlSetBkColor(-1, 0xABCDEF) GUICtrlSetState(-1, $GUI_DISABLE) $gBackground = GUICtrlCreateLabel("", 60, 60, 170, 60) GUICtrlSetBkColor(-1, 0x444444) GUICtrlSetState(-1, $GUI_DISABLE) $gLabelInfo = GUICtrlCreateLabel("Button Pressed: " & $info, 70, 70, 100, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0x444444) GUICtrlSetColor(-1, 0x88FF00) $gLabelOK = GUICtrlCreateLabel("OK", 180, 70, 40, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; Using a label, a button causes transparency issues GUICtrlSetBkColor(-1, 0xDDDDDD) _WinAPI_SetLayeredWindowAttributes($gForm2, 0xABCDEF, 255) GUISetState(@SW_SHOW) While $gShowChild If Not WinActive($gForm2) Then ExitLoop ; 1. Allows click on other main GUI buttons, 2. Deletes the child window if main GUI is not active Switch GUIGetMsg() Case $gLabelOK ExitLoop EndSwitch Wend $gShowChild = False GUIDelete($gForm2) EndFunc Func Terminate() If $gShowChild = True Then $gShowChild = False Else Exit EndIf EndFunc -
Does AutoIt support the special ‘This’ keyword
Nine replied to TwoCanoe's topic in AutoIt General Help and Support
Don't use that eval approach, there is absolutely no reason for doing so. Just use the control id, and you will be fine. By using the eval you are returning a string which will not work with GUICtrlRead (or any GUICtrl* functions). Control* functions will work perfectly well with the ID. -
Does AutoIt support the special ‘This’ keyword
TwoCanoe replied to TwoCanoe's topic in AutoIt General Help and Support
Thanks for the reply Nine. You might be on the right track. Your example returns a number for each button. I guess it is a GUI id number. Though the numbers are consistent so maybe usable. Possibly using Eval() in the child script (?): #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("{Esc}", "Terminate") Local $gShowChild = False Local $gForm1, $gButton1, $gButton2, $gButton3, $gButton4, $gButton5, $gButton6, $gButton7, $gButton8, $gButton9 StartGUI() ; Main GUI Func StartGUI() Local $GuiW = 260 Local $GuiH = 260 Local $GuiX = @DesktopWidth/2 - $GuiW/2 Local $GuiY = @DesktopHeight/2 - $GuiH/2 $gForm1 = GUICreate("Transparent Test", $GuiW, $GuiH, $GuiX, $GuiY) $gButton1 = GUICtrlCreateButton("1", 20, 20, 60, 60) $gButton2 = GUICtrlCreateButton("2", 100, 20, 60, 60) $gButton3 = GUICtrlCreateButton("3", 180, 20, 60, 60) $gButton4 = GUICtrlCreateButton("4", 20, 100, 60, 60) $gButton5 = GUICtrlCreateButton("5", 100, 100, 60, 60) $gButton6 = GUICtrlCreateButton("6", 180, 100, 60, 60) $gButton7 = GUICtrlCreateButton("7", 20, 180, 60, 60) $gButton8 = GUICtrlCreateButton("8", 100, 180, 60, 60) $gButton9 = GUICtrlCreateButton("9", 180, 180, 60, 60) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() ; CHANGED HERE Switch $iMsg ; CHANGED HERE Case $gButton1 To $gButton9 ; CHANGED HERE ShowInfo("$gButton" & string($iMsg -2)) ; CHANGED HERE Case $GUI_EVENT_MINIMIZE, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($gForm1) EndFunc ; Child GUI Func ShowInfo($control) Local $evalControl = Eval($control) $gShowChild = True Local $Pos = ControlGetPos($gForm1, "", $evalControl) ; CHANGED HERE - Works Local $GuiX = $Pos[0] Local $GuiY = $Pos[1] Local $GuiW = 235 Local $GuiH = 125 Local $info = GUICtrlRead($evalControl) ; CHANGED HERE - Does not work! $gForm2 = GUICreate("Show Info: " & $info, $GuiW, $GuiH, $GuiX, $GuiY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gForm1) GUISetBkColor(0xABCDEF); $gBordersLabel = GUICtrlCreateLabel("", 0, 0, $GuiW, $GuiH) GUICtrlSetBkColor(-1, 0x44BB00) GUICtrlSetState(-1, $GUI_DISABLE) $gTransLabel1 = GUICtrlCreateLabel("", 60, 0, 180, 55) ; Upper right transparency GUICtrlSetBkColor(-1, 0xABCDEF) $gTransLabel2 = GUICtrlCreateLabel("", 0, 60, 55, 140) ; Lower left transparency GUICtrlSetBkColor(-1, 0xABCDEF) $gTransLabel3 = GUICtrlCreateLabel("", 5, 5, 50, 50) ; Target button transparency GUICtrlSetBkColor(-1, 0xABCDEF) GUICtrlSetState(-1, $GUI_DISABLE) $gBackground = GUICtrlCreateLabel("", 60, 60, 170, 60) GUICtrlSetBkColor(-1, 0x444444) GUICtrlSetState(-1, $GUI_DISABLE) $gLabelInfo = GUICtrlCreateLabel("Button Pressed: " & $info, 70, 70, 100, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0x444444) GUICtrlSetColor(-1, 0x88FF00) $gLabelOK = GUICtrlCreateLabel("OK", 180, 70, 40, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; Using a label, a button causes transparency issues GUICtrlSetBkColor(-1, 0xDDDDDD) _WinAPI_SetLayeredWindowAttributes($gForm2, 0xABCDEF, 255) GUISetState(@SW_SHOW) While $gShowChild If Not WinActive($gForm2) Then ExitLoop ; 1. Allows click on other main GUI buttons, 2. Deletes the child window if main GUI is not active Switch GUIGetMsg() Case $gLabelOK ExitLoop EndSwitch Wend $gShowChild = False GUIDelete($gForm2) EndFunc Func Terminate() If $gShowChild = True Then $gShowChild = False Else Exit EndIf EndFunc Line 56 works, but line 62 does not. I'll keep playing and see what happens. Will post any improvements. -
Does AutoIt support the special ‘This’ keyword
Nine replied to TwoCanoe's topic in AutoIt General Help and Support
Not directly, but this : #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> StartGUI() ; Main GUI Func StartGUI() Local $gForm1, $gButton1, $gButton2, $gButton3, $gButton4, $gButton5, $gButton6, $gButton7, $gButton8, $gButton9 Local $GuiW = 260 Local $GuiH = 260 Local $GuiX = @DesktopWidth / 2 - $GuiW / 2 Local $GuiY = @DesktopHeight / 2 - $GuiH / 2 $gForm1 = GUICreate("Transparent Test", $GuiW, $GuiH, $GuiX, $GuiY) $gButton1 = GUICtrlCreateButton("1", 20, 20, 60, 60) $gButton2 = GUICtrlCreateButton("2", 100, 20, 60, 60) $gButton3 = GUICtrlCreateButton("3", 180, 20, 60, 60) $gButton4 = GUICtrlCreateButton("4", 20, 100, 60, 60) $gButton5 = GUICtrlCreateButton("5", 100, 100, 60, 60) $gButton6 = GUICtrlCreateButton("6", 180, 100, 60, 60) $gButton7 = GUICtrlCreateButton("7", 20, 180, 60, 60) $gButton8 = GUICtrlCreateButton("8", 100, 180, 60, 60) $gButton9 = GUICtrlCreateButton("9", 180, 180, 60, 60) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Switch $iMsg Case $gButton1 To $gButton9 ShowInfo($iMsg) ; is ShowInfo(This) possible? Case $GUI_EVENT_MINIMIZE, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($gForm1) EndFunc ;==>StartGUI ; Child GUI Func ShowInfo($control) ConsoleWrite($control & @CRLF) EndFunc ;==>ShowInfo -
Hello To further explain what I mean: Here’s an example of the This keyword in javascript: https://www.w3schools.com/js/js_this.asp And an example of the This keyword in C#: https://www.geeksforgeeks.org/c-sharp/c-sharp-this-keyword/ I haven’t encountered this type of inheritance so far, using AutoIt scripting. Here is an example script: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> HotKeySet("{Esc}", "Terminate") Local $gShowChild = False Local $gForm1, $gButton1, $gButton2, $gButton3, $gButton4, $gButton5, $gButton6, $gButton7, $gButton8, $gButton9 StartGUI() ; Main GUI Func StartGUI() Local $GuiW = 260 Local $GuiH = 260 Local $GuiX = @DesktopWidth/2 - $GuiW/2 Local $GuiY = @DesktopHeight/2 - $GuiH/2 $gForm1 = GUICreate("Transparent Test", $GuiW, $GuiH, $GuiX, $GuiY) $gButton1 = GUICtrlCreateButton("1", 20, 20, 60, 60) $gButton2 = GUICtrlCreateButton("2", 100, 20, 60, 60) $gButton3 = GUICtrlCreateButton("3", 180, 20, 60, 60) $gButton4 = GUICtrlCreateButton("4", 20, 100, 60, 60) $gButton5 = GUICtrlCreateButton("5", 100, 100, 60, 60) $gButton6 = GUICtrlCreateButton("6", 180, 100, 60, 60) $gButton7 = GUICtrlCreateButton("7", 20, 180, 60, 60) $gButton8 = GUICtrlCreateButton("8", 100, 180, 60, 60) $gButton9 = GUICtrlCreateButton("9", 180, 180, 60, 60) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $gButton1 ShowInfo($gButton1) ; is ShowInfo(This) possible? Case $gButton2 ShowInfo($gButton2) ; is ShowInfo(This) possible? Case $gButton3 ShowInfo($gButton3) ; is ShowInfo(This) possible? Case $gButton4 ShowInfo($gButton4) ; is ShowInfo(This) possible? Case $gButton5 ShowInfo($gButton5) ; is ShowInfo(This) possible? Case $gButton6 ShowInfo($gButton6) ; is ShowInfo(This) possible? Case $gButton7 ShowInfo($gButton7) ; is ShowInfo(This) possible? Case $gButton8 ShowInfo($gButton8) ; is ShowInfo(This) possible? Case $gButton9 ShowInfo($gButton9) ; is ShowInfo(This) possible? Case $GUI_EVENT_MINIMIZE, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($gForm1) EndFunc ; Child GUI Func ShowInfo($control) $gShowChild = True Local $Pos = ControlGetPos($gForm1, "", $control) ; Get position of button pressed Local $GuiX = $Pos[0] Local $GuiY = $Pos[1] Local $GuiW = 235 Local $GuiH = 125 Local $info = GUICtrlRead($control) $gForm2 = GUICreate("Show Info: " & $info, $GuiW, $GuiH, $GuiX, $GuiY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gForm1) GUISetBkColor(0xABCDEF); $gBordersLabel = GUICtrlCreateLabel("", 0, 0, $GuiW, $GuiH) GUICtrlSetBkColor(-1, 0x44BB00) GUICtrlSetState(-1, $GUI_DISABLE) $gTransLabel1 = GUICtrlCreateLabel("", 60, 0, 180, 55) ; Upper right transparency GUICtrlSetBkColor(-1, 0xABCDEF) $gTransLabel2 = GUICtrlCreateLabel("", 0, 60, 55, 140) ; Lower left transparency GUICtrlSetBkColor(-1, 0xABCDEF) $gTransLabel3 = GUICtrlCreateLabel("", 5, 5, 50, 50) ; Target button transparency GUICtrlSetBkColor(-1, 0xABCDEF) GUICtrlSetState(-1, $GUI_DISABLE) $gBackground = GUICtrlCreateLabel("", 60, 60, 170, 60) GUICtrlSetBkColor(-1, 0x444444) GUICtrlSetState(-1, $GUI_DISABLE) $gLabelInfo = GUICtrlCreateLabel("Button Pressed: " & $info, 70, 70, 100, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0x444444) GUICtrlSetColor(-1, 0x88FF00) $gLabelOK = GUICtrlCreateLabel("OK", 180, 70, 40, 40, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; Using a label, a button causes transparency issues GUICtrlSetBkColor(-1, 0xDDDDDD) _WinAPI_SetLayeredWindowAttributes($gForm2, 0xABCDEF, 255) GUISetState(@SW_SHOW) While $gShowChild If Not WinActive($gForm2) Then ExitLoop ; 1. Allows click on other main GUI buttons, 2. Deletes the child window if main GUI is not active Switch GUIGetMsg() Case $gLabelOK ExitLoop EndSwitch Wend $gShowChild = False GUIDelete($gForm2) EndFunc Func Terminate() If $gShowChild = True Then $gShowChild = False Else Exit EndIf EndFunc If ShowInfo(This) isn’t possible, is there another way?
-
AutoIt's UDF are so many that at times I learn that something is there only after I reinvent the function 😅 Anywayz, is not a bad idea to have a function to dig into an OS version and for that ns-winnt-osversioninfoexw is a good start. To share the data collected would be simpler to have it in text to copy and paste to the forum. And to do that I modded _WinAPI_DisplayStruct() here. With this we can compile future versions of the ever growing way of determining what OS is running.
-
The idea is to be able to share information in the forum when a struct data needs to be shared among us. As an example, lets say that we wanna share what comes out of $tagOSVERSIONINFOEX. We could just run: #include <WinAPIMisc.au3> #include <WinAPIDiag.au3> #include <Debug.au3> #include <Sqlite.au3> Exit GetOs() Func GetOs() Local $tOSVERSIONINFOEX = DllStructCreate($tagOSVERSIONINFOEX) DllStructSetData($tOSVERSIONINFOEX, 1, DllStructGetSize($tOSVERSIONINFOEX)) Local $aCall = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVERSIONINFOEX) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Local $aArray = _WinAPI_DisplayStruct_mod($tOSVERSIONINFOEX, $tagOSVERSIONINFOEX, '', 0, 0, 0, True, 0, 1) Local $sText = _SQLite_Display2DResult($aArray, 0, True) ConsoleWrite(@CRLF & $sText & @CRLF & @CRLF) ; for those outside the editor Local $iW = 600, $iH = 300, $hGui = GUICreate(@ScriptName, $iW, $iH) GUISetFont(10, 400, 0, "Terminal") Local $idEdit = GUICtrlCreateEdit($sText, 0, 0, $iW, $iH) GUISetState() While GUIGetMsg() <> -3 WEnd GUIDelete($hGui) EndFunc ;==>GetOs ... ... and share the text that comes out: - - 0x0125DC18 <struct> 0 - 1 OSVersionInfoSize 0 DWORD 4 284 2 MajorVersion 4 DWORD 4 10 3 MinorVersion 8 DWORD 4 0 4 BuildNumber 12 DWORD 4 22631 5 PlatformId 16 DWORD 4 2 6 CSDVersion 20 WCHAR[128] 256 7 ServicePackMajor 276 USHORT 2 0 8 ServicePackMinor 278 USHORT 2 0 9 SuiteMask 280 USHORT 2 256 10 ProductType 282 BYTE 1 1 11 Reserved 283 BYTE 1 - - - 0x0125DD34 <endstruct> 284 - So the mod. I made to _WinAPI_DisplayStruct() is here ( with the complete running example from above ) This way is easier to share such. I know this is a lazy way to do it but, is a fast mod. and does what is needed to get the data as text.
-
plplp889 joined the community
-
Many thanks for the update! Very much appreciate all work people put into making Autoit great 👍 Just wondering of there's been any time spent looking at the built in callback functions, like DllCallbackRegister(). Apologies if I'm wrong, but my understanding is that Autoit's built in callback setup suffers from reentrancy, which can cause the main thread to crash. This post here raises the issue: There is an old 32bit dllcallback function on this forum that doesn't suffer this issue, I believe it's due to the critical section setup. This for me working great, but limited to 32bit. KR Jardz
- Last week
-
Move window behind desktop icons
Parsix replied to Parsix's topic in AutoIt General Help and Support
Thanks you The problem still persists. ☹️ Tested on Windows 10 Enterprise 22H2 19045.3324 and newer -
In autoit.de a user said that if the script was closed from the tray, something lingered and did not close the process. This was the example he gave: #include <Array.au3> Local $a[1] _ArrayDisplay($a) Looked into it and this is the fix I propose: ... ; Switch to GetMessage mode Local $iOnEventMode = Opt("GUIOnEventMode", 0), $aMsg ConsoleWrite("__ArrayDisplay_Share() loadded in: " & TimerDiff($hRetTimer) & @CRLF) __ArrayDisplay_OnExit_CleanUp(1, $hGUI, $iCoordMode, $iOnEventMode, $_iCallerError, $_iCallerExtended, $p__ArrayDisplay_NotifyHandler) ) ; add this OnAutoItExitRegister(__ArrayDisplay_OnExit_CleanUp) ; add this ... ; Pass array and selection to user function $hUser_Function($_g_ArrayDisplay_aArray, $aiSelItems) $_g_ArrayDisplay_bUserFunc = False OnAutoItExitUnRegister(__ArrayDisplay_OnExit_CleanUp) ; add this ... #EndRegion GUI Handling events OnAutoItExitUnRegister(__ArrayDisplay_OnExit_CleanUp) ; add this __ArrayDisplay_CleanUp($hGUI, $iCoordMode, $iOnEventMode, $_iCallerError, $_iCallerExtended, $p__ArrayDisplay_NotifyHandler) ... Func __ArrayDisplay_OnExit_CleanUp($iInit = 1, $hGUI = "", $iCoordMode = "", $iOnEventMode = "", $_iCallerError = "", $_iCallerExtended = "", $p__ArrayDisplay_NotifyHandler = "") #forceref $iInit Local Static $Saved_hGUI = $hGUI, _ $Saved_iCoordMode = $iCoordMode, _ $Saved_iOnEventMode = $iOnEventMode, _ $Saved__iCallerError = $_iCallerError, _ $Saved__iCallerExtended = $_iCallerExtended, _ $Saved_p__ArrayDisplay_NotifyHandler = $p__ArrayDisplay_NotifyHandler ;~ ConsoleWrite(@CRLF & 'Int(Execute("$iInit")) = ' & Int(Execute("$iInit")) & @CRLF) If Int(Execute("$iInit")) == 0 Then ;~ ConsoleWrite(@CRLF & "--- __ArrayDisplay_OnExit_CleanUp() = " & IsHWnd($Saved_hGUI) & @CRLF) __ArrayDisplay_CleanUp($Saved_hGUI, $Saved_iCoordMode, $Saved_iOnEventMode, $Saved__iCallerError, $Saved__iCallerExtended, $Saved_p__ArrayDisplay_NotifyHandler) EndIf EndFunc I will not push it to SVN so if anyone can do it, thanks
-
autopilot5000 joined the community
-
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; Dec, Int, Number Constants Global Const $NUMBER_AUTO = 0 Global Const $NUMBER_32BIT = 1 Global Const $NUMBER_64BIT = 2 Global Const $NUMBER_DOUBLE = 3 ;~ Global Const $tagOSVERSIONINFO = "struct;dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;" & _ ;~ "dword dwBuildNumber;dword dwPlatformId;wchar szCSDVersion[128];endstruct" Global Const $tagOSVERSIONINFO = "struct;DWORD dwOSVersionInfoSize;DWORD dwMajorVersion;DWORD dwMinorVersion;" & _ "DWORD dwBuildNumber;DWORD dwPlatformId;WCHAR szCSDVersion[128];" & _ "WORD wServicePackMajor;WORD wServicePackMinor;WORD wSuiteMask;BYTE wProductType;BYTE wReserved;endstruct" Global $sInformation = "===========================" & @CRLF & _ "AutoIt version: " & @AutoItVersion & @CRLF & _ "Windows version: " & _WinAPI_GetVersion() & " - " & " Build: " & @extended & @CRLF & _ "@OSVersion: " & @OSVersion & @CRLF & _ "@OSType: " & @OSType & @CRLF & _ "===========================" & @CRLF ConsoleWrite($sInformation & @CRLF) ClipPut($sInformation) MsgBox(262144 + 64, @ScriptName, $sInformation, 300) Func _WinAPI_GetVersion() ; wProductType enum ; https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexw Local Enum $VER_NT_NoClue, $VER_NT_WORKSTATION, $VER_NT_DOMAIN_CONTROLLER, $VER_NT_SERVER Local $aProductType[5] = ["VER_NT_NoClue", "VER_NT_WORKSTATION", "VER_NT_DOMAIN_CONTROLLER", "VER_NT_SERVER"] Local $tOSVI = DllStructCreate($tagOSVERSIONINFO) DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $aCall = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) ConsoleWrite("dwPlatformId: " & DllStructGetData($tOSVI, "dwPlatformId") & @CRLF) ; note: The operating system platform. This member can be VER_PLATFORM_WIN32_NT (2). ConsoleWrite("wProductType: " & DllStructGetData($tOSVI, "wProductType") & _ " = " & $aProductType[Int(DllStructGetData($tOSVI, "wProductType"))] & @CRLF) ; <<<< ;~ MsgBox(0, "OSVERSIONINFO", "MajorVersion = " & DllStructGetData($tOSVI, "MajorVersion") & @CRLF & _ ;~ "MinorVersion = " & DllStructGetData($tOSVI, "MinorVersion") & @CRLF & _ ;~ "BuildNumber = " & DllStructGetData($tOSVI, "BuildNumber")) Return SetError(0, Number(DllStructGetData($tOSVI, "dwBuildNumber")), Number(DllStructGetData($tOSVI, "dwMajorVersion") & "." & DllStructGetData($tOSVI, "MinorVersion"), $NUMBER_DOUBLE)) EndFunc ;==>_WinAPI_GetVersion ... I guess it'll need a table to tell what is v10 that is not Win10 ? ...win32/sysinfo/getting-the-system-version ( they should have done better than this ) in .../windows-server-release-info the "LastBuild" should be the table for the newer servers. Actually, .../wiki/List_of_Microsoft_Windows_versions has a complete table.
-
maybe something like: OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION ?
-
Windows Server 2025 Standard 24H2 - 26100.1742 =========================== AutoIt version: 3.3.17.1 Windows version: 10 - Build: 26100 @OSVersion: WIN_2022 @OSType: WIN32_NT =========================== Windows Server 2025 Standard 24H2 - 26100.4349 =========================== AutoIt version: 3.3.17.1 Windows version: 10 - Build: 26100 @OSVersion: WIN_2022 @OSType: WIN32_NT =========================== Installed Server 2025 in VMs. These are the results of the 1st ISO and the updated to "June 2025"
-
Help File/Documentation Issues. (Discussion Only)
guinness replied to guinness's topic in AutoIt Technical Discussion
Thanks @pixelsearch. Indeed I double checked and it seems this constant was missing from the list. I have fixed it now. -
Help File/Documentation Issues. (Discussion Only)
pixelsearch replied to guinness's topic in AutoIt Technical Discussion
@guinness is here, such great news. Thanks for your incredible participation in AutoIt Yesterday I found that something important was also missing in the help file (as stated in this post) . Please let me paste it here as that's the place to be : Thanks if you can fix it too. -
@jpm maybe the same way like here: https://www.autoitscript.com/trac/autoit/ticket/3849#comment:2 @rikthhpgf2005 please use this script to post here result as text ; Dec, Int, Number Constants Global Const $NUMBER_AUTO = 0 Global Const $NUMBER_32BIT = 1 Global Const $NUMBER_64BIT = 2 Global Const $NUMBER_DOUBLE = 3 Global Const $tagOSVERSIONINFO = 'struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct' ConsoleWrite('Windows version: ' & _WinAPI_GetVersion() & @CRLF) Func _WinAPI_GetVersion() Local $tOSVI = DllStructCreate($tagOSVERSIONINFO) DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $aCall = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) MsgBox(0, "OSVERSIONINFO", "MajorVersion = " & DllStructGetData($tOSVI, "MajorVersion") & @CRLF & _ "MinorVersion = " & DllStructGetData($tOSVI, "MinorVersion") & @CRLF & _ "BuildNumber = " & DllStructGetData($tOSVI, "BuildNumber")) Return Number(DllStructGetData($tOSVI, "MajorVersion") & "." & DllStructGetData($tOSVI, "MinorVersion"), $NUMBER_DOUBLE) EndFunc ;==>_WinAPI_GetVersion or even this one: #AutoIt3Wrapper_Change2CUI=y ; Dec, Int, Number Constants Global Const $NUMBER_AUTO = 0 Global Const $NUMBER_32BIT = 1 Global Const $NUMBER_64BIT = 2 Global Const $NUMBER_DOUBLE = 3 Global Const $tagOSVERSIONINFO = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct" Global $sInformation = _ "AutoIt version: " & @AutoItVersion & @CRLF & _ "Windows version: " & _WinAPI_GetVersion() & @CRLF & " Build: " & @extended & @CRLF & _ "@OSVersion: " & @OSVersion & @CRLF & _ "@OSType: " & @OSType & @CRLF & _ "" ConsoleWrite($sInformation & @CRLF) ClipPut($sInformation) Func _WinAPI_GetVersion() Local $tOSVI = DllStructCreate($tagOSVERSIONINFO) DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $aCall = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) MsgBox(0, "OSVERSIONINFO", "MajorVersion = " & DllStructGetData($tOSVI, "MajorVersion") & @CRLF & _ "MinorVersion = " & DllStructGetData($tOSVI, "MinorVersion") & @CRLF & _ "BuildNumber = " & DllStructGetData($tOSVI, "BuildNumber")) Return SetError(0, Number(DllStructGetData($tOSVI, "BuildNumber")), Number(DllStructGetData($tOSVI, "MajorVersion") & "." & DllStructGetData($tOSVI, "MinorVersion"), $NUMBER_DOUBLE)) EndFunc ;==>_WinAPI_GetVersion
-
Your UDF is a nice option. Thanks for letting me know about it because I was not aware. It deserves more attention. By the way, is it possible to obtain a position on each of the parts? The reason why I ask is because I would like to be able to swap one or two of the parts with an input or combo control.