Jump to content

New to autoit scriptting - need help


Recommended Posts

i'm new to autoit scriptting and cant seem to get some functions to work right if i can get some help that would be awsome... i have tryed looking at other forums and threads but cant seem to get help.

what i have done so far is this script... below

what it should do...

if script is run...it will find a active "word.doc" and open it up... then when F1 key is pressed... the script will start running....

Step 1 of the script - looks within the range ($Left, $Top, $Right, $Bottom) for any red text/pixel color, if there are any, it should add 1 to a status list then click in the front of the red text/pixcel and hit "Enter" 2 times then move on to step 2....

Step 2 of the script - looks within the range ($Left, $Top, $Right, $Bottom) for any blue text/pixel color, if there are any, it should add 1 to a status list then click in the front of the blue text/pixcel and hit "Enter" 2 times then move on to step 3....

Step 3 of the script - looks within the range ($Left, $Top, $Right, $Bottom) for any green text/pixel color, if there are any, it should add 1 to a status list then click in the front of the green text/pixcel and hit "delete" key once and wait for 1 sec then hit "ctrl + HOME" to go to the top of the doc again.

what else i want it to do is....if any green is found... on steps 3 it will do everything it should and return to the top of the doc and end the while loop in the script and restarts the loop from the top of the while fuction (so it should end loop then starts at step 1 again)... i cant figure out what to do to get this to work....

what i have think of...

i was thinking of adding a "ExitLoop" at the end of "Send("^HOME")" (which moves to the top of the doc again) on step 3, but that would only exit the loop and stop the script, so is there another command i should use so that it does not end the loop but restarts the loop from the begining?

Any help would be great and greatful, thanks again for the time to read all this junk. ;)

WINACTIVATE("Word.doc") ;opens active program
Global $Paused
HotKeySet("F1","StartPause")  ;STARTS and PAUSE Script
HotKeySet("F2", "Stop")
$start = False

$Left = 300                   
$Top = 0                          
$Right = 1920                   
$Bottom = 1080

$TotalRed = 0
$TotalBlue = 0
$TotalGreen = 0

$red = 0xA56DF1
$blue = 0x6969FF
$green = 0xB5F773


While = True
    if($start) Then
$SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $red)  ;searches for red color
If Not @error Then
      $TotalRed += 1
      UpdateStatus()
      MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)
      Send("{Enter 2}")
EndIf
$SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $blue)  ;searches for blue color
If Not @error Then
      $TotalBlue += 1
      UpdateStatus()
      MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)
      Send("{Enter 2}")
EndIf
$SearchResult = PixelSearch($Left, $Top, $Right, $Bottom, $green)  ;searches for green color
If Not @error Then
      $TotalGreen += 1
      UpdateStatus()
      MouseClick("left", $SearchResult[0], $SearchResult[1], 1, 10)
      Send("{del}")
      Sleep(1000)
      Send("^HOME")
EndIf
      Send("{DOWN down}")
      Sleep(2000)
      Send("{DOWN up}")
EndIf
Wend



Func UpdateStatus()
   ToolTip("Red "&$TotalRed&" : "&$TotalBlue&" Blue, "&$TotalGreen" Greens, ", 380, 37)
EndFunc

Func StartPause()
        $start = Not $start
        While Not $start
            Sleep(100)
            ToolTip("Scan Paused",887, 60)
        WEnd
   UpdateStatus()
EndFunc

Func Stop()
    Exit 0
EndFunc
Edited by blu3dragon619
Link to comment
Share on other sites

  • Moderators

blu3dragon619,

Welcome to the AutoIt forum. ;)

But please do NOT bump your posts within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. :)

As to your problem, it would be a good idea to post an example of the sort of Word document you are working with as it is difficult to code anything without a good idea of what it is we are trying to do. Help us to help you. :)

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

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