kudrow Posted October 19, 2013 Share Posted October 19, 2013 Not even sure this is possible but below is a test script that I thought may add a button to a third party gui not built in AutoIt. #include <GuiButton.au3> $i=4 While $i=4 $winname= "Third Party GUI" _GUICtrlEdit_Create($winname, "TEST", "854", "477", "300", "300") WEnd Anyone have any thoughts? Thanks, Cody Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 19, 2013 Moderators Share Posted October 19, 2013 kudrow,I strongly doubt that using _GUICtrlEdit_Create is going to create a button. But even if you do create a button, the problem is getting notification of it being actioned. You might like to look at this thread where the whole problem was discussed at length. 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...
martin Posted October 19, 2013 Share Posted October 19, 2013 (edited) It is actually quite easy to do. Create a popup window which is big enough to hold the button. Make the window positionthe same as the position you want it to be in the 3rd party window. Set the parent for the popup to be the 3rd party window and it will move there. You can react to the button press in your script as normal. Here is a simple example. ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Pumac.exe #AutoIt3Wrapper_res_requestedExecutionLevel=asInvoker #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** AutoItSetOption('trayiconhide', 1) Run('calc.exe');just to have a window to use $ParentTitle = "Calculator"; While Not WinExists($ParentTitle) Sleep(200) WEnd ConsoleWrite("ss" & @CRLF) $hParentWindow = WinGetHandle($ParentTitle) ;guess and experiment $fleft = 12 $ftop = 38 $winf7 = GUICreate("F7",30, 30, $fleft, $ftop, $WS_POPUP) GUISetBkColor(0xff0000) $Btnf7 = GUICtrlCreateButton("F7", 1, 1, 28, 28) ;GUICtrlSetFont(-1, 16) DllCall("user32.dll", "int", "SetParent", "hwnd", $winf7, "hwnd", $hParentWindow) GUISetState() While WinExists($hParentWindow) if GUIGetMsg() = $Btnf7 then msgbox(262144,'Click', 'F7 pressed') WEnd WinKill($winf7) For a UDF which does this for you search for anygui. Edited October 19, 2013 by martin Wombat 1 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...
kudrow Posted October 21, 2013 Author Share Posted October 21, 2013 This is very cool. It indeed works but with a minor problem. The button does not appear until the mouse pointer rolls over the hidden button. Not sure why it is hidden. Any thoughts? Thanks again for the help. Cody Link to comment Share on other sites More sharing options...
martin Posted October 22, 2013 Share Posted October 22, 2013 (edited) I don't how how you should redraw the button, or rather, how you know when to rdraw it. I tried using Shell Hook but $HSHELL_REDRAW doesn't seem to be related to when a window repaints. So you could just keep redrawing the button as I show below, but it is a bit nasty. I suggest you start a new thread and see if someone knows how to do it. expandcollapse popup;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_res_requestedExecutionLevel=asInvoker #endregion ; *** Start added by AutoIt3Wrapper *** #include <WindowsConstants.au3> #include <winapi.au3> AutoItSetOption('trayiconhide', 1) Run('calc.exe');just to have a window to use $ParentTitle = "Calculator"; While Not WinExists($ParentTitle) Sleep(200) WEnd ConsoleWrite("ss" & @CRLF) $hParentWindow = WinGetHandle($ParentTitle) ConsoleWrite($hParentWindow & @LF) ;guess and experiment $fleft = 12 $ftop = 38 $winf7 = GUICreate("F7", 30, 30, $fleft, $ftop, $WS_POPUP) GUISetBkColor(0xff0000) $Btnf7 = GUICtrlCreateButton("F7", 1, 1, 28, 28) DllCall("user32.dll", "int", "SetParent", "hwnd", $winf7, "hwnd", $hParentWindow) GUISetState() AdlibRegister("redrawButton", 500) While WinExists($hParentWindow) If GUIGetMsg() = $Btnf7 Then MsgBox(262144, 'Click', 'F7 pressed') WEnd WinKill($winf7) Func redrawButton() ;If $redraw = 1 Then _WinAPI_InvalidateRect($winf7) EndFunc ;==>redrawButton Edited October 22, 2013 by martin 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