Sign in to follow this  
Followers 0
kudrow

Add button to third party gui?

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by martin
1 person likes this

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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.

;**** 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 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0