Jump to content
Sign in to follow this  
styles3000

How Do I Tag Everything?

Recommended Posts

styles3000

.......My next challenge is ....In a nutshell: I want AutoIT to select and copy a list of keywords,like such.....

Keyword 1

Keyword 2

Keyword 3

Keyword 4

Keyword 5

Keyword 6

Keyword 7

Keyword 8

Keyword 9

Keyword 10

all the way to Keyword N and beyond.

After the keywords are copied I want to place them in a notepad doc. Here's what I want the

Function to kick in. When the words are placed in the doc, I want the function to tag all the keywords incrementally.

Like such.........

<tag1>Keyword 1<tag1/>

<tag2>Keyword 2<tag2/>

<tag3>Keyword 3<tag3/>

<tag4>Keyword 4<tag4/>

<tag5>Keyword 5<tag5/>

<tag6>Keyword 6<tag6/>

<tag7>Keyword 7<tag7/>

<tag8>Keyword 8<tag8/>

<tag9>Keyword 9<tag9/>

<tag10>Keyword 10<tag10/>

So, if 1,000 keywords , I want all the keywords up to the 1,000th to be wrapped in tags. <tag>keyword 1,000<tag1,000/>.

Does anyone have any idea how to do this?

Edited by styles3000

Share this post


Link to post
Share on other sites
MrCreatoR

I want AutoIT to select and copy a list of keywords,like such

Select and Copy? Where from?

I want to place them in a notepad doc. Here's what I want the

Function to kick in. When the words are placed in the doc, I want the function to tag all the keywords incrementally

What you mean by notepad doc? a text file?

Try this:

$sData = _
    "Keyword 1" & @CRLF & _
    "Keyword 2" & @CRLF & _
    "Keyword 3" & @CRLF & _
    "Keyword 4" & @CRLF & _
    "Keyword 5" & @CRLF & _
    "Keyword 6" & @CRLF & _
    "Keyword 7" & @CRLF & _
    "Keyword 8" & @CRLF & _
    "Keyword 9" & @CRLF & _
    "Keyword 10"

$sData = StringRegExpReplace($sData, "(Keyword )(\d+)", "<tag\2>\1\2<tag\2/>")

;ConsoleWrite($sData & @CRLF)
FileWrite("File.txt", $sData)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites
styles3000

Yes, a text file.

Select and Copy? Where from?

What you mean by notepad doc? a text file?

Try this:

$sData = _
    "Keyword 1" & @CRLF & _
    "Keyword 2" & @CRLF & _
    "Keyword 3" & @CRLF & _
    "Keyword 4" & @CRLF & _
    "Keyword 5" & @CRLF & _
    "Keyword 6" & @CRLF & _
    "Keyword 7" & @CRLF & _
    "Keyword 8" & @CRLF & _
    "Keyword 9" & @CRLF & _
    "Keyword 10"

$sData = StringRegExpReplace($sData, "(Keyword )(\d+)", "<tag\2>\1\2<tag\2/>")

;ConsoleWrite($sData & @CRLF)
FileWrite("File.txt", $sData)

Share this post


Link to post
Share on other sites
styles3000

Yes, a text file.

I'm going to be placing 1,000 to 2,000 keywords in one text file with AutoIT. I'm going to copying keywords from a text file and pasting them in another text file. When AutoIT paste them into the text I just want them tagged. I need a little help with placing the code in my script. Could you explain it to me in laments terms? Below is the basic format of code I'll be using. The first batch of code is code unbroken, the second is the code broken up .

#region --- ScriptWriter generated code Start --- 
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("Program Manager","FolderView")
If Not WinActive("Program Manager","FolderView") Then WinActivate("Program Manager","FolderView")
WinWaitActive("Program Manager","FolderView")
MouseClick("left",111,340,2)
WinWait("Document 1 - Notepad","")
If Not WinActive("Document 1 - Notepad","") Then WinActivate("Document 1 - Notepad","")
WinWaitActive("Document 1 - Notepad","")
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}")
MouseMove(293,16)
MouseDown("left")
MouseUp("left")
WinWait("Program Manager","FolderView")
If Not WinActive("Program Manager","FolderView") Then WinActivate("Program Manager","FolderView")
WinWaitActive("Program Manager","FolderView")
MouseClick("left",115,265,2)
WinWait("Document 2 - Notepad","")
If Not WinActive("Document 2 - Notepad","") Then WinActivate("Document 2 - Notepad","")
WinWaitActive("Document 2 - Notepad","")
Send("{CTRLDOWN}v{CTRLUP}")
MouseMove(292,15)
MouseDown("left")
MouseUp("left")
WinWait("Notepad","The text in the D:\D")
If Not WinActive("Notepad","The text in the D:\D") Then WinActivate("Notepad","The text in the D:\D")
WinWaitActive("Notepad","The text in the D:\D")
MouseMove(161,124)
MouseDown("left")
MouseUp("left")
#endregion --- ScriptWriter generated code End ---

#region --- ScriptWriter generated code Start --- 
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("Program Manager","FolderView")
If Not WinActive("Program Manager","FolderView") Then WinActivate("Program Manager","FolderView")
WinWaitActive("Program Manager","FolderView")
MouseClick("left",111,340,2)
WinWait("Document 1 - Notepad","")
If Not WinActive("Document 1 - Notepad","") Then WinActivate("Document 1 - Notepad","")
WinWaitActive("Document 1 - Notepad","")
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}")

Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}")<<<<This is where the keywords will be copied from

MouseMove(293,16)
MouseDown("left")
MouseUp("left")
WinWait("Program Manager","FolderView")
If Not WinActive("Program Manager","FolderView") Then WinActivate("Program Manager","FolderView")
WinWaitActive("Program Manager","FolderView")
MouseClick("left",115,265,2)
WinWait("Document 2 - Notepad","")
If Not WinActive("Document 2 - Notepad","") Then WinActivate("Document 2 - Notepad","")
WinWaitActive("Document 2 - Notepad","")
Send("{CTRLDOWN}v{CTRLUP}")

Send("{CTRLDOWN}v{CTRLUP}")<<<<This is where the keywords will be pasted

MouseMove(292,15)
MouseDown("left")
MouseUp("left")
WinWait("Notepad","The text in the D:\D")
If Not WinActive("Notepad","The text in the D:\D") Then WinActivate("Notepad","The text in the D:\D")
WinWaitActive("Notepad","The text in the D:\D")
MouseMove(161,124)
MouseDown("left")
MouseUp("left")
#endregion --- ScriptWriter generated code End ---

Share this post


Link to post
Share on other sites
qazwsx

why don't you use fileread and filewrite? It should be much more reliable.

Share this post


Link to post
Share on other sites
trancexx

I'm going to copy all the code from here and save it. And every now and then I'm gonna search for it and open those scripts and just look at the code... and look some more.

Also I'm taking a screenshot of this thread so that I have that kind of memory on this. Will save as bitmap, max. resolution. I mean, bitmap worthy for sure - this is above jpeg.

Sticky potential also.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
ofLight

#include <file.au3>


_CreateTaggedKeywords()








Func _CreateTaggedKeywords()
    Dim $aRecords
    $PthFile = 'C:\Documents and Settings\ofLight\Desktop\Keywords.txt' ;Full path and filename to read
    $outputFileName = 'C:\Documents and Settings\ofLight\Desktop\TAGGED_Keywords.txt'

    If Not _FileReadToArray($PthFile,$aRecords) Then
       MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
       Exit
    EndIf
    
    $file = FileOpen($outputFileName, 2)
    For $x = 1 to $aRecords[0]
        FileWriteLine($file, '<tag'&$x&'>'&$aRecords[$x]&'<tag'&$x&'/>' & @CRLF)
    Next
    FileClose($file)
EndFunc


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
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
Sign in to follow this  

×