Jump to content

_GUICtrlListBox_FindString


 Share

Recommended Posts

Hi all,

Below code msgbox always show equal. Please advice.

For  $i = 0 To $Num
     $MYEditText = _GUICtrlListBox_ClickItem ($LHandle,$i ,"left") ;work fine
     $MyWantedText1 = ControlGetText($Handle,"",$MYEditText )      ;work fine
     ;MsgBox (0 , "" , $MyWantedText1)
     If $MyWantedText1 <> $hsfserver Then
        MsgBox(32,'',"equal")
     Else
        MsgBox(32,'',"Not equal")
     EndIf
  Next

 

Link to comment
Share on other sites

@Rammanan

You can't use ControlGetText() in that way, since _GUICtrlListBox_ClickItem() doesn't return any value.

You could use _GUICtrlListBox_SetSel() to select your item(s) in your ListBox, and immediately after use _GUICtrlListBox_GetSelItemsText() to get the text of the selected item(s).

Try it, and let us know :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@FrancescoDiMuro

FYI i'm not get value from listbox box because the return from listbox is in japanes or somthing. So i get value from editbox.

So above code will select row and get value from edit box.(Work fine). Problem is  below code always go for equal.

$MyWantedText1 is value that i already have.

If $MyWantedText1 <> $hsfserver Then
        MsgBox(32,'',"equal")
     Else
        MsgBox(32,'',"Not equal")
     EndIf

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi @FrancescoDiMuro

Sorry for late reply. i just back to work. Below are the full code.

Always get not equal. Please advise

Local $ttlWindow = "DSD Window UserInterface (Ver 1.16.1) - ntmmm"
Local $cidList = "[CLASS:ListBox; INSTANCE:1]"
Local $cidEdit = "[CLASS:Edit; INSTANCE:3]"
Local $LHandle = ControlGetHandle($ttlWindow, "", "[CLASS:ListBox; INSTANCE:1]")
Local $Handle = ControlGetHandle($ttlWindow, "", "[CLASS:Edit; INSTANCE:3]")
Local $num = _GUICtrlListBox_GetCount($LHandle)
Local $NumForLines = $Num
Local $boolCheck = 0;
;=========================================
Local $hsfserver = "LSD_8_INCH"
Local $i = 0
;=========================================
;=========================================
WinActivate("DSD Window UserInterface (Ver 1.16.1) - ntmmm")
WinWaitActive("DSD Window UserInterface (Ver 1.16.1) - ntmmm")
$hdlWindow = WinGetHandle($ttlWindow)
 $NumForLines -= $NumForLines
  For  $i = 0 To $Num
     $MYEditText = _GUICtrlListBox_ClickItem ($LHandle,$i ,"left") ;work fine
     $MyWantedText1 = ControlGetText($Handle,"",$MYEditText )      ;work fine
     MsgBox (0 , "" , $MyWantedText1)
     If $MyWantedText1 <> $hsfserver Then
        MsgBox(32,'',"equal")
     Else
        MsgBox(32,'',"Not equal")
     EndIf

  Next

 

Edited by Rammanan
Link to comment
Share on other sites

@Rammanan

Logically, these lines of code

If $MyWantedText1 <> $hsfserver Then
    MsgBox(32,'',"equal")
Else
    MsgBox(32,'',"Not equal")
EndIf

should be

If $MyWantedText1 = $hsfserver Then
    MsgBox(32,'',"equal")
Else
    MsgBox(32,'',"Not equal")
EndIf

; Or

If $MyWantedText1 <> $hsfserver Then
    MsgBox(32,'',"Not equal")
Else
    MsgBox(32,'',"Equal")
EndIf

Run these lines of code and you'll see the correct result from your script ;)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@Rammanan

ControlGetText() needs the Control ID of your edit control, so, instead of passing $MyEditText to the function, which is a "blank" variable, you should pass $cidEdit, which is the Control ID of the edit you are getting the text from.

Try that and let us know :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Hi all expert,

Really thanks for you all help me to solve on this problem.

Below are the final code that  work fine.

WinActivate("DSD Window UserInterface (Ver 1.16.1) - ntmmm")
    WinWaitActive("DSD Window UserInterface (Ver 1.16.1) - ntmmm")
    $NumForLines -= $NumForLines
    $hdlWindow = WinGetHandle($ttlWindow)

    For $i = 0 To $Num
         $open = FileOpen("C:\recipe.txt",1)
         $MYEditText = _GUICtrlListBox_ClickItem ($L
         Handle,$i) ;(Click ListBox)
         $MyWantedText1 = ControlGetText($Handle,"","");(Get recepi from editbox)
         $file = FileWrite($open,$MyWantedText1 & @CRLF) ;(Write test at .txt)
      Next

      Dim $aRecords
        If Not _FileReadToArray("C:\recipe.txt",$aRecords) Then ;(Read txt file at local c)
           MsgBox(4096,"Error", " Error reading log to Array   error:" & @error)
           Exit
        EndIf

         ;$aArray = _ArrayDisplay( $aRecords, "Entries left in the array")
      _ArrayPop($aRecords)        ;(Delete last entry at array)
         ;$aArray = _ArrayDisplay($aRecords, "Entries left in the array" )

      $Search = _ArraySearch($aRecords, $hsfserver,0,0,0,1) ; (Search for string at array)
      If @error Then
          MsgBox(4096,"Error", "No Recipe Found At List Please Inform To Engineer")
         ;MsgBox(0, "", $aRecords[$Search] & 'found in row: ' & $Search)
      $int = ($Search) - (1) ;( - 1)
         ;MsgBox(32,'',$int)
      $loadrecipe = _GUICtrlListBox_ClickItem ($LHandle,$int) ;(select recepi)
      FileDelete("C:\recipe.txt")

 

Link to comment
Share on other sites

Cheers. 

Man well done you dont gived up. 

 

That’s how you learn autoIT.

 

:lmao:

 

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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