All Activity
- Past hour
-
Nine, May I ask why the last MouseClick should be succeeded by a Sleep?
-
mr-es335 reacted to a post in a topic:
Delayed MouseClick()
- Today
-
No, but... Your last MouseClick is not followed by a Sleep. Probably the reason.
-
RichardL reacted to a post in a topic:
SciTE on Windows 11 Doesn't have Alt-Space Menu
-
Avoid "AutoIt Error" message box in unknown errors
Jos replied to EKY32's topic in AutoIt General Help and Support
Is this a fact or your guess as I don't see any proof during my quick scan of this thread, or did I miss that? -
Avoid "AutoIt Error" message box in unknown errors
Jos replied to EKY32's topic in AutoIt General Help and Support
Sorry, hadn't seen this one as I was avoiding this topic after seeing only questions and no clear answers! Anyway, no idea what you are asking me, as I do not know what "doesn't work" means and am too lazy to start trying to sort out what it could mean! 😉 -
Good day, I have been unable to obtain an answer to my query regarding the MouseClick() function. Two examples may be beneficial here: #cs The following example WILL produce an error wherein the inital command IS NEVER completed successfully! #ce ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example1() ; ----------------------------------------------- Func Example1() MouseClick($MOUSE_CLICK_LEFT, 684, 112, 1, 0) Sleep($iTimeOut) Send("{ALTDOWN}") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 486, 112, 1, 0) Sleep($iTimeOut) Send("{ALTUP}") Sleep($iTimeOut) Send("I") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 160, 1, 1) EndFunc ;==>Example1 ; ----------------------------------------------- ============================================ #cs The following example will NOT produce an error wherein the inital command IS completed successfully! #ce ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iTimeOut = 100 ; ----------------------------------------------- Example2() ; ----------------------------------------------- Func Example2() Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 684, 112, 1, 0) Sleep($iTimeOut) Send("{ALTDOWN}") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 486, 112, 1, 0) Sleep($iTimeOut) Send("{ALTUP}") Sleep($iTimeOut) Send("I") Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 160, 1, 1) EndFunc ;==>Example2 ; ----------------------------------------------- My question is, "Is a pause generally required prior to the execution of a MouseClick() function?" What is even "odder" to me is that I often have to execute scripts more-than-once in order to obtain the results that are required!?! "Why?" As always...any assistance in this matter would be greatly appreciated! Thank you all for your time!
-
Avoid "AutoIt Error" message box in unknown errors
mLipok replied to EKY32's topic in AutoIt General Help and Support
Sitll we are not talking about the fact that AutoIt crashes. We are talking about: Why @trancexx code is not working in 64bit. -
Tony4219 reacted to a post in a topic:
GUICtrlSetResizingEx - Resizing for external elements
-
Avoid "AutoIt Error" message box in unknown errors
argumentum replied to EKY32's topic in AutoIt General Help and Support
https://www.autoitscript.com/forum/topic/154081-avoid-autoit-error-message-box-in-unknown-errors/page/4/#findComment-1547359 -
CYCho reacted to a post in a topic:
Sudden Spike in zPlayer Downloads — Any Idea Why?
-
SciTE on Windows 11 Doesn't have Alt-Space Menu
argumentum replied to RichardL's topic in AutoIt Technical Discussion
You ought to see me pressing Alt + space then C. People see me doing that, and is like am a god or something Maybe Co-Pilot took it ? 🤔 -
argumentum reacted to a post in a topic:
Sudden Spike in zPlayer Downloads — Any Idea Why?
-
Sudden Spike in zPlayer Downloads — Any Idea Why?
Nine replied to CYCho's topic in Developer General Discussion
It was mentioned here how AI bots are intensively hitting the site. I suppose they also grab all the codes they can take... -
SciTE on Windows 11 Doesn't have Alt-Space Menu
WildByDesign replied to RichardL's topic in AutoIt Technical Discussion
It works here with SciTE 5.5.5 (64-bit) on Win11 25H2 also. -
SciTE on Windows 11 Doesn't have Alt-Space Menu
Jos replied to RichardL's topic in AutoIt Technical Discussion
On Win11 Home Alt and the Space work fine for me with SciTE 32 v5.5.6. -
Avoid "AutoIt Error" message box in unknown errors
mLipok replied to EKY32's topic in AutoIt General Help and Support
It was related to using 64bit AutoIt version and using #AutoIt3Wrapper_Au3Stripper_OnError=f instead: #AutoIt3Wrapper_Au3Stripper_OnError=c For this reason, I also tried to ask you to explain why using the following directive with the FORCE parameter: #AutoIt3Wrapper_Au3Stripper_OnError=f warry on the results - I mean changes that compiled version works or not. -
On most/all Windows windows, you press alt then space, and the menu appears. I've been doing that for 20+ years. Now on SciTE and Notepad++ it's not working. The menu letters underline as if I've only pressed alt. On everthing else e.g. Firefox, MS Office, TaskMgr it's alright. I think this is since my PC was changed from W10 to W11 a few weeks ago. Windows 11 Enterprise 24H2. Just tested on another W11 PC, by remote desktop. SciTE has the problem but Notepad++ is normal.
-
Ok, so it's far from perfect - but I've finally thrown everything together for a v1.5 release. It's just as "point in time" upload I guess, because there has been a ton of dev since v1.4. For those following along there shouldn't be too many surprises, we now have: - Added a bunch of libraries that were missing in 1.4. I believe there we a ton of statics interfaces that were missed. - Added _WinRT_SwitchInterface($pObj, $sIID), which is a QueryInterface, and Release call in one. (tidies code quite a lot!) - Added Windows.UI libraries (native XAML libs) - Added WindowsAppSDK v1.8 libraries (WinUI3 libs) - Removed _WinRT_Col* funcs. That was a glorified VectorView wrapper - so just use the IVectorView lib! - Added support for paramatised interfaces. You can also determine PIIDs yourselves if need be. Local $sIID_IVector_1_IAudioEffectDefinition_ = _WinRT_GetParameterizedTypeInstanceIID("Windows.Foundation.Collections.IVector`1<Windows.Media.Effects.IAudioEffectDefinition>") _WinRT_SwitchInterface($pInNode_EffectDefs, $sIID_IVector_1_IAudioEffectDefinition_) -Added support for creating delegates (the "type" param is optional - but some objects won't let you register the delegate without specifying this) Local $pFileCompletedDgt = _WinRT_CreateDelegate("_FileCompleted", "Windows.Foundation.TypedEventHandler`2<Windows.Media.Audio.AudioFileInputNode, Object>") Local $iFileCompletedTkn = IAudioFileInputNode_AddHdlrFileCompleted($pAG_InNode, $pFileCompletedDgt) ;.... IAudioFileInputNode_RemoveHdlrFileCompleted($pAG_InNode, $iFileCompletedTkn) _WinRT_DestroyDelegate($pFileCompletedDgt) ;.... Func _FileCompleted($pThis, $pObj, $pArgs) ConsoleWrite("File Completed" & @CRLF) EndFunc - Updated class explorer And probably a bunch of other things that I've forgotten about over the last year!
-
Hi everyone, I’ve noticed something unusual with my zPlayer files I uploaded in the Downloads section of this forum. Normally, it used to get 1–10 downloads per day, but starting November 11 afternoon, the numbers skyrocketed — over 200 downloads on each of November 12 and 13, and still maintaining that surge. I’m curious if anyone knows what might have triggered this surge. Was it mentioned somewhere, linked in a tutorial, or picked up by a bot? If you’ve seen anything similar or have any ideas, I’d love to hear your thoughts. Thanks in advance! C Y Cho
-
Avoid "AutoIt Error" message box in unknown errors
mLipok replied to EKY32's topic in AutoIt General Help and Support
@Danyfirex my friend. Would you be so kind as to take a look at the code below to see why it requires only the 32-bit version? Perhaps you can create a fix that will allow this code to work in both 32-bit and 64-bit versions. Maybe someone else here also would be able to help with creating an appropriate fix? -
DotNet.au3 UDF to access .NET Framework from AutoIt
haijie1223 replied to LarsJ's topic in AutoIt Example Scripts
good job - Yesterday
-
ROOT-APK joined the community
-
yes it is "DO"-able?? (and the simplest) the only dissonance is Sleep(1) the smallest possible is Sleep(10) Maximum sleep time is 2147483647 milliseconds (24 days) and the minimum is 10 milliseconds. So using 1-9 will automatically default to 10 milliseconds.
-
Hello, PS: I thought that I had submitted this earlier...but it never was not submitted....!!! • iso747, I will look at your recent offerings...thanks...as always!! Is the following "DO"-able?? ; ----------------------------------------------- #include <AutoItConstants.au3> #include <misc.au3> ; ----------------------------------------------- Global $iTimeOut = 100 Global $iX = 711, $iY = 80 ; For F12 ; ----------------------------------------------- UpdateScenesF12($iX, $iY) ; ----------------------------------------------- Func UpdateScenesF12($iX, $iY) ConsoleWrite("UpdateScenes(" & $iX & ", " & $iY & ")" & @CRLF) Local $hSAC_MAIN = "[CLASS:SAC_MAIN]" Local $hSAC_SCENES = "[CLASS:SAC_SCENES]" Local $hSAC_SCENEPROPERTIES = "[CLASS:SAC_SCENEPROPERTIES]" ; ----------------------------------------------- WinActivate($hSAC_MAIN) WinActivate($hSAC_SCENES) ; ----------------------------------------------- ; <<<<==== Script Intervention ====>>>> Send("{End}") ; Select [End Of List] ; ----------------------------------------------- Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 0) ; Select [New], the [Enter Scene Name] dialog is displayed. ; ----------------------------------------------- Send("{CTRLDOWN}") Send("v") ; Enter Scene Name Send("{CTRLUP}") ; ---------------------- Send("{ENTER}") ; Select [Ok], the [Enter Scene Name] dialog is exited ; ...and the [Scene Properties] dialog is displayed ; ----------------------------------------------- Sleep($iTimeOut) WinMove($hSAC_SCENEPROPERTIES, "", $iX, $iY) ; The [Scene Properties] dialog is repositioned ; ----------------------------------------------- Sleep($iTimeOut) MouseMove(1000, 550, 0) ; The mouse is positioned within the [Scene Properties] dialog ; ----------------------------------------------- Do Sleep(1) Until _IsPressed("0D") ; ----------------------------------------------- Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) EndFunc ;==>UpdateScenesF12 ; -----------------------------------------------
-
System Tray Menu Auto-Light/Dark Mode: If your system theme is a light mode theme, it will make the system tray menu light. Dark theme will show dark tray menu. I used to apply dark mode to the system tray menu before by creating a GUI that was never shown. But now I realized that I don't have to create that GUI and simply get the handle for the hidden AutoIt window and apply to that handle. #NoTrayIcon #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> #include <SendMessage.au3> #include <WindowsNotifsConstants.au3> Global $hTray = _GetHwndFromPID(@AutoItPID) Global $bIsDarkMode = _WinAPI_ShouldAppsUseDarkMode() ; DPI Awareness DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("TrayMenuMode", 3) Example() Func Example() ; Create a tray item with the radio item parameter selected. TrayCreateItem("Radio 1", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetState(-1, $TRAY_CHECKED) TrayCreateItem("Radio 2", -1, -1, $TRAY_ITEM_RADIO) TrayCreateItem("Radio 3", -1, -1, $TRAY_ITEM_RADIO) TrayCreateItem("") ; Create a separator line. Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. If $bIsDarkMode Then DarkMode($hTray, True) While 1 Switch TrayGetMsg() Case $idExit ; Exit the loop. ExitLoop EndSwitch WEnd EndFunc ;==>Example ;-------------------------------------------------------------------------------------------------------------------------------- ; https://www.autoitscript.com/forum/topic/211475-darkmode-udf-for-autoits-win32guis/#comment-1530103 ;-------------------------------------------------------------------------------------------------------------------------------- Func DarkMode($hWnd, $bDarkMode = True) ; DarkMode Local Enum $DWMWA_USE_IMMERSIVE_DARK_MODE = (@OSBuild <= 18985) ? 19 : 20 Local $iRet = _WinAPI_DwmSetWindowAttribute_unr($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, $bDarkMode) If Not $iRet Then Return SetError(1, 0, -1) _SetCtrlColorMode($hWnd, $bDarkMode) EndFunc ;==>DarkMode ;-------------------------------------------------------------------------------------------------------------------------------- Func _SetCtrlColorMode($hWnd, $bDarkMode = True, $sName = Default) ; 'Explorer', 'CFD', 'DarkMode_ItemsView', etc. If $sName = Default Then $sName = $bDarkMode ? 'DarkMode_Explorer' : 'Explorer' $bDarkMode = Not Not $bDarkMode ; https://www.vbforums.com/showthread.php?900444-Windows-10-Dark-Mode-amp-VB6-apps If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local Enum $eDefault, $eAllowDark, $eForceDark, $eForceLight, $eMax ; enum PreferredAppMode DllCall('uxtheme.dll', 'bool', 133, 'hwnd', $hWnd, 'bool', $bDarkMode) ; fnAllowDarkModeForWindow = 133 DllCall('uxtheme.dll', 'int', 135, 'int', ($bDarkMode ? $eForceDark : $eForceLight)) ; fnAllowDarkModeForApp = 135 _WinAPI_SetWindowTheme_unr($hWnd, $sName) ; https://www.autoitscript.com/forum/index.php?showtopic=211475&view=findpost&p=1530103 DllCall('uxtheme.dll', 'none', 104) ; fnRefreshImmersiveColorPolicyState = 104 ; not needed ? _SendMessage($hWnd, $WM_THEMECHANGED, 0, 0) ; not needed ? EndFunc ;==>_SetCtrlColorMode ;-------------------------------------------------------------------------------------------------------------------------------- Func _WinAPI_SetWindowTheme_unr($hWnd, $sName = Null, $sList = Null) ; #include <WinAPITheme.au3> ; unthoughtful unrestricting mod. ;Causes a window to use a different set of visual style information than its class normally uses Local $sResult = DllCall('UxTheme.dll', 'long', 'SetWindowTheme', 'hwnd', $hWnd, 'wstr', $sName, 'wstr', $sList) If @error Then Return SetError(@error, @extended, 0) If $sResult[0] Then Return SetError(10, $sResult[0], 0) Return 1 EndFunc ;==>_WinAPI_SetWindowTheme_unr ;-------------------------------------------------------------------------------------------------------------------------------- Func _WinAPI_DwmSetWindowAttribute_unr($hWnd, $iAttribute, $iData) ; #include <WinAPIGdi.au3> ; unthoughtful unrestricting mod. ;Sets the value of the specified attributes for non-client rendering to apply to the window Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, _ 'dword*', $iData, 'dword', 4) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then Return SetError(10, $aCall[0], 0) Return 1 EndFunc ;==>_WinAPI_DwmSetWindowAttribute_unr ;-------------------------------------------------------------------------------------------------------------------------------- Func _WinAPI_ShouldAppsUseDarkMode() Local $fnShouldAppsUseDarkMode = 132 Local $aResult = DllCall('UxTheme.dll', 'bool', $fnShouldAppsUseDarkMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>_WinAPI_ShouldAppsUseDarkMode ;-------------------------------------------------------------------------------------------------------------------------------- ; Function for getting HWND from PID Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Return $hWnd EndFunc ;==>_GetHwndFromPID
-
Hi all, Updated libraries based on the new Version 1.8 of WindowsAppSDK are here. Until now we've been on 1.7.x The v1.8 runtime can be installed from here: (Remembering that we require the x64 version.) A copy of the latest bootstrapper dll is included in the zip - but if you need to manually update it later for whatever reason, it has moved. So you'll now find it here: https://www.nuget.org/packages/Microsoft.WindowsAppSdk.Foundation/ download package (on the right) > extract contents > then you'll find it under .\runtimes\win-x64\native
-
my question is why don't you do it like that? (Unless you want it to wait for you to press enter manually) ; ----------------------------------------------- #include <AutoItConstants.au3> ; ----------------------------------------------- Global $iTimeOut = 100 Global $iX = 711, $iY = 80 ; For F12 ; ----------------------------------------------- UpdateScenesF12($iX, $iY) ; ----------------------------------------------- Func UpdateScenesF12($iX, $iY) ConsoleWrite("UpdateScenes(" & $iX & ", " & $iY & ")" & @CRLF) Local $hSAC_MAIN = "[CLASS:SAC_MAIN]" Local $hSAC_SCENES = "[CLASS:SAC_SCENES]" Local $hSAC_SCENEPROPERTIES = "[CLASS:SAC_SCENEPROPERTIES]" ; ----------------------------------------------- WinActivate($hSAC_MAIN) WinActivate($hSAC_SCENES) ; ----------------------------------------------- ; <<<<==== Script Intervention ====>>>> Send("{End}") ; Select [End Of List] ; ----------------------------------------------- Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 0) ; Select [New], the [Enter Scene Name] dialog is displayed. ; ----------------------------------------------- Send("{CTRLDOWN}") Send("v") ; Enter Scene Name Send("{CTRLUP}") ; ---------------------- ;~ Send("{ENTER}") ; Select [Ok], the [Enter Scene Name] dialog is exited...and the [Scene Properties] dialog is displayed Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) ; Perform mouse click ⚠️ ; ----------------------------------------------- Sleep($iTimeOut) WinMove($hSAC_SCENEPROPERTIES, "", $iX, $iY) ; The [Scene Properties] dialog is repositioned ; ----------------------------------------------- Sleep($iTimeOut) MouseMove(1000, 550, 0) ; The mouse is positioned within the [Scene Properties] dialog EndFunc ;==>UpdateScenesF12 ; ----------------------------------------------- Edit: ; ----------------------------------------------- #include <AutoItConstants.au3> ; ----------------------------------------------- Global $iTimeOut = 100 Global $iX = 711, $iY = 80 ; For F12 ; Set the hotkey for [Enter] to trigger MouseClickAction HotKeySet("{ENTER}", "MouseClickAction") ; ----------------------------------------------- UpdateScenesF12($iX, $iY) ; ----------------------------------------------- Func UpdateScenesF12($iX, $iY) ; Various script stuff ; ----------------------------------------------- ; When [ENTER] is selected [for the [OK] button] then ; Wait for [Enter] to be pressed and handled by MouseClickAction While $bActive Sleep(100) ; Keeps the loop alive, waiting for the [Enter] hotkey action WEnd MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) Exit script EndFunc ;==>UpdateScenesF12 ; ----------------------------------------------- Func MouseClickAction() HotKeySet("{ENTER}") ; Disable hotkey to prevent repeated clicks ;~ Send("{ENTER}") ; if you want to deliver the Enter key too MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) ; Perform mouse click $bActive = False ; Exit loop in UpdateScenesF12 EndFunc Or alternately ; ----------------------------------------------- #include <AutoItConstants.au3> ; ----------------------------------------------- Global $iTimeOut = 100 Global $iX = 711, $iY = 80 ; For F12 ; ----------------------------------------------- UpdateScenesF12($iX, $iY) ; ----------------------------------------------- Func UpdateScenesF12($iX, $iY) ; Various script stuff ; ----------------------------------------------- ; When [ENTER] is selected [for the [OK] button] then WinWaitClose("the window that closes the ok") MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) Exit script EndFunc ;==>UpdateScenesF12 ; -----------------------------------------------
-
InputBox string larger than 254 characters?
Nine replied to jimg's topic in AutoIt General Help and Support
It is possible but I am not sure you will like the solution. It requires a bit of additional code, however it's not that complicated. Anyway, here you go : ; From Nine #include <GUIConstants.au3> #include <WinAPI.au3> #include <String.au3> Opt("MustDeclareVars", True) Global Const $HCBT_DESTROYWND = 4 Global $sAnswer, $hHook Example() Func Example() Local $hGUI = GUICreate("Test") Local $idBut = GUICtrlCreateButton("Show", 100, 100, 80, 20) Local $hStub = DllCallbackRegister(WH_CBT, "lresult", "int;wparam;lparam") $hHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hStub), 0, _WinAPI_GetCurrentThreadId()) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBut ClipPut(_StringRepeat("1234567890", 30)) ; for testing longer than 254 characters InputBox("InputBox", "Enter value", "", "", 500, 140) If Not @error Then ConsoleWrite(StringLen($sAnswer) & "/" & $sAnswer & @CRLF) EndIf EndSwitch WEnd _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub) EndFunc ;==>Example Func WH_CBT($nCode, $wParam, $lParam) Local $hWnd = HWnd($wParam) If $nCode = $HCBT_DESTROYWND And _WinAPI_GetClassName($hWnd) = "#32770" And ControlGetHandle($hWnd, "", "Edit1") Then $sAnswer = ControlGetText($hWnd, "", "Edit1") EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>WH_CBT -
ioa747, My apologies, GetKeyPress does not appear work... ; ----------------------------------------------- #include <AutoItConstants.au3> ; ----------------------------------------------- Global $iTimeOut = 100 Global $iX = 711, $iY = 80 ; For F12 ; ----------------------------------------------- UpdateScenesF12($iX, $iY) ; ----------------------------------------------- Func UpdateScenesF12($iX, $iY) ; Various script stuff ; ----------------------------------------------- ; When [ENTER] is selected [for the [OK] button] then ; MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) ; Exit script EndFunc ;==>UpdateScenesF12 ; -----------------------------------------------
-
You may not need to use _IsPressed(): #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; === Create GUI === Global $hGUI = GUICreate("Demo GUI - Handle Enter (WM_COMMAND)", 400, 200) Global $lblName = GUICtrlCreateLabel("Enter your name:", 30, 30, 150, 20) Global $inpName = GUICtrlCreateInput("", 180, 28, 150, 20) Global $btnOK = GUICtrlCreateButton("OK", 50, 100, 80, 30) Global $btnCancel = GUICtrlCreateButton("Cancel", 160, 100, 80, 30) Global $btnAbout = GUICtrlCreateButton("About", 270, 100, 80, 30) GUISetState(@SW_SHOW, $hGUI) ; === Register Windows message handler for WM_COMMAND === GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; === Main loop === While True Local $nMsg = GUIGetMsg() Switch $nMsg ;~ Case $btnOK ;This is not necessary! ;~ Action_OK() ;~ Case $btnCancel;This is not necessary! ;~ Action_Cancel() ;~ Case $btnAbout;This is not necessary! ;~ Action_About() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) Exit ; ========================================================= ; === WM_COMMAND message handler === ; ========================================================= Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $nCtrlID = BitAND($wParam, 0xFFFF) Local $nCode = BitShift($wParam, 16) ; Handle Enter key press (BN_CLICKED / EN_CHANGE etc.) If $nCode = 0 Then Switch $nCtrlID Case $inpName Action_Input() Case $btnOK Action_OK() Case $btnCancel Action_Cancel() Case $btnAbout Action_About() EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ; ========================================================= ; === Action Functions === ; ========================================================= Func Action_Input() Local $sText = StringStripWS(GUICtrlRead($inpName), 3) If $sText = "" Then MsgBox($MB_ICONWARNING, "Warning", "Please enter your name!") GUICtrlSetState($inpName, $GUI_FOCUS) Return EndIf MsgBox($MB_ICONINFORMATION, "Hello", "Hello, " & $sText & "!") EndFunc Func Action_OK() MsgBox($MB_ICONINFORMATION, "OK", "You pressed the OK button or hit Enter on it.") EndFunc Func Action_Cancel() MsgBox($MB_ICONINFORMATION, "Cancel", "You pressed the Cancel button or hit Enter on it.") EndFunc Func Action_About() MsgBox($MB_ICONINFORMATION, "About", "Demo GUI AutoIt") EndFunc