Jump to content

[HELP] Find text in frame


Recommended Posts

post-60307-0-33152900-1303942582_thumb.p

I want to code a tool for my work

I'm thinking i will have a frame on my tool for input data:

aaaaaaaaaaa|cccccc|dddddddd

bbbbbbbb|cccccc|eeeeeeeeeeeeeeeeeeeeee

...............

i want to find keyword "ccccccc" in that frame.

Please help me.

Sorry my English very bad

Edited by VicVietCorp
Link to comment
Share on other sites

i wrote this code to tell you how many times it occurs in the data, as monoscout999 said check out what StringSplit() and you can change what its looking for. hope it helps :unsure:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <Constants.au3>

HotKeySet("{enter}", "button1")
$Form1 = GUICreate("search", 600, 350)
$edit1= GUICtrlCreateEdit("", 5, 5, 500, 150)
$input1= GUICtrlCreateInput("search for what?", 5, 160, 500, 22)
$edit2 = GUICtrlCreateEdit("Results", 5, 185, 500, 150)
$button = GUICtrlCreateButton("open a txt file", 510, 5, 90, 30)
$button2 = GUICtrlCreateButton("search", 510, 60, 90, 30)
GUISetState(@SW_SHOW)

while 1
$msg=GUIGetMsg()
If $msg = -3 Then Exit
If $msg = $button Then button()
If $msg = $button2 Then button1()

WEnd

Func button()
    $message=("click shift to Select multiple files.")
    $var=FileOpenDialog($message,@desktopcommondir & "\","lists (*.txt)")
    $file=FileRead($var)
If @error Then
    MsgBox(0,"","no file(s) were selected")
Else
    GUICtrlSetData($edit1, $file)
EndIf
EndFunc

Func button1()
    $search=ControlGetText("","",$input1)
    $data=ControlGetText("","",$edit1)
    $a=StringSplit($data,$search,1)
    ControlSetText("","",$edit2, "occures " & $a[0]-1 & " times")    ; the -1 is so it doesn't count the input box as an entry
EndFunc
Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Link to comment
Share on other sites

i wrote this code to tell you how many times it occurs in the data, as monoscout999 said check out what StringSplit() and you can change what its looking for. hope it helps :unsure:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <Constants.au3>

HotKeySet("{enter}", "button1")
$Form1 = GUICreate("search", 600, 350)
$edit1= GUICtrlCreateEdit("", 5, 5, 500, 150)
$input1= GUICtrlCreateInput("search for what?", 5, 160, 500, 22)
$edit2 = GUICtrlCreateEdit("Results", 5, 185, 500, 150)
$button = GUICtrlCreateButton("open a txt file", 510, 5, 90, 30)
$button2 = GUICtrlCreateButton("search", 510, 60, 90, 30)
GUISetState(@SW_SHOW)

while 1
$msg=GUIGetMsg()
If $msg = -3 Then Exit
If $msg = $button Then button()
If $msg = $button2 Then button1()

WEnd

Func button()
    $message=("click shift to Select multiple files.")
    $var=FileOpenDialog($message,@desktopcommondir & "\","lists (*.txt)")
    $file=FileRead($var)
If @error Then
    MsgBox(0,"","no file(s) were selected")
Else
    GUICtrlSetData($edit1, $file)
EndIf
EndFunc

Func button1()
    $search=ControlGetText("","",$input1)
    $data=ControlGetText("","",$edit1)
    $a=StringSplit($data,$search,1)
    ControlSetText("","",$edit2, "occures " & $a[0]-1 & " times")    ; the -1 is so it doesn't count the input box as an entry
EndFunc

Thank you very much

I'm thinking

My tool have 4 input label

Label 1:

Input data by many line

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|222222222|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|33333333|cccccccccccccc

Label 2:

Example: |111111|

Input keyword

Label 3:

Show resutl by line

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|111111|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|111111|ccccccccccccc

Label 4:

Show not result by line

aaaaaaaaaaaaaaaaaaaa|222222222|cccccccccccccc

aaaaaaaaaaaaaaaaaaaa|33333333|cccccccccccccc

Link to comment
Share on other sites

As monoscout999 said in post use StringSplit() in the help file. It will tell you exactly how to do it Posted Image

Using StringSplit will put the data into an array. The first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) is what you need as you can see few lines down

$strings = StringSplit("aaaaaaaaaaa|cccccc|dddddddd", "|")
;$strings[1] contains "aaaaaaaaaaa"
;$strings[2] contains "cccccc" <========= This would be what you looking for
;$strings[3] contains "dddddddd"
Edited by Jayson
Link to comment
Share on other sites

I am sorry to say this but I'll not write everything for you. Try at least something and if you still ran into a problem we're here to help you ! Posted Image

If you want someone to make it for you, you can ask here.

Edited by Jayson
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...