Jump to content

Add button to third party gui?


kudrow
 Share

Recommended Posts

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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
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

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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...