ptrex Posted January 25, 2006 Share Posted January 25, 2006 I am trying to create a button on a legacy application using ANYGUI. The button won't appear ??!! I' ve tested the script creating a button on Windows Explorer, and this works fine. When I use the AU3Info Tool to get the info of the legacy appl. I don' t see a CONTROL ID for any of the controls. Only ClassnameNN and Text are available. This is my problem that none of the Ctrls are having a Control ID. Is there a workaround for this. To work using the ClassNameNN instead or maybe using a DLLCall routine ? This is the working script for the Windows Explorer. #include <ANYGUI.au3> #include <guiconstants.au3> Opt("WinTitleMatchMode", 4) Opt("GUIOnEventMode", 1) $appWindow = WinGetHandle("classname=ExploreWClass") $Targetwindow = _GuiTarget($appWindow,"FolderView","",40960) $btn = _TargetaddButton ( "Drawing", 740, 3, 80, 30,"","",$Targetwindow); GUICtrlSetOnEvent($btn[0], "Clicked") GUISetState(@SW_SHOW) _EndTarget() While WinExists($Targetwindow) Sleep(100) If Not WinExists($Targetwindow) Then Exit EndIf WEnd Func Clicked() MsgBox(0,"TEST","OK") EndFunc Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
quaizywabbit Posted January 26, 2006 Share Posted January 26, 2006 $Targetwindow = _GuiTarget($appWindow,"FolderView","",40960) the above parameters aren't in the right order. the parameter order is supposed to be: Title, Mode, Text, Controlid as far as using ClassnameNN see the docs for Wingethandle() and Controlgethandle(). There is only one extra parameter between them. The Mode parameter simply determines whether the returned variable is either Local or Global in Scope. [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
ptrex Posted January 26, 2006 Author Share Posted January 26, 2006 (edited) @quaizywabbitThanks for the info.1. The parameter info was not correct, like you noticed. But it is working in both cases.2. Second, I looked at the Wingethandle() and Controlgethandle(). But I can' t situate what it has to do with my problem. I will explain a but further. This is what I get from the AU3Info Tool. As you can see the CONTROL ID's are missing for any of the the control in that window. (This is not a Microsoft Appl.)Class: TsShellWinClassSize: X: 202 Y: 69 W: 767 H: 551>>>>>>>>>>> Mouse Details <<<<<<<<<<<Screen: X: 884 Y: 129Cursor ID: 2>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<RGB: Hex: 0xECE9D8 Dec: 15526360>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<Size: X: 0 Y: 0 W: 759 H: 497Control ID: MISSINGClassNameNN: TsWinClass2Text: DsCmwindow-5Style: 0x56000000ExStyle: 0x00000000I wanted to add a button on one of those controls. But when using your ANYGUI, I need a CONTROL ID to tell it on which control it should place the BUTTON.Since I am missing the CONTROL ID's I can't get it to work, because your _GuiTarget() needs a CONTROL ID as a last parameter.Maybe you can show me what to do in this case.Thanks a lot. Edited January 26, 2006 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
ptrex Posted January 26, 2006 Author Share Posted January 26, 2006 @quaizywabbit I've got it to work !! Still I don't understand why, maybe you can explain me the background details. This is the code. $handle = ControlGetHandle("classname=TsShellWinClass", "DsCrowColumn", "TsWinClass10") ;MsgBox(0,"",$handle) $Targetwindow = _GuiTarget($appWindow,"","",$handle) As you suggested I added the ControlGetHandle() to get the HWND/Handle value. This variable $handle, I have put as a last parameter value for your function _GuiTarget(). This is not clear to me why it accepts the handle value instead of the CONTROL ID, as is mentioned in your function description. Or is AutoIT always capable of working with the handle instead of the control ID ? This is all new to me. So feedback would be much appreciated. Anyhow, your function ANYGUI rocks !!! Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Dizzy Posted February 2, 2006 Share Posted February 2, 2006 Hi ptrex, your code looks great. I will use it in excel but i've got a little problem. I loose my focus. A workaround is a msgbox - but not very nice. Can you help me? Here is youre code with a german excel. expandcollapse popup#include <ANYGUI.au3> #include <guiconstants.au3> Opt("WinTitleMatchMode", 4) Opt("GUIOnEventMode", 1) $appWindow = WinGetHandle("classname=XLMAIN") $handle = ControlGetHandle("classname=XLMAIN", "", "EXCEL22") ;MsgBox(0,"",$handle) $Targetwindow = _GuiTarget($appWindow,"","",$handle) $btn = _TargetaddButton ( "Test Button", 800, 25, 80, 30,"","",$Targetwindow); GUICtrlSetOnEvent($btn[0], "Clicked") GUISetState(@SW_SHOW) _EndTarget() ;WinActivate("Microsoft Excel - Mappe1", "") $handle = ControlGetHandle("classname=XLMAIN", "", "XLDESK1") $Targetwindow = _GuiTarget($appWindow,"","",$handle) GUISetState(@SW_SHOW) _EndTarget() ;WinSetState("Microsoft Excel - Mappe1", "", @SW_ENABLE) ;ControlFocus("Microsoft Excel - Mappe1", "", "XLDESK1") MsgBox(0,"Help Window","Just to get the focus back",2) ;Send ("^G") ;Send ("F5") ;Send ("{ENTER}") While WinExists($Targetwindow) Sleep(100) If Not WinExists($Targetwindow) Then Exit EndIf WEnd Func Clicked() MsgBox(0,"TEST","OK") EndFunc CU Dizzy Link to comment Share on other sites More sharing options...
ptrex Posted February 3, 2006 Author Share Posted February 3, 2006 @Dizzy This code works on my system. Excel English version (Excel22 does not exist on my Excel, changed to 21) Than I did some cleaning up of your code and run this one. ; Working example for EXCEL 2002 English version ; PTREX 04/02/2006 #include <ANYGUI.au3> #include <guiconstants.au3> Opt("WinTitleMatchMode", 4) Opt("GUIOnEventMode", 1) $appWindow = WinGetHandle("classname=XLMAIN") $handle = ControlGetHandle("classname=XLMAIN", "", "EXCEL21") WinWaitActive("") $Targetwindow = _GuiTarget($appWindow,"","",$handle) $btn = _TargetaddButton ( "Test Button", 800, 25, 80, 30,"","",$Targetwindow); GUICtrlSetOnEvent($btn[0], "Clicked") GUISetState(@SW_SHOW) While WinExists($Targetwindow) Sleep(100) If Not WinExists($Targetwindow) Then Exit EndIf WEnd Func Clicked() MsgBox(0,"TEST","OK") EndFunc Success !! Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Dizzy Posted February 4, 2006 Share Posted February 4, 2006 @ptrex yes - my focus is back! I think i've to test, play and read a little more ... Thanks for your help! Dizzy 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