Info Posted July 7, 2009 Author Share Posted July 7, 2009 I'm sorry Melba23 but if I cannot use buttons then this isn't what I'm looking for. I guess I'll have to break my head for the solution. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2009 Moderators Share Posted July 7, 2009 Info, Why the fixation on buttons? Labels are just as good and more flexible. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Info Posted July 7, 2009 Author Share Posted July 7, 2009 I've set myself a challenge to build a virtual keyboard with buttons. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2009 Moderators Share Posted July 7, 2009 Info, Why on earth did you not say so at the beginning - then I would not have wasted so much of my time trying (and succeeding) to produce something that you were never going to use. You are now on your own now - and if you think you have annoyed me......you are dead right! "Click" M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Info Posted July 7, 2009 Author Share Posted July 7, 2009 Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 Do you *need* to have the button animation as well? Link to comment Share on other sites More sharing options...
Info Posted July 7, 2009 Author Share Posted July 7, 2009 (edited) I think I'm onto something: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Focused", 651, 42, 192, 124, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $Test = GUICtrlCreateButton("Test", 304, 8, 65, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 If WinActive($Form1) = False Then WinSetTitle("Focused","","Focused - " & WinGetTitle("","")) EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Test $ReplacedString = StringReplace(WinGetTitle($Form1),"Focused - ","") WinActivate($ReplacedString) ControlSend($ReplacedString,"","","asd") EndSwitch WEnd There seems to be a 0.5sec delay in the ControlSend function, any idea why? Do you *need* to have the button animation as well?I'll be fine, thanks. Edit: A little improve for the script. Edited July 7, 2009 by Info Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 See SendKeyDelay and SendKeyDownDelay. Fine if you've got it yourself, but I found a way to get exactly what you want, it's just that the button animations do not happen. You can get rollover effects (hottracking of the button), but the actual press / release animations cannot happen as they steal focus. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2009 Moderators Share Posted July 7, 2009 wraithdu, I would be really interested to see how you do that. The button animation stealing focus was what led me to believe labels were the only way to go. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 (edited) I took most of your script for the nice keyboard GUI. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $_NOACTIVATE = 0x08000000 $MA_NOACTIVATE = 3 $MA_NOACTIVATEANDEAT = 4 HotKeySet("{ESC}", "On_Exit") Global $aKeys[48] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", _ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", _ "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", '"', _ "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "spc", "enter"] ; Create "keyboard" GUI $hGUI = GUICreate("Test", 360, 120, 500, 100, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $_NOACTIVATE)) $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 GUICtrlCreateButton("", $i * 30, $j * 30, 30, 30) GUICtrlSetData(-1, $aKeys[$iCount]) $iCount += 1 ;~ GUICtrlSetFont(-1, 10) ;~ GUICtrlSetBkColor(-1, 30000 + 2000 * ($i + 1) + 2000 * ($j + 1)) Next Next GUISetState() GUIRegisterMsg($WM_MOUSEACTIVATE, 'WM_EVENTS') Run("notepad.exe") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_EVENTS($hWndGUI, $MsgID, $WParam, $LParam) Switch $hWndGUI Case $hGUI Switch $MsgID Case $WM_MOUSEACTIVATE ; Check mouse position Local $aMouse_Pos = GUIGetCursorInfo($hGUI) If $aMouse_Pos[4] <> 0 Then Local $sText = ControlGetText($hGUI, "", $aMouse_Pos[4]) ; Write key If $sText = "spc" Then Send("{SPACE}") ElseIf $sText = "enter" Then Send("{ENTER}") Else Send($sText) EndIf EndIf Return $MA_NOACTIVATEANDEAT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func On_Exit() Exit EndFunc The keys are the _NOACTIVATE (WS_EX_NOACTIVATE) extended style which prevents the system from giving the window focus, and handing the WM_MOUSEACTIVATE message to eat the mouseclick yet still do what you want. An alternative to your indexing scheme, is to directly send a WM_COMMAND message to the GUI with the BN_CLICKED message for the hovered button. This will still send the button notification but won't trigger the animation or steal focus. This way you can still have button triggered events / functions. Local $word = _WinAPI_MakeLong($hButton, $BN_CLICKED) _SendMessage($hGUI, $WM_COMMAND, $word, GUICtrlGetHandle($hButton)) Where $hButton is the button you 'clicked', available from the GUIGetCursorInfo() function. Edited July 7, 2009 by wraithdu Link to comment Share on other sites More sharing options...
Info Posted July 7, 2009 Author Share Posted July 7, 2009 wraithdu, I'll be very thankful if you'll show here how is it possible to click a button on my GUI without stealing the focus from the active window. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2009 Moderators Share Posted July 7, 2009 wraithdu,Thank you for that - you have just cheered up a pretty miserable day.I never imagined that you could use a NO_ACTIVATE style - I only discovered the @SW_SHOWNOACTIVATE macro a few weeks ago!I never cease to be amazed at what Autoit can do with a bit of imagination.Thanks again.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 (edited) Those are actually two different things. WS_EX_NOACTIVATE is an extended windows style (lookup CreateWindowEx() in MSDN), while SW_SHOWNOACTIVATE is a constant for the ShowWindow() function. Both are totally legal, didn't break any laws, promise! Edited July 7, 2009 by wraithdu Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2009 Moderators Share Posted July 7, 2009 wraithdu,I cannot get the SendMessage alternative you suggested to work. Is this correct or have I misunderstood?Switch $MsgID Case $WM_MOUSEACTIVATE ; Check mouse position Local $aMouse_Pos = GUIGetCursorInfo($hGUI) Local $word = _WinAPI_MakeLong($aMouse_Pos[4], $BN_CLICKED) _SendMessage($hGUI, $WM_COMMAND, $word, GUICtrlGetHandle($aMouse_Pos[4])) Return $MA_NOACTIVATEANDEAT EndSwitchM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 Made a small change to the example. It doesn't rely on the index now, as it's easier to just grab the text right from the button with ControlGetText(). Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 @M23 That looks correct. What's the rest of the script though? Do you have events set up for a button click? Link to comment Share on other sites More sharing options...
wraithdu Posted July 7, 2009 Share Posted July 7, 2009 Here ya go: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> $WS_EX_NOACTIVATE = 0x08000000 $MA_NOACTIVATE = 3 $MA_NOACTIVATEANDEAT = 4 HotKeySet("{ESC}", "On_Exit") Global $aKeys[48] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", _ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", _ "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", '"', _ "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "spc", "enter"] ; Create "keyboard" GUI $hGUI = GUICreate("Test", 360, 120, 500, 100, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) $dummy1 = GUICtrlCreateDummy() $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 GUICtrlCreateButton("", $i * 30, $j * 30, 30, 30) GUICtrlSetData(-1, $aKeys[$iCount]) $iCount += 1 ;~ GUICtrlSetFont(-1, 10) ;~ GUICtrlSetBkColor(-1, 30000 + 2000 * ($i + 1) + 2000 * ($j + 1)) Next Next $dummy2 = GUICtrlCreateDummy() GUISetState() GUIRegisterMsg($WM_MOUSEACTIVATE, 'WM_EVENTS') Run("notepad.exe") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $dummy1 To $dummy2 Local $sText = ControlGetText($hGUI, "", $msg) ; Write key If $sText = "spc" Then Send("{SPACE}") ElseIf $sText = "enter" Then Send("{ENTER}") Else Send($sText) EndIf EndSwitch WEnd Func WM_EVENTS($hWndGUI, $MsgID, $WParam, $LParam) Switch $hWndGUI Case $hGUI Switch $MsgID Case $WM_MOUSEACTIVATE ; Check mouse position Local $aMouse_Pos = GUIGetCursorInfo($hGUI) If $aMouse_Pos[4] <> 0 Then Local $word = _WinAPI_MakeLong($aMouse_Pos[4], $BN_CLICKED) _SendMessage($hGUI, $WM_COMMAND, $word, GUICtrlGetHandle($aMouse_Pos[4])) EndIf Return $MA_NOACTIVATEANDEAT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func On_Exit() Exit EndFunc Professor_Bernd and n1maS 2 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2009 Moderators Share Posted July 7, 2009 wraithdu, Ah, I was not at all on the same wavelength. Another day, another thing learnt - keeps Alzheimers at bay for a bit longer..... ;-) Thank you again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Info Posted July 7, 2009 Author Share Posted July 7, 2009 Thank you all. Link to comment Share on other sites More sharing options...
martin Posted July 8, 2009 Share Posted July 8, 2009 @wraithdu Many thanks for showing how to do that. I tried last year and never worked it out. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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