Jump to content

ANYGUI.au3


quaizywabbit
 Share

Recommended Posts

I tried adding a button to the browser "Maxhon", but nothing happens, at all. Does the controls have to be of some special kind? Found the toolbar control ID (59392) and tried passing tham into the _GuiTarget function, but still no go.

Has anyone had success with other applications besides hoster? (tried the sample code with that, and it worked fine for me).

This is the code. The X/Y and size values should place the button within that toolbar area.

#region Hoster demo addbutton
opt ("WinTitleMatchMode", 2)
#include <ANYGUI.au3>
#include <GUIConstants.au3>; must be included in main script for GUI Functions to work
Dim $myVar1, $myVarB1, $myVarB2, $myVarB3, $myVarB4, $myVarB5, $myVarB6, $myVarC1


WinSetState("Maxthon Browser", "", @SW_MAXIMIZE)
Sleep(2000)

$myVar1 = _GuiTarget("Maxthon Browser", "", "", 59392);<===Target is control on main application.
$myVarB1 = _TargetAddButton("Test", 600, 28, 100, 20, "", "", $myVar1)
GUISetState(@SW_SHOW)

While WinExists($myVar1)
      Sleep(100)
      If Not WinExists($myVar1) Then
         Exit
      EndIf
  WEnd
  _EndTarget()
  
#endregion
Edited by carpediem
Link to comment
Share on other sites

This is really cool stuff. Thanks quaizywabbit.

Here's an expanded example with an event handler for button presses and monitoring for parent application exit. It places two buttons on an application's menu bar that then pass key sequences to the application.

I was screwed up for a while until I realized that the buttons were stealing input focus from the main app. The 'ControlFocus' calls return focus to the main application before performing the actions for the buttons.

Note that the button handles are returned in array element 0.

I also had to switch to OnEvent mode so that I could monitor for button events AND for the parent application exit.

Enjoy,

Dale

#region AnyGuiTest
#include <ANYGUI.au3>
#include <GUIConstants.au3>; must be included in main script for GUI Functions to work
Opt("WinTitleMatchMode", 4); allow ClassName lookup to avoid window confusion
Opt("GUIOnEventMode", 1); Change to OnEvent mode 

Dim $appWindow, $guiTarget, $button1, $button2
; find control handles using 'AutoIt Window Info' app
Dim const $parentControl = 59422; handle of control to which we'll attach GUI
Dim const $mainAppControl = 59648; handle of main application window control

HotKeySet("{ESC}", "Terminate")

$appWindow = WinGetHandle("classname=MindMan5WndClass")
$guiTarget = _GuiTarget($appWindow, "", "", $parentControl)

$button1 = _TargetAddButton("Edit Activity", 810, 0, 100, 25, "", "", $guiTarget)
GUICtrlSetOnEvent($button1[0], "button1Clicked")
GUISetState(@SW_SHOW)

$button2 = _TargetAddButton("Add Activity", 910, 0, 100, 25, "", "", $guiTarget)
GUICtrlSetOnEvent($button2[0], "button2Clicked")
GUISetState(@SW_SHOW)

_EndTarget()

While WinExists($appWindow)
    Sleep(100)
    If Not WinExists($appWindow) Then
        Exit 0
    EndIf
Wend

Func button1Clicked()
    ControlFocus($appWindow,"",$mainAppControl);Button click steals focus, restore to app
    Send("!{e}{y}")
EndFunc

Func button2Clicked()
    ControlFocus($appWindow,"",$mainAppControl);Button click steals focus, restore to app
    Send("!{i}{y}")
EndFunc
  
Func Terminate();Only if the main application has focus
    If WinActive($appWindow) Then
        Exit 0
    EndIf
EndFunc

#endregion

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Got a screen-shot of the result? Just curious if the control you embedded the buttons to is a dialog type control(as it was in Hoster) or if it was a different type.

So we can know where these func's work, and where they don't......

<{POST_SNAPBACK}>

OK, I've tried to attach a screen shot -- I'm hoping I did it correctly. The attached buttons on in the bottom right corner of the application and I circled them in green.

Here is the info about the control I attached them to:

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 760 W: 1078 H: 26

Control ID: 59422

ClassNameNN: BCGDockBar:400000:8:10011:102

Text:

I'm also including an update to the code as I changed the idle loop logic and am also using an ObjCreate to get at the application API...

#region AnyGuiTest
#include <GUIConstants.au3>; must be included in main script for GUI Functions to work
#include <ANYGUI.au3>

Opt("WinTitleMatchMode", 4); allow ClassName lookup to avoid window confusion
Opt("GUIOnEventMode", 1); Change to OnEvent mode 
Opt("TrayIconHide", 1); hide tray icon

Dim $appWindow, $guiTarget, $button1, $button2
; find control handles using 'AutoIt Window Info' app
Dim const $parentControl = 59422; handle of control to which we'll attach GUI
Dim const $mainAppControl = 59398; application main menu bar
Dim const $mapCentralPath = "G:\hohm\My Documents\My Maps\Map Central.mmap"

HotKeySet("{ESC}", "Terminate")

$myMindMan = ObjCreate("MindManager.Application")
$myMindMan.visible = 1

$appWindow = WinGetHandle("classname=MindMan5WndClass")
$guiTarget = _GuiTarget($appWindow, "", "", $parentControl)

$button1 = _TargetAddButton("Edit Activity", 830, 0, 75, 25, "", "", $guiTarget)
GUICtrlSetOnEvent($button1[0], "button1Clicked")
GUISetState(@SW_SHOW)

$button2 = _TargetAddButton("Add Activity", 905, 0, 75, 25, "", "", $guiTarget)
GUICtrlSetOnEvent($button2[0], "button2Clicked")
GUISetState(@SW_SHOW)

$button3 = _TargetAddButton("Map Central", 980, 0, 75, 25, "", "", $guiTarget)
GUICtrlSetOnEvent($button3[0], "button3Clicked")
GUISetState(@SW_SHOW)

;button4 for future use
;$button4 = _TargetAddButton("No Sweep", 1055, 0, 75, 25, "", "", $guiTarget)
;GUICtrlSetOnEvent($button4[0], "button4Clicked")
;GUISetState(@SW_SHOW)

_EndTarget()

; Check for 'visible' attribute of the main application.  Testing for existance didn't work
; because the ObjCreate in this script created a reference to the app and prevented run down
; even though it appeared to exit and became invisible.
While $myMindMan.visible
    Sleep(1000)
Wend

Exit 0; If we got out of the While loop, the main app was closed, so Exit

Func button1Clicked()
;   ControlFocus($appWindow,"",$mainAppControl);Button click steals focus, restore to app
;   Send("!{e}{y}")
    $myMindMan.RunMacro("C:\Program Files\Gyronix\ResultManager\ResultManager-X5-Edit.MMBas")
EndFunc

Func button2Clicked()
;   ControlFocus($appWindow,"",$mainAppControl);Button click steals focus, restore to app
;   Send("!{i}{y}")
    $myMindMan.RunMacro("C:\Program Files\Gyronix\ResultManager\ResultManager-X5-Insert.MMBas")
EndFunc

Func button3Clicked()
    $mapCentral = $myMindMan.documents.open($mapCentralPath)
EndFunc

Func button4Clicked()
;;;
EndFunc

Func Terminate();Only if the this main application has focus
    If WinActive($appWindow) Then
        Exit 0
    EndIf
EndFunc

#endregion

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

outstanding!!!!

Now there.s at least 2 types of controls that work.....

btw....nice work!!!

EDIT::Those with successful embeds with various controls(as above...) PLEASE post your findings here, so others might benefit (screenshots help, and posting the AutoIT's Window Info Tools data helps immeasurably!!):)

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

Hi,

Can someone provide an working example with the AnyGui in combination with an "standard" installed application. Like Notepad/Calculator or what ever is default installed in windows ?

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

#include <ANYGUIv2.2.au3>
#include <guiconstants.au3>
Run("notepad.exe")
Sleep(1000)
WinSetState("Untitled - Notepad", "", @SW_MAXIMIZE)
$Targetwindow = _GuiTarget ("Untitled - Notepad", 1); mode 1 set so all '_Targetadd(s) go to this window
ControlMove($Targetwindow, "", 15, 0, 0, 800, 500);resize Edit1 control so everything fits
$btn1 = _TargetaddButton ( "Button1", 30, 550, 100, 50);
GUISetState(@SW_SHOW);
$btn2 = _TargetaddButton ( "Button2", 150, 550, 100, 50);
GUISetState(@SW_SHOW);
$Child = _TargetaddChild ("Test", 810, 0, 205, 500);
GUISetBkColor(0xff000);
$label1 = GUICtrlCreateLabel("Child Window", 60, 0, 100, 30)
$btn3 = GUICtrlCreateButton("Button3", 52, 35, 100, 50);
$grp1 = GUICtrlCreateGroup("Testing", 20, 90, 165, 200);
$radio1 = GUICtrlCreateRadio("A", 95, 120);
$radio2 = GUICtrlCreateRadio("B", 95, 180);
$radio3 = GUICtrlCreateRadio("C", 95, 240);
$Date = GUICtrlCreateDate("My Calender", 20, 300, 165, 180);
GUISetState(@SW_SHOW);
$tab = _TargetaddTab (300, 500, 715, 210);
$tab1 = GUICtrlCreateTabItem("First");
$tab2 = GUICtrlCreateTabItem("Second");
$tab3 = GUICtrlCreateTabItem("Third");
GUISetState(@SW_SHOW)
While WinExists($Targetwindow)
   $msg = GUIGetMsg(1)
   If $msg[0] = $GUI_EVENT_CLOSE Then Exit
   If Not WinExists($Targetwindow) Then Exit
   Sleep(50)
WEnd

Hope this helps some......

EDIT: changed TargetChildCreate to TargetaddChild

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

you beat me :)

#include <guiconstants.au3>
#include <anygui.au3>
Run ( "calc" )
WinWait ( "Calculator" )
$Pos = WinGetPos ( "Calculator" )
WinMove ( "Calculator", '', (@DesktopWidth-$Pos[2])/2, (@DesktopHeight-$Pos[3])/2, $Pos[2] + 47, $Pos[3] )
_GuiTarget ( "Calculator", 1 )
$Quit = _TargetAddButton ( "Quit", $Pos[2]-10, 37, 50, 29 )
$Quit = $Quit[0]
GUISetState ( )
_TargetAddLabel ( "Notepad", $Pos[2]-10, 66, 50, 18 )
GUISetState ( )
_TargetAddEdit ( "", $Pos[2]-10, 84, 50, 115 )
GUISetState ( )
While 1
    $msg = GUIGetMsg ( )
    If $msg = $Quit Then Exit
    If Not WinExists ( "Calculator" ) Then Exit
WEnd

Func OnAutoItExit()
    ProcessClose ( "calc.exe" )
EndFunc

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

  • 3 weeks later...

FYI -- I upgraded AutoIt to the latest beta from the developer forum on a machine where I had been using ANYGUI for some time very happily...

To my distress, my embedded buttons quit appearing and the script generated no errors. I checked a couple of the other examples that have been posted here and they still worked, but my app did not. To make a long story short (after working on debugging for a while) I checked back here for an update to ANYGUI.au3...

I noticed that Quaizywabbit had posted an update since I had written my script... I downloaded it and magically, everything is working again! Yeah! Everything is happy again and I didn't have to do the debugging :)

Hoped this post might save some others some time and frustration.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Sorry Dale, I went through and formatted  ANYGUI so its more UDF friendly, and ended up renaming _TargetChildCreate to _TargetaddChild, then updating all the func's that use it...

I have no plans to change anything else (unless I have to).

Only additional "any Gui" controls will be added as they become available, with the exception of functions which alter the style and/or exstyle of an existing app window or control (this would really round out the ANYGUI concept nicely)

<{POST_SNAPBACK}>

Thanks -- the odd thing was that it was not ANYGUI that I updated, but AutoIt. Something you changed in your newer codebase, intentionally or not, made the code compatible with the new AutoIt beta. Great job! :)

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Hi!

I've been using anygui.au3 and i think it's very usefull

But i have an application compiled in python and i cannot acces to them?

Is there any trick.

The au3info don't retrieve information about the controlid , just its class

Has anybody here present this already?

Lars

Link to comment
Share on other sites

Hi,

I have just tried this, without succes;

Running "Hoster" script example;

[_targetbtnadd("Test", 750,20, 100, 50)

^ ERROR]

beta 3.1.1.8

anygui.au3 in "include" directory.

What am I missing?

Thanks, Randall

Link to comment
Share on other sites

the example is outdated since I formatted it to be UDF friendly.....

there is:

_GuiTarget

_EndTarget

_Targetadd*********<==whatever control or Child window you want added(this includes the change of _TargetChildCreate to _TargetaddChild)

_TargetSetStyle <====change style/exstyle for window or control

Edit:: Sorry about that....I've only been updating the original post, and have neglected the examples.....when I get time I'll fix this...

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

Hi!

I've been using anygui.au3 and i think it's very usefull

But i have an application compiled in python and i cannot acces to them?

Is there any trick.

The au3info don't retrieve information about the controlid , just its class

Has anybody here present this already?

Lars

<{POST_SNAPBACK}>

from the help file.....

Control ID

ClassNameNN

Text

Control Handle (HWND) (Not available in AutoIt Window Info Tool - see below)

Whenever you see a Control...() command expecting a ControlID parameter (most of them) you can use any one of these methods.

[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

Updated ANYGUI.au3 (see first post)

added: _TargetSetStyle --- many Kudo's to Xenogis for all his hard work!

allows you to "Add", "Remove", or "Replace" Style(s) and/or Exstyle(s) of existing Windows or Controls...

EDIT:: fixed Optional Style and Exstyle parameters (was 0, changed to -1[so defaults work properly] Thanks DaleHolm!!

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

  • 2 weeks later...

Version 2.0: (will be "Versioned" from now on....)

added basic error handling to all func's (except _EndTarget)

Returns 0 and sets @error

Enjoy!!

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

any idea how to manipulate existing ContexMenu's of other applications?

#include <GUIConstants.au3>
$target_title = "My GUI Context Menu"
$target_hwnd = WinGetHandle($target_title)
ConsoleWrite (GUISwitch($target_hwnd) & @cr)
for $i = 1 To 256
    if (GUICtrlSetState ($i,$GUI_DISABLE) = 1) Then ConsoleWrite($i & " ")
Next

The code above was my first attempt, it didnt work and i am out of ideas...

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

Sorry, Not a clue.....

Perhaps you should post this in the Support section of the forums......

You could possibly add a context menu if it didn't have one already

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
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...