Jump to content

how to enter text into a string


Recommended Posts

i am making an autoit script to update blocklist manager. i have it working successfully, but i want to make it better. what i want todo is add the number of blocked ips and the error count(if any) to the final message box. but todo this i need to extract the information from blocklist manger. the other thing is that the number of blocked ips is dynamic. here is what my code looks like and i have attached a pic. can someone please post a snippet of code that shows how to extract the text so i can put it in a string variable?

; Prompt the user to run the script - use a Yes/No prompt

$answer = MsgBox(36, "Update Script", "This script will launch Blocklist Manager, update lists, and import to PeerGuardian, Run?")

; Check the user's answer to the prompt

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(0, "AutoIt", "OK. Bye!")

Exit

EndIf

; Run Blocklist

Run("C:\Program Files\Bluetack\Blocklist Manager\BlockMgr.exe")

; Wait for Blocklist Manager to become active

WinWaitActive("Blocklist Manager")

; Process Blocklists

Send ("^p")

; Wait for Blocklists to finish downloading

WinWaitActive("Blocklist Manager", "BLM Version: 2.7.7")

; Launch Blocklist Converter

Send ("^v")

; Wait for Blocklist Manager converter to become active

WinWaitActive("Convert from Memory Array...")

; Start Blocklist Converter

Send ("!v")

; Wait for Conversion to Finish by changing focus, waiting for "Conversion Complete" then changing focus back to "Convert from Memory Array..."

WinActivate("Blocklist Manager")

WinWaitActive("Blocklist Manager", "Conversion Complete.")

WinActivate("Convert from Memory Array...")

; Save Output As

Send ("!a")

; Wait for Save As window to become active

WinWaitActive("Save As")

Sleep(1000)

; Save file as Paranoid Blocklist.p2p

Send("Paranoid Blocklist.p2p")

Sleep(1000)

Send("{ENTER}")

Sleep(1000)

Send("!y")

; Wait for save to finish

WinWaitClose("Save As")

; Close convert from memory array window

WinClose("Convert from Memory Array...")

WinWaitClose("Convert from Memory Array...")

; Close blocklist manager

WinClose("Blocklist Manager")

WinWaitClose("Blocklist Manager")

;Show Final Prompt and number of blocked IP's

MsgBox(64, "Update Script", "Update Completed Succesfully!")

post-45156-1232429438_thumb.gif

Link to comment
Share on other sites

i was looking at WinGetText ( "title" [, "text"] ) ,but how does this work if the text is dynamic? i was thinking that i could use StringRight along with it, because the begining of the text will always start as "total ip count:" since this is my 1st time using autoit, im hoping someone can post some example snippets of code. thank you everyone! :)

Link to comment
Share on other sites

please use autoit or code tags!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

i was looking at WinGetText ( "title" [, "text"] ) ,but how does this work if the text is dynamic? i was thinking that i could use StringRight along with it, because the begining of the text will always start as "total ip count:" since this is my 1st time using autoit, im hoping someone can post some example snippets of code. thank you everyone! :)

Try some options.

Opt("option",value)

WinDetectHiddenText Specifies if hidden window text can be "seen" by the window matching functions.

0 = Do not detect hidden text (default)

1 = Detect hidden text

WinSearchChildren Allows the window search routines to search child windows as well as top-level windows.

0 = Only search top-level windows (default)

1 = Search top-level and child windows

WinTextMatchMode Alters the method that is used to match window text during search operations.

1 = Complete / Slow mode (default)

2 = Quick mode

In quick mode AutoIt can usually only "see" dialog text, button text and the captions of some controls. In the default mode much more text can be seen (for instance the contents of the Notepad window).

If you are having performance problems when performing many window searches then changing to the "quick" mode may help.

WinTitleMatchMode Alters the method that is used to match window titles during search operations.

1 = Match the title from the start (default)

2 = Match any substring in the title

3 = Exact title match

4 = Advanced mode, see Window Titles & Text (Advanced)

-1 to -4 = force lower case match according to other type of match.

Link to comment
Share on other sites

im a total noob to autoit. please elaborate. if you look at the highlited text in the attached pic, i basically just want the numbers after "total ip count" to be assigned to a string. i know that autoit can read the text if you look at the 6th block of posted code. i dont want to sound like a dumass but can you post some code for me?(im a pc technician, not a programmer :) ) thank you very much!

Link to comment
Share on other sites

im a total noob to autoit. please elaborate. if you look at the highlited text in the attached pic, i basically just want the numbers after "total ip count" to be assigned to a string. i know that autoit can read the text if you look at the 6th block of posted code. i dont want to sound like a dumass but can you post some code for me?(im a pc technician, not a programmer :) ) thank you very much!

Is this visible text seen by the AutoIt Window Info?
Link to comment
Share on other sites

new problem. how can i remove the commas in a string of numbers? for example, if the clipboard contains 123,456,789,123

$DenyIPString = ClipGet()

$DenyIPCount = StringReplace("$DenyIPString", ",", "")

this does not seem to be working for me. ive also tried number("$DenyIPString") any suggestions would be greatly appreciated!

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