header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Question about PSSnapIn
Last Post 06 Apr 2010 07:55 AM by Joel "Jaykul" Bennett. 5 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
viviUser is Offline
New Member
New Member
Posts:2
Avatar

--
25 Mar 2010 09:18 PM
    Hello everyone!



    I'm a beginner regarding PowerShell but I'd like to ask all of you about a PSSnapIn I found on Internet. I've been checking and testing the Cmdlets for UI Automation (here the link: http://msdn.microsoft.com/en-us/mag...301.aspx). There is an application in that page which the cmdlets can be tested, but I wanted to test the cmdlets with other program (WiimoteConnect). When I tried to read a read-only textbox that is found on the bottom of the WiimoteConnect window with a cmdlet called get-textBox, the only thing I could get was the control name ("StatusStrip1") and not its content as a String. I was wondering if I'm making something wrong, or maybe the get-textBox doesn't work for read-only textboxs.



    I've already sent an e-mail to the author with my question, but I haven't get an answer. If anyone has worked with this and has the answer, I'd really appreciate their help :)



    WiimoteConnect can be found here if anyone is interested:
    http://www.wiimoteproject.com/index...view;id=14



    I also attach a screenshot.










    I'm sorry if I have grammatical mistakes... English isn't my first language :)




    George HowarthUser is Offline
    Basic Member
    Basic Member
    Posts:360
    Avatar

    --
    26 Mar 2010 01:04 AM
    The control you are obtaining a handle to is not a TextBox, it is a StatusStrip, hence why it is entitled "StatusStrip1". This will (or should) get the handle to the StatusStrip:

    $app = Get-Window "WiimoteConnect"
    $statusStrip = Get-Control $app "StatusStrip1"
    Write-Host "Handle to StatusStrip is " $statusStrip
    viviUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    05 Apr 2010 10:15 AM
    Thank you for your answer GWHowarth88! :)

    But I have a question... after I get the handle like you said, I write two lines more:

    $text = get-textBox $statusStrip
    write-host $text

    wishing for obtain the text "connected: 0" hehe... I was wondering if there is some method to obtain that "connected: 0" :)

    Thanks for your help! :)
    George HowarthUser is Offline
    Basic Member
    Basic Member
    Posts:360
    Avatar

    --
    06 Apr 2010 01:33 AM
    Try this (although I'm not sure if it'll work or not):

    $app = Get-Window "WiimoteConnect"
    $statusStripHandle = Get-Control $app "StatusStrip1"
    $statusStrip = [System.Windows.Forms.Control]::FromHandle($statusStripHandle)
    Write-Host $statusStrip.Text
    Joel "Jaykul" BennettUser is Offline
    Basic Member
    Basic Member
    Posts:112
    Avatar

    --
    06 Apr 2010 07:53 AM
    So, uhm ... that article (and my frustration at using his code), was part of the motivation for the WASP project, and I think you should just run over and get that before you go any further :)

    http://wasp.codeplex.com/

    Secondly, the problem you're having is that the "StatusStrip" is the PARENT of the control that has the text on it. StatusStrips don't have text themselves

    I'm pretty sure that you'll be able to just do this to get at the text (using WASP):

    Select-Window "WiimoteConnect" | select-control -recurse -title "StatusStrip1" | select-control
    Joel "Jaykul" BennettUser is Offline
    Basic Member
    Basic Member
    Posts:112
    Avatar

    --
    06 Apr 2010 07:55 AM
    (Whoops, Double Submit)
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer