spudw2k Posted August 24, 2020 Posted August 24, 2020 (edited) I have an issue with the live preview not updating to reflect the GUI state. I have a script demo below to illustrate the problem I am having. Symptoms / Behavior 1) Text field is masked when it is not focused 2) If the text field is unmasked when the GUI is minimized, the text field should become masked when GUI is minimized (via WM_ACTIVATE) but the live preview still shows the input field unmasked expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Opt("GUIOnEventMode", 1) Dim $aGUI[1] = ["hwnd|id"] Enum $hGUI = 1, $idInput, $idBtn, $iGUILast ReDim $aGUI[$iGUILast] #Region - UI Creation $aGUI[$hGUI] = GUICreate("Demo", 508, 130, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX)) $aGUI[$idInput] = GUICtrlCreateInput("This will mask when focus is lost", 22, 22, 462, 34, BitOR($SS_CENTER, $ES_PASSWORD)) GUICtrlSetFont(-1, 18, $FW_BOLD, Default, "Consolas") Const $ES_PASSWORDCHAR = GUICtrlSendMsg(-1, $EM_GETPASSWORDCHAR, 0, 0) $aGUI[$idBtn] = GUICtrlCreateButton("Button", 220, 80, 60, 30) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUISetOnEvent($GUI_EVENT_CLOSE, "GUIEvents") #EndRegion - UI Creation Show() GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd #Region - UI Event Functions Func GUIEvents() $iCtrl = @GUI_CtrlId Switch $iCtrl Case $GUI_EVENT_CLOSE Exit EndSwitch EndFunc ;==>GUIEvents Func GUIMinimize() Hide() GUISetState(@SW_MINIMIZE) EndFunc ;==>GUIMinimize Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; LoWord - this gives the control which sent the message Local $iCode = BitShift($wParam, 16) ; HiWord - this gives the message that was sent Switch $iCode Case $EN_SETFOCUS Switch $iIDFrom Case $aGUI[$idInput] Show() EndSwitch Case $EN_KILLFOCUS Switch $iIDFrom Case $aGUI[$idInput] Hide() EndSwitch EndSwitch EndFunc ;==>WM_COMMAND Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam) Local $iCode = BitAND($wParam, 0xFFFF) Switch $hWnd Case $aGUI[$hGUI] Switch $iCode Case 0 ; WA_INACTIVE Hide() EndSwitch EndSwitch EndFunc ;==>WM_ACTIVATE #EndRegion - UI Event Functions #Region - Additonal Functions Func InputboxMask($iCtrl, $bMask = True) Switch $bMask Case False GUICtrlSendMsg($iCtrl, $EM_SETPASSWORDCHAR, 0, 0) Case True GUICtrlSendMsg($iCtrl, $EM_SETPASSWORDCHAR, $ES_PASSWORDCHAR, 0) EndSwitch Local $aRes = DllCall("user32.dll", "int", "RedrawWindow", "hwnd", GUICtrlGetHandle($iCtrl), "ptr", 0, "ptr", 0, "dword", 5) EndFunc ;==>InputboxMask Func Hide() GUICtrlSetState($aGUI[$idBtn], $GUI_FOCUS) InputboxMask($aGUI[$idInput]) EndFunc ;==>Hide Func Show() InputboxMask($aGUI[$idInput], False) EndFunc ;==>Show #EndRegion - Additonal Functions I am hoping either there is a way to intercept the minimize event and handle it on my own after masking the field, or a way to update the thumbnail. Any help would be much appreciated. Edit: I don't have a working solution yet, but it seems that the function below and associated example is a good place for me to explore. _WinAPI_DwmSetIconicLivePreviewBitmap() Edited May 31, 2021 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Solution Nine Posted August 24, 2020 Solution Posted August 24, 2020 This works well for me : expandcollapse popup#include <GUIConstants.au3> #include <Constants.au3> #include <FontConstants.au3> #include <WinAPIGdi.au3> Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) Dim $aGUI[1] = ["hwnd|id"] Enum $hGUI = 1, $idInput, $idBtn, $iGUILast ReDim $aGUI[$iGUILast] #Region - UI Creation $aGUI[$hGUI] = GUICreate("Demo", 508, 130, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX)) $aGUI[$idInput] = GUICtrlCreateInput("This will mask when focus is lost", 22, 22, 462, 34, BitOR($SS_CENTER, $ES_PASSWORD)) GUICtrlSetFont(-1, 18, $FW_BOLD, Default, "Consolas") Const $ES_PASSWORDCHAR = GUICtrlSendMsg(-1, $EM_GETPASSWORDCHAR, 0, 0) $aGUI[$idBtn] = GUICtrlCreateButton("Button", 220, 80, 60, 30) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetOnEvent($GUI_EVENT_CLOSE, GUIEvents) GUISetOnEvent($GUI_EVENT_MINIMIZE, GUIEvents) GUISetOnEvent($GUI_EVENT_RESTORE, GUIEvents) #EndRegion - UI Creation Show() GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd #Region - UI Event Functions Func GUIEvents() $iCtrl = @GUI_CtrlId Switch $iCtrl Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE GUICtrlSendMsg($aGUI[$idInput], $EM_SETSEL, 0, -1) GUISetState(@SW_MINIMIZE) Case $GUI_EVENT_RESTORE GUISetState(@SW_RESTORE) EndSwitch EndFunc ;==>GUIEvents Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; LoWord - this gives the control which sent the message Local $iCode = BitShift($wParam, 16) ; HiWord - this gives the message that was sent Switch $iCode Case $EN_SETFOCUS Switch $iIDFrom Case $aGUI[$idInput] Show() EndSwitch Case $EN_KILLFOCUS Switch $iIDFrom Case $aGUI[$idInput] Hide() EndSwitch EndSwitch return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND #EndRegion - UI Event Functions #Region - Additonal Functions Func InputboxMask($iCtrl, $bMask = True) Switch $bMask Case False GUICtrlSendMsg($iCtrl, $EM_SETPASSWORDCHAR, 0, 0) Case True GUICtrlSendMsg($iCtrl, $EM_SETPASSWORDCHAR, $ES_PASSWORDCHAR, 0) EndSwitch _WinAPI_RedrawWindow($aGUI[$hGUI], 0, 0, $RDW_UPDATENOW) EndFunc ;==>InputboxMask Func Hide() InputboxMask($aGUI[$idInput]) EndFunc ;==>Hide Func Show() InputboxMask($aGUI[$idInput], False) EndFunc ;==>Show #EndRegion - Additonal Functions “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
spudw2k Posted August 25, 2020 Author Posted August 25, 2020 @Nine Interesting. Seems that the GUIEventOptions option is the key. Thank you. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Nine Posted August 25, 2020 Posted August 25, 2020 17 minutes ago, spudw2k said: Seems that the GUIEventOptions option is the key. Not quite. GUICtrlSendMsg($aGUI[$idInput], $EM_SETSEL, 0, -1) is the key. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
spudw2k Posted August 25, 2020 Author Posted August 25, 2020 22 hours ago, Nine said: Not quite. GUICtrlSendMsg($aGUI[$idInput], $EM_SETSEL, 0, -1) is the key. Not for my purposes necessarily. I just needed a way to handle the minimize event, so the GUIEventOptions allowed me to do that (in combination with registering the Minimize and Restore events)...unless I am missing something? Regardless, you led me to a solution to my problem, and I thank you for that. I may still play around with the DWM Live Preview stuff in the future--could come in handy. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now