magace Posted May 12, 2016 Share Posted May 12, 2016 Hello I have written a simple gui for work to auto print labels with DYMO. However I have one small problem. Currently I detect when the scanner sends the tab key to call the print function. I was thinking if I can just detect when a input box is active or the curser is in the input box I could do away with the _ispressed function making the script run smoother. Here is a sample gui showing what I would like to do please let me know if anything is unclear. Thanks! #include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("Print", 310, 370, 85, 25) Local $inp1 = GUICtrlCreateInput("Scan goes here then tabs to the next InputBox", 10, 35, 300, 20) ; will not accept drag&drop files Local $inp2 = GUICtrlCreateInput("I want to detect when this input box is active/curser is here", 10, 55, 300, 20) ; will not accept drag&drop files ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example Link to comment Share on other sites More sharing options...
MichaelHB Posted May 12, 2016 Share Posted May 12, 2016 Hi magace, It's not very elegant, it's just some snippets that i put it together to give you an ideia. Look if this helps: expandcollapse popup#include <GUIConstantsEx.au3> #Include <WinAPI.au3> Example() Func Example() Local $sMsg1 = "" ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("Print", 310, 370, 85, 25) Local $inp1 = GUICtrlCreateInput("Scan goes here then tabs to the next InputBox", 10, 35, 300, 20) ; will not accept drag&drop files Local $inp2 = GUICtrlCreateInput("I want to detect when this input box is active/curser is here", 10, 55, 300, 20) ; will not accept drag&drop files ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $hWnd = ControlGetHandle(WinGetHandle("Example"), "", "[CLASSNN:Edit2]") Local $MouseOver = False ; Loop until the user exits. While 1 $tPoint = _WinAPI_GetMousePos() If _WinAPI_WindowFromPoint($tPoint) = $hWnd Then If Not $MouseOver Then ; Do something ConsoleWrite('MouseOver' & @CRLF) $MouseOver = 1 EndIf Else If $MouseOver Then ; Do something ConsoleWrite('MouseOver Lost' & @CRLF) $MouseOver = 0 EndIf EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK GUIDelete() Exit Case Else $sFocus = ControlGetFocus($hGUI) $hFocus = ControlGetHandle($hGUI, "", $sFocus) $ctrlFocus = _WinAPI_GetDlgCtrlID($hFocus) $sMsg = "Focus:" & @CRLF & _ @TAB & "ClassNameNN = " & $sFocus & @CRLF & _ @TAB & "Hwnd = " & $hFocus & @CRLF & _ @TAB & "ID = " & $ctrlFocus If $sMsg <> $sMsg1 Then ConsoleWrite($sMsg & @CRLF) $sMsg1 = $sMsg EndIf EndSwitch WEnd EndFunc ;==>Example Exit Link to comment Share on other sites More sharing options...
magace Posted May 12, 2016 Author Share Posted May 12, 2016 Thanks this helps a ton! 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