Sign in to follow this  
Followers 0
erez135

_GUICtrlTreeView_GetText - not active

20 posts in this topic

#1 ·  Posted (edited)

Hi,

I am running "devmgmt.msc" - windows application.

I want to get the item's property.

_GUICtrlTreeView_ClickItem - work's fine

_GUICtrlTreeView_GetFirstChild - work's fine

_GUICtrlTreeView_GetSelection - work's fine

Now:

I need the item name / description that i am click on using : _GUICtrlTreeView_GetText -

but i can't get it work.

I am try ControlTreeView function (get text) also - but i am fail to get the item text.

I will appreciate any help.

Thanks in advanced

Erez.

Edited by erez135

Share this post


Link to post
Share on other sites



Could you please post your code so we can have a look at it?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks...

#include "repository.au3"

#Include <GuiTreeView.au3>

ShellExecute("D:\WINDOWS\system32\devmgmt.msc ")

WinActive("Device Manager")

Sleep(1000)

WinActivate ("Device Manager")

Sleep(200)

$wHndle=WinGetHandle("Device Manager")

$hTree=ControlGetHandle($wHndle,"","[CLASS:SysTreeView32; INSTANCE:1]")

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hTree = ' & $hTree & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Sleep(100)

$node_first_item = _GUICtrlTreeView_GetFirstItem($hTree)

$node_first_child = _GUICtrlTreeView_GetFirstChild($hTree,$node_first_item)

_GUICtrlTreeView_ClickItem($hTree, $node_first_child)

Sleep(300)

$h_lsti=_GUICtrlTreeView_GetFirstChild($hTree, $node_first_item)

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $h_lsti = ' & $h_lsti & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

_GUICtrlTreeView_ClickItem($hTree, $h_lsti)

Sleep(1000)

$tx=_GUICtrlTreeView_GetText($node_first_child)

ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $tx = ' & $tx & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Share this post


Link to post
Share on other sites

The handle to the control was missing. So please change line

$tx=_GUICtrlTreeView_GetText($node_first_child)
to
$tx=_GUICtrlTreeView_GetText($hTree,$node_first_child)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for reply water.

I change it.

but still i don't get it work.

I recive empty string ("");

Thanks again

Share this post


Link to post
Share on other sites

I stripped down your script and this works fine for me:

#Include <GuiTreeView.au3>
ShellExecute("D:\WINDOWS\system32\devmgmt.msc ")
WinWait("Device Manager")
WinActivate ("Device Manager")
$wHndle=WinGetHandle("Device Manager")
$hTree=ControlGetHandle($wHndle,"","[CLASS:SysTreeView32; INSTANCE:1]")
$node_first_item = _GUICtrlTreeView_GetFirstItem($hTree)
$node_first_child = _GUICtrlTreeView_GetFirstChild($hTree,$node_first_item)
$tx=_GUICtrlTreeView_GetText($hTree,$node_first_child)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $tx = ' & $tx & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I copy/paste your script.

run it.

at application pop up.

but the results :

>"D:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Documents and Settings\Administrator\Desktop\driver_restart\test.au3" /autoit3dir "D:\Program Files (x86)\AutoIt3" /UserParams

+>15:19:02 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_2003/Service Pack 2 CPU:X64 ANSI)

>Running AU3Check (1.54.14.0) from:D:\Program Files (x86)\AutoIt3

+>15:19:02 AU3Check ended.rc:0

>Running:(3.3.0.0):):\Program Files (x86)\AutoIt3\autoit3.exe "D:\Documents and Settings\Administrator\Desktop\driver_restart\test.au3"

@@ Debug(10) : $tx =

>Error code: 0

+>15:19:03 AutoIT3.exe ended.rc:0

+>15:19:05 AutoIt3Wrapper Finished

>Exit code: 0 Time: 2.744

i am working on windows 2003 server 64 bit SP2-2.

could it be that i installed wrong autoit version ?

or autoit not supported this O.S ?

maybe the installation directory path - D:\Program Files (x86)\AutoIt3 is the problem ?

Share this post


Link to post
Share on other sites

So far everything looks fine to me. I've inserted some to see where the problem is:

#Include <GuiTreeView.au3>
ShellExecute("D:\WINDOWS\system32\devmgmt.msc ")
$RC = WinWait("Device Manager")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $RC = ' & $RC & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$RC = WinActivate ("Device Manager")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $RC = ' & $RC & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$wHndle=WinGetHandle("Device Manager")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $wHndle = ' & $wHndle & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$hTree=ControlGetHandle($wHndle,"","[CLASS:SysTreeView32; INSTANCE:1]")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hTree = ' & $hTree & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$node_first_item = _GUICtrlTreeView_GetFirstItem($hTree)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $node_first_item = ' & $node_first_item & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$node_first_child = _GUICtrlTreeView_GetFirstChild($hTree,$node_first_item)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $node_first_child = ' & $node_first_child & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$tx=_GUICtrlTreeView_GetText($hTree,$node_first_child)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $tx = ' & $tx & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$RC = WinClose($wHndle)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $RC = ' & $RC & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
I'm running Autoit 3.3.0.0 on Windows XP SP2 German, so my code and environment is a bit different.

Could you please post the Console after running my code?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks ..

>"D:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Documents and Settings\Administrator\Desktop\driver_restart\test.au3" /autoit3dir "D:\Program Files (x86)\AutoIt3" /UserParams

+>15:58:05 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_2003/Service Pack 2 CPU:X64 ANSI)

>Running AU3Check (1.54.14.0) from:D:\Program Files (x86)\AutoIt3

+>15:58:05 AU3Check ended.rc:0

>Running:(3.3.0.0):):\Program Files (x86)\AutoIt3\autoit3.exe "D:\Documents and Settings\Administrator\Desktop\driver_restart\test.au3"

@@ Debug(4) : $RC = 1

>Error code: 0

@@ Debug(6) : $RC = 1

>Error code: 0

@@ Debug(8) : $wHndle = 0x0009012E

>Error code: 0

@@ Debug(10) : $hTree = 0x00060178

>Error code: 0

@@ Debug(12) : $node_first_item = 0x038C3010

>Error code: 0

@@ Debug(14) : $node_first_child = 0x038C37C0

>Error code: 0

@@ Debug(16) : $tx =

>Error code: 0

@@ Debug(18) : $RC = 1

>Error code: 0

+>15:58:07 AutoIT3.exe ended.rc:0

+>15:58:08 AutoIt3Wrapper Finished

>Exit code: 0 Time: 2.771

Share this post


Link to post
Share on other sites

That's crazy :) Could you please expand the TreeView to the item you want to get the text of and post a ScreenShot?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#include <GUITreeView.au3>

ShellExecute('devmgmt.msc')
WinWaitActive('Device Manager')

$hWnd = WinGetHandle('Device Manager')
$hTree = ControlGetHandle($hWnd, '', 'SysTreeView321')

$hItem = _GUICtrlTreeView_GetFirstItem($hTree)
ConsoleWrite(_GUICtrlTreeView_GetText($hTree, $hItem) & @LF)
$hItem = _GUICtrlTreeView_GetFirstChild($hTree, $hItem)
ConsoleWrite(_GUICtrlTreeView_GetText($hTree, $hItem) & @LF)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

water,

without any relation to the results of this session, i would like to thank you for your effort and time.

I need to open "mellanox Connectx Adapters" and to enable /disable the driver - in loop

see attached file.

post-51684-1248005897742_thumb.jpg

Edited by erez135

Share this post


Link to post
Share on other sites

Hi erez135,

glad to be of service. I have received so much support from this forum myself that I would like to return some of the time and effort.

Everything looks fine to me. Maybe there is a bug in the 64Bit version of AutoIt :)

Do you have a 32Bit Windows server available to test it there?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes - it is working 100% on win2003 32 bit.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

OK, another approach. Lets directly search for the item you are looking for:

#Include <GuiTreeView.au3>
ShellExecute("D:\WINDOWS\system32\devmgmt.msc ")
$RC = WinWait("Device Manager")
$RC = WinActivate ("Device Manager")

$wHndle=WinGetHandle("Device Manager")
$hTree=ControlGetHandle($wHndle,"","[CLASS:SysTreeView32; INSTANCE:1]")

$hItemFound = _GUICtrlTreeView_FindItem($hTree, "Mellanox ConnectX Adapters")
If $hItemFound Then
    MsgBox(4160, "Information", "Item Found:" & @LF & "Handle: " & $hItemFound & @LF & "Text: " & _GUICtrlTreeView_GetText($hTree, $hItemFound))
Else
    MsgBox(4160, "Information", "Not Found")
EndIf
$RC = WinClose($wHndle)

Does it work?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I try it.

and the information box appear " Not Found" message appear.

Share this post


Link to post
Share on other sites

Could you test this new code on the 32bit server as well? Just to be sure there is no bug in my code.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Could you please have a look in the AutoIt help file -> Autoit -> Using AutoIt -> Running under Windows 4-bit Edition?

Have you beend asked at installation time to install the x64 version of AutoIt? If yes, then I think you are out of luck (for the moment) because the GuiTreeView UDF uses DLL calls a lot.

As the script runs fine on 32Bit systems I think you'll have to post a bug report as suggested in the help file.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes - i install it under 64 bit.

I will post a bug report as you suggested.

I will develope the application under win2003 32 bit at the current time.

I would like to Thank you again for your time and your patience .

This forum is very good and strong - thanks to people like you

Thanks and "shalom"

Erez

Share this post


Link to post
Share on other sites

Shalom and greetings from Austria

Thomas


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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