Jump to content

Passing value then compare in function


Recommended Posts

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <string.au3>

Opt("WinTitleMatchMode", 4)

Local $title, $cstate, $valueEvaluate, $valueFound, $value

$test2 = "Question"

$text1 = "Are you sure you want day?"

$value = _TitleCheck($valueFound)

Func _TitleCheck($pass1)

    $title = WinGetTitle($test2)

    If WinExists($title, "") Then WinActivate($title, "")

    $Question = WinGetHandle($title, "")

    ;$cstate = StringInStr(WinGetText($valueFound), $text1 ) ;this code by itself work
    ;however instead I want to create a list to evaluate as below and return a match

    $cstate = WinGetText($valueFound) ; the value is there how

    Local $newcstate = listvalue($cstate)

    If $newcstate Then

        ConsoleWrite($newcstate & @CRLF & @CRLF)

        Run("notepad.exe")

    Else

        ConsoleWrite($newcstate & @CRLF & @CRLF)

        MsgBox(0, "", "")

    EndIf

EndFunc   ;==>_TitleCheck

;I want to compare in func listvalue a retun a match as  1 no match 0

Func listvalue($text1)

    $text1 = "Are you sure you want y?"

    $text2 = "what day it is"

    $text3 = " what month is today"

    Return ()

EndFunc   ;==>listvalue

 

Edited by antonioj84
Added code tags
Link to comment
Share on other sites

  • Moderators

antonioj84,

You have been here long enough to know that when you post code you shoulde use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You can use an array and use _Array functions (or a standard loop) :

#Include <Array.au3>

Global $aText[3] = ["Are you sure you want y?", "what day it is", "what month is today"]

If _ArraySearch($aText, "what day it is") <> -1 Then
    ConsoleWrite("text found")
Else
    ConsoleWrite("text not found")
EndIf

 

Link to comment
Share on other sites

;Credit to Jguinch

;This is my final code that work for me, if it can help someone
;the window title is "Question" there will be various messages on window pop up that
;will be captures with "wingettext", and stored in  "$valuefound" which is the text
;read from the windows  and "$text1" is the array containing the text to compare
;with.

 
 
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <string.au3>
Opt("WinTitleMatchMode", 4)
 
Global $title, $cstate, $valueEvaluate,$valueFound, $value
Local $test2 ="Question"
 
Global $text1[6]
$text1[0]= "I am home now1"
$text1[1]= "I am home now2"
$text1[2]= "I am home now3"
$text1[3]= "I am home now4"
$text1[4] ="Are you sure you want to Close the Store and start end of Day?"
$text1[5]= "I am home now5"
 
$value= _TitleCheck($valueFound)
 
 
Func _TitleCheck($pass1)
$title = WinGetTitle($test2)
If WinExists($title,"") Then WinActivate($title,"")
$Question = WinGetHandle($title,"")
 
for $i = 0 to UBound($text1) - 1
 
if  StringInStr(WinGetText($valueFound), $text1[$i] ) Then
 
  ConsoleWrite($text1[$i] & " :found" & @CRLF)
 
  Else
 
ConsoleWrite($text1[$i] &" :Not found" & @CRLF)
EndIf
 
next
 
EndFunc

 

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

×
×
  • Create New...