Wingens Posted August 19, 2019 Share Posted August 19, 2019 Hi I am trying to create a GUI at wich turns the input field yellow when the cursor/focus is on it. So the users instandly sees where they are typing. Right now I am stuck with this code, it get's the focus but it does not change the input background color. Hope you guys can help me. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <array.au3> #include <GuiListView.au3> #include <Misc.au3> #include <ColorConstants.au3> #include <GUIComboBox.au3> Global $VERSION = "2.0.0 | Build: 20819" $INLOGGUI = GUICreate($VERSION & " - Inloggen", 332, 342, -1, -1, $WS_POPUPWINDOW) $BG = GUICtrlCreatePic(@ScriptDir & '\Images\LoginBG.BMP', 0, 0, 332, 342) $TITEL = GUICtrlCreateLabel("Inloggen", 0, 40, 332, 30, $ES_CENTER) GUICtrlSetFont(-1, 18, 800, 0, "Calibri") $LABELUSERNAME = GUICtrlCreateLabel("Gebruiker", 50, 150, 50, 17) $Combo1 = GUICtrlCreateCombo("Kies een medewerker...", 50, 167, 233, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) $LABELPASSW = GUICtrlCreateLabel("Wachtwoord:", 50, 210, 77, 17, 0) $PasswordEdit = GUICtrlCreateInput("", 50, 227, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_PASSWORD)) $VERSIONLABEL = GUICtrlCreateLabel("Versie: " & $VERSION, 8, 323) $hLabel = GUICtrlCreateLabel("", 0, 0, 332, 50, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetState($BG, $GUI_DISABLE) GUICtrlSetBkColor($TITEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($LABELUSERNAME, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($LABELPASSW, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($Combo1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($PasswordEdit, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($VERSIONLABEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($hLabel, $GUI_BKCOLOR_TRANSPARENT) Local $hDLL = DllOpen("user32.dll") GUISetState(@SW_SHOW) While 1 $Test = ControlGetFocus($VERSION & " - Inloggen") IF $Test = "Edit1" Then GUICtrlSetBkColor($Combo1, $COLOR_YELLOW) Else GUICtrlSetBkColor($Combo1, $COLOR_WHITE) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Nine Posted August 19, 2019 Share Posted August 19, 2019 here something that would work way better : expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <array.au3> #include <GuiListView.au3> #include <Misc.au3> #include <ColorConstants.au3> #include <GUIComboBox.au3> Global $VERSION = "2.0.0 | Build: 20819" Global $INLOGGUI = GUICreate($VERSION & " - Inloggen", 332, 342, -1, -1, $WS_POPUPWINDOW) $TITEL = GUICtrlCreateLabel("Inloggen", 0, 40, 332, 30, $ES_CENTER) GUICtrlSetFont(-1, 18, 800, 0, "Calibri") $LABELUSERNAME = GUICtrlCreateLabel("Gebruiker", 50, 150, 50, 17) $Combo1 = GUICtrlCreateCombo("Kies een medewerker...", 50, 167, 233, 25) $LABELPASSW = GUICtrlCreateLabel("Wachtwoord:", 50, 210, 77, 17, 0) $PasswordEdit = GUICtrlCreateInput("", 50, 227, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_PASSWORD)) $VERSIONLABEL = GUICtrlCreateLabel("Versie: " & $VERSION, 8, 323) Global $iIDPrev = 0 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $lParam $iIDFrom = _WinAPI_LoWord($wParam) $iCode = _WinAPI_HiWord($wParam) If $iIDFrom <> $iIDPrev Then ; ConsoleWrite ($hWndFrom & "/" & $iIDFrom & "/" & $iCode & @CRLF) GUICtrlSetBkColor($iIDPrev, $COLOR_WHITE) GUICtrlSetBkColor($iIDFrom, $COLOR_YELLOW) _WinAPI_RedrawWindow($INLOGGUI) $iIDPrev = $iIDFrom EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Wingens Posted August 20, 2019 Author Share Posted August 20, 2019 @Nine Thx for the reply only problem is i am getting: Link to comment Share on other sites More sharing options...
LukeLe Posted August 20, 2019 Share Posted August 20, 2019 @Wingens The error msg says it, you lack Func WM_COMMAND. Please add a function with name "WM_COMMAND" like in the code @Nine posted above. Wondering who uses AutoIT and what it can be used for? Link to comment Share on other sites More sharing options...
Wingens Posted August 20, 2019 Author Share Posted August 20, 2019 (edited) @LukeLe I did add it, i will add my entire script to this post. All the way below you will find the func i added. 2.0.0.au3 Edited August 20, 2019 by Wingens LukeLe 1 Link to comment Share on other sites More sharing options...
Nine Posted August 20, 2019 Share Posted August 20, 2019 There is an illegal character in that statement, just delete it. It happens sometimes with copy/paste... LukeLe 1 “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Wingens Posted August 20, 2019 Author Share Posted August 20, 2019 Thx just copied it to a notepad and then recopied it to the editor now it is working. Link to comment Share on other sites More sharing options...
UEZ Posted August 20, 2019 Share Posted August 20, 2019 You can do something like this here: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <file.au3> #include <array.au3> #include <GuiListView.au3> #include <Misc.au3> #include <ColorConstants.au3> #include <GUIComboBox.au3> Global $VERSION = "2.0.0 | Build: 20819" $INLOGGUI = GUICreate($VERSION & " - Inloggen", 332, 342, -1, -1, $WS_POPUPWINDOW) $BG = GUICtrlCreatePic(@ScriptDir & '\Images\LoginBG.BMP', 0, 0, 332, 342) $TITEL = GUICtrlCreateLabel("Inloggen", 0, 40, 332, 30, $ES_CENTER) GUICtrlSetFont(-1, 18, 800, 0, "Calibri") $LABELUSERNAME = GUICtrlCreateLabel("Gebruiker", 50, 150, 50, 17) $Combo1 = GUICtrlCreateCombo("Kies een medewerker...", 50, 167, 233, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) $LABELPASSW = GUICtrlCreateLabel("Wachtwoord:", 50, 210, 77, 17, 0) $PasswordEdit = GUICtrlCreateInput("", 50, 227, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_PASSWORD)) $hPasswordEdit = GUICtrlGetHandle($PasswordEdit) $VERSIONLABEL = GUICtrlCreateLabel("Versie: " & $VERSION, 8, 323) $hLabel = GUICtrlCreateLabel("", 0, 0, 332, 50, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetState($BG, $GUI_DISABLE) GUICtrlSetBkColor($TITEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($LABELUSERNAME, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($LABELPASSW, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($Combo1, $GUI_BKCOLOR_TRANSPARENT) ;~ GUICtrlSetBkColor($PasswordEdit, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($VERSIONLABEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($hLabel, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_SHOW) Global $iColor = 0xFFFFFF GUIRegisterMsg($WM_CTLCOLOREDIT, "WM_CTLCOLOREDIT") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_CTLCOLOREDIT($hWnd, $iMsg, $wParam, $lParam) If $lParam = $hPasswordEdit Then _WinAPI_SetTextColor($wParam, 0x000000) _WinAPI_SetBkMode($wParam, $TRANSPARENT) Return _WinAPI_CreateSolidBrush($iColor) EndIf Return "GUI_RUNDEFMSG" EndFunc Func WM_COMMAND($hWnd, $iMsg, $lParam, $wParam) Switch $hWnd Case $INLOGGUI Switch _WinAPI_LoWord($lParam) Case $PasswordEdit Switch _WinAPI_HiWord($lParam) Case $EN_SETFOCUS $iColor = 0x00FFFF Case $EN_KILLFOCUS $iColor = 0xFFFFFF EndSwitch EndSwitch EndSwitch Return "GUI_RUNDEFMSG" EndFunc spudw2k 1 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 More sharing options...
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