Jump to content

Newbie Here


Recommended Posts

Hello,

I'm trying to write my first 'If' statement when certain windows pop up. I want to use the windows as variables because based on the condition of the internet, I get different windows at different times. I already have the scripts ready to run, I just need to know how to arrange and tag my scripts 1 and 2 so when the windows come up they can be automatically directed. I don't know if I did this right below at all. If the msgbox that says (HyperVRE, 10 keyword selected'), I want to it to proceed to script 2. If the msgbox that says (HyperVRE, 0 or 1 keyword selected'), I want to it to proceed to script 1b. I've placed a pdf document for a clearer view of what I'm trying to accomplish.

$var= WinWait(HyperVRE, ")

If $var= WinWait(HyperVRE, 10 keyword selected')

Then proceed to script 2

(How do I include and make AutoIT go to script 2?)

If $var= WinWait(HyperVRE, 0 keyword selected')

Then proceed to script 1b (How do I include and make AutoIT go to script 1b?)

If $var= WinWait(HyperVRE, 1 keyword selected')

Then proceed to script 1b (How do I include and make AutoIT go to script 1b?)

EndIf

AutoIT_Assistance.pdf

Link to comment
Share on other sites

Maybe...

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100) ; save CPU

WEnd

; Functions-----------


Func script_2()
    MsgBox(4096, "", "Script 2")
EndFunc   ;==>script_2

Func script_1b()
    MsgBox(4096, "", "Script 1b")
EndFunc   ;==>script_1b

8)

NEWHeader1.png

Link to comment
Share on other sites

Should I just place the additional scripts below as I've done?

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100); save CPU

WEnd

; Functions-----------


Func script_2()
    MsgBox(4096, "", "Script 2")
EndFunc  ;==>script_2

Func script_1b()
    MsgBox(4096, "", "Script 1b")
EndFunc  ;==>script_1b


--------------------------------------------------------------------------
                                                   This is Script 1b

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here  
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 


---------------------------------------------------------------------------
                                                         This is Script 2

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here

Maybe...

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100) ; save CPU

WEnd

; Functions-----------


Func script_2()
    MsgBox(4096, "", "Script 2")
EndFunc   ;==>script_2

Func script_1b()
    MsgBox(4096, "", "Script 1b")
EndFunc   ;==>script_1b

8)

Link to comment
Share on other sites

You want to do

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100); save CPU

WEnd

; Functions-----------


Func script_2()
;   --------------------------------------------------------------------------
;                                                  This is Script 2

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here  
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 

EndFunc;==>script_2

Func script_1b()
;   ---------------------------------------------------------------------------
;                                                        This is Script 1b

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here
EndFunc;==>script_1b

Edited by leftler
Link to comment
Share on other sites

Or should I do it like this?

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100); save CPU

WEnd

; Functions-----------


Func script_2()
     This is Script 2

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
EndFunc  ;==>script_2

Func script_1b()
    This is Script 1b
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
EndFunc  ;==>script_1b

Maybe...

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100) ; save CPU

WEnd

; Functions-----------


Func script_2()
    MsgBox(4096, "", "Script 2")
EndFunc   ;==>script_2

Func script_1b()
    MsgBox(4096, "", "Script 1b")
EndFunc   ;==>script_1b

8)

Link to comment
Share on other sites

Hey Fellas,

I'm having some problems with the main script transitioning from the main script into script_2().

Could you take a look at it to see what I need to add or take away in regards to the winwaits? When I run it, it, I'm expecting it to proceed to script_2() but it just pauses at the coordinates of my last MouseMove.To my understanding, when it does that(pauses) its waiting for something,right? I have a lot of " ; " within the code because I want to make sure the transition into Function script_2 works before I move on to the other one.

I'm also thinking ,being that I have no mouse coordinates(in the the script I'm coming from) directing the mouse to click the Msgbox.(rather,they're located in the script we're transitioning to) I think it doesn't know how to get to script_2.

I'm thinking, the function script_2 might just kick in after the Msgbox is clicked.

MouseMove(611, 342) ;this is when the cursor moves to the add to master list button.

MouseDown("left")

MouseUp("left")

;WinWait("HyperVRE", "");wait for the window to become active, the text is not important at this stage

WinWait("HyperVRE","10 Selected keywords")

If Not WinActive("HyperVRE","10 Selected keywords") Then WinActivate("HyperVRE","10 Selected keywords")

WinWaitActive("HyperVRE","10 Selected keywords")

While 1

If WinWait("HyperVRE", "10 keyword selected keywords") Then

script_2()

EndIf

;If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then

; script_1b()

;EndIf

;Sleep(100); save CPU

WEnd

#Region --- ScriptWriter generated code Start ---
;Title:Master Script
;Note:In this script,HyperVRE needs to be manually opened first before you run the script.
;You also need to have your Sony Keywords Notepad document opened and placed in the left hand side.
;This is the very first script to run in the AutoIT/HyperVRE project. This script can be a loop, but remember if this script is to
;loop you must change the coordinates for each keyword on the WinWait("Sony Keywords - Notepad", "")
;page so it could be a new keyword entering the loop each time. 
Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
WinWait("Sony Keywords - Notepad", "")
If Not WinActive("Sony Keywords - Notepad", "") Then WinActivate("Sony Keywords - Notepad", "")
WinWaitActive("Sony Keywords - Notepad", "")
MouseMove(61, 57)
Sleep(2000)
MouseDown("left")
MouseMove(-2, 62)
MouseUp("left")
Send("{CTRLDOWN}c{CTRLUP}")
WinWait("Program Manager", "FolderView")
If Not WinActive("Program Manager", "FolderView") Then WinActivate("Program Manager", "FolderView")
WinWaitActive("Program Manager", "FolderView")
MouseMove(456, 579)
Sleep(2000)
MouseDown("left")
MouseUp("left")
WinWait("HyperVRE - Convert your content into cash", "")
If Not WinActive("HyperVRE - Convert your content into cash", "") Then WinActivate("HyperVRE - Convert your content into cash", "")
WinWaitActive("HyperVRE - Convert your content into cash", "")
MouseMove(202, 129)
MouseDown("left")
MouseUp("left")
WinWait("Step 1 - Keyword Selection", "")
If Not WinActive("Step 1 - Keyword Selection", "") Then WinActivate("Step 1 - Keyword Selection", "")
WinWaitActive("Step 1 - Keyword Selection", "")
MouseMove(276, 166);cursor moves over the 'suggest keywords'button.
MouseDown("left")
MouseUp("left")
Send("{CTRLDOWN}v{CTRLUP}")
MouseMove(196, 123); keyword is placed in box 
MouseDown("left")
MouseUp("left")
WinWait("Keyword Suggestion Tool", "")
If Not WinActive("Keyword Suggestion Tool", "") Then WinActivate("Keyword Suggestion Tool", "")
WinWaitActive("Keyword Suggestion Tool", "")
Sleep(1000)
MouseMove(329, 175);this is where the mouse moves over the "get keywords" button.
MouseDown("left")
Sleep(2000)
MouseUp("left")
Sleep(10000)
MouseMove(38, 230);this is where the cursor is moved to select the first keyword.
Sleep(2000)
MouseDown("left");this is where the first keyword is selected
MouseUp("left")
MouseMove(35, 251)
Sleep(2000)
MouseDown("left");this is where the second keyword is selected
MouseUp("left")
MouseMove(35, 268)
Sleep(2000)
MouseDown("left");this is where the third keyword is selected
MouseUp("left")
MouseMove(35, 286)
Sleep(2000)
MouseDown("left");this is where the fourth keyword is selected
MouseUp("left")
MouseMove(35, 307)
Sleep(2000)
MouseDown("left");this is where the fifth keyword is selected
MouseUp("left")
MouseMove(35, 324)
Sleep(2000)
MouseDown("left");this is where the sixth keyword is selected
MouseUp("left")
MouseMove(36, 344)
Sleep(2000)
MouseDown("left");this is where the seventh keyword is selected
MouseUp("left")
MouseMove(38, 363)
Sleep(2000)
MouseDown("left");this is where the eigth keyword is selected
MouseUp("left")
MouseMove(38, 379)
Sleep(2000)
MouseDown("left");this is where the nineth keyword is selected
MouseUp("left")
MouseMove(38, 394)
Sleep(2000)
MouseDown("left");this is where the tenth keyword is selected
MouseUp("left")
MouseMove(611, 342);this is when the cursor moves to the add to master list button.
MouseDown("left")
MouseUp("left")
;WinWait("HyperVRE", "");wait for the window to become active, the text is not important at this stage
WinWait("HyperVRE","10 Selected keywords")
If Not WinActive("HyperVRE","10 Selected keywords") Then WinActivate("HyperVRE","10 Selected keywords")
WinWaitActive("HyperVRE","10 Selected keywords")
While 1

    If WinWait("HyperVRE", "10 keyword selected keywords") Then 
       script_2()
    EndIf
   ;If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
    ;   script_1b()
   ;EndIf

   ;Sleep(100); save CPU

WEnd
; Functions-----------


Func script_2()
;   --------------------------------------------------------------------------
;                                                  This is Script 2


 
;Opt("WinWaitDelay",100)
;Opt("WinTitleMatchMode",4)
;Opt("WinDetectHiddenText",1)
;Opt("MouseCoordMode",0)
;WinWait("HyperVRE","10 Selected keywords")
;If Not WinActive("HyperVRE","10 Selected keywords") Then WinActivate("HyperVRE","10 Selected keywords")
;WinWaitActive("HyperVRE","10 Selected keywords")
;MouseMove(183,105)
MouseDown("left")
MouseUp("left")
WinWait("Keyword Suggestion Tool","")
If Not WinActive("Keyword Suggestion Tool","") Then WinActivate("Keyword Suggestion Tool","")
WinWaitActive("Keyword Suggestion Tool","")
MouseMove(630,472)
MouseDown("left")
MouseUp("left")
WinWait("Step 1 - Keyword Selection","")
If Not WinActive("Step 1 - Keyword Selection","") Then WinActivate("Step 1 - Keyword Selection","")
WinWaitActive("Step 1 - Keyword Selection","")
MouseMove(180,198)
MouseDown("left")
MouseUp("left")
MouseMove(177,218)
MouseDown("left")
MouseUp("left")
MouseMove(180,235)
MouseDown("left")
MouseUp("left")
MouseMove(181,255)
MouseDown("left")
MouseUp("left")
MouseMove(177,274)
MouseDown("left")
MouseUp("left")
MouseMove(181,293)
MouseDown("left")
MouseUp("left")
MouseMove(179,312)
MouseDown("left")
MouseUp("left")
MouseMove(176,324)
MouseDown("left")
MouseUp("left")
MouseMove(182,348)
MouseDown("left")
MouseUp("left")
MouseMove(181,365)
MouseDown("left")
MouseUp("left")
MouseMove(697,506)
MouseDown("left")
MouseUp("left")
WinWait("Step 2 - Select Templates","PHP")
If Not WinActive("Step 2 - Select Templates","PHP") Then WinActivate("Step 2 - Select Templates","PHP")
WinWaitActive("Step 2 - Select Templates","PHP")
MouseMove(103,239)
MouseDown("left")
MouseUp("left")
WinWait("Select a HTML file for Homepage Template","Open as &read-only")
If Not WinActive("Select a HTML file for Homepage Template","Open as &read-only") Then WinActivate("Select a HTML file for Homepage Template","Open as &read-only")
WinWaitActive("Select a HTML file for Homepage Template","Open as &read-only")
MouseMove(48,156)
MouseDown("left")
MouseUp("left")
MouseMove(116,145)
MouseDown("left")
MouseUp("left")
Send("{ENTER}")
WinWait("Step 2 - Select Templates","PHP")
If Not WinActive("Step 2 - Select Templates","PHP") Then WinActivate("Step 2 - Select Templates","PHP")
WinWaitActive("Step 2 - Select Templates","PHP")
MouseMove(103,311)
MouseDown("left")
MouseUp("left")
WinWait("Select a HTML file for Keyword Template","Open as &read-only")
If Not WinActive("Select a HTML file for Keyword Template","Open as &read-only") Then WinActivate("Select a HTML file for Keyword Template","Open as &read-only")
WinWaitActive("Select a HTML file for Keyword Template","Open as &read-only")
MouseMove(136,164)
MouseDown("left")
MouseUp("left")
Send("{ENTER}")
WinWait("Step 2 - Select Templates","PHP")
If Not WinActive("Step 2 - Select Templates","PHP") Then WinActivate("Step 2 - Select Templates","PHP")
WinWaitActive("Step 2 - Select Templates","PHP")
MouseMove(688,495)
MouseDown("left")
MouseUp("left")
WinWait("Step 3 - Webpage Content","Rotating Definitions")
If Not WinActive("Step 3 - Webpage Content","Rotating Definitions") Then WinActivate("Step 3 - Webpage Content","Rotating Definitions")
WinWaitActive("Step 3 - Webpage Content","Rotating Definitions")
MouseMove(563,226)
MouseDown("left")
MouseUp("left")
MouseMove(687,500)
MouseDown("left")
MouseUp("left")
WinWait("Step 4 - Article Search & Download","")
If Not WinActive("Step 4 - Article Search & Download","") Then WinActivate("Step 4 - Article Search & Download","")
WinWaitActive("Step 4 - Article Search & Download","")
MouseMove(520,177)
MouseDown("left")
MouseUp("left")
MouseMove(646,392)
MouseDown("left")
MouseUp("left")
MouseMove(48,266)
MouseDown("left")
MouseUp("left")
MouseMove(48,282)
MouseDown("left")
MouseUp("left")
MouseMove(45,303)
MouseDown("left")
MouseUp("left")
MouseMove(45,321)
MouseDown("left")
MouseUp("left")
MouseMove(43,337)
MouseDown("left")
MouseUp("left")
MouseMove(45,356)
MouseDown("left")
MouseUp("left")
MouseMove(48,375)
MouseDown("left")
MouseUp("left")
MouseMove(46,392)
MouseDown("left")
MouseUp("left")
MouseMove(46,413)
MouseDown("left")
MouseUp("left")
MouseMove(45,430)
MouseDown("left")
MouseUp("left")
MouseMove(652,282)
MouseDown("left")
MouseUp("left")
WinWait("HyperVRE","Your selected articl")
If Not WinActive("HyperVRE","Your selected articl") Then WinActivate("HyperVRE","Your selected articl")
WinWaitActive("HyperVRE","Your selected articl")
MouseMove(177,103)
MouseDown("left")
MouseUp("left")
WinWait("Step 4 - Article Search & Download","")
If Not WinActive("Step 4 - Article Search & Download","") Then WinActivate("Step 4 - Article Search & Download","")
WinWaitActive("Step 4 - Article Search & Download","")
MouseMove(688,500)
MouseDown("left")
MouseUp("left")
EndFunc;==>script_2

You want to do

While 1

    If WinWait("HyperVRE", "10 keyword selected") Then
        script_2()
    EndIf

    If WinWait("HyperVRE", "0 keyword selected") Or WinWait("HyperVRE", "1 keyword selected") Then
        script_1b()
    EndIf

    Sleep(100); save CPU

WEnd

; Functions-----------


Func script_2()
;   --------------------------------------------------------------------------
;                                                  This is Script 2

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here  
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 

EndFunc;==>script_2

Func script_1b()
;   ---------------------------------------------------------------------------
;                                                        This is Script 1b

code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here 
code will be here
EndFunc;==>script_1b
Link to comment
Share on other sites

I'm thinking something like this

While 1

    If WinWait("HyperVRE", "10 keyword selected keywords") If Not WinActive("HyperVRE","10 Selected keywords") Then WinActivate("HyperVRE","10 Selected keywords")
WinWaitActive("HyperVRE","10 Selected keywords") Else 
       script_2()
    EndIf
       ;EndIf

   ;Sleep(100); save CPU

WEnd

No wait, I'm wanting the script to read 'the text' , "move the mouse' and click the Msgboxes ' .

Link to comment
Share on other sites

If I "Execute" like I did below? Would that be proper syntax to make function script_2 execute?

script_2("Execute")

While 1

    If WinWait("HyperVRE", "10 keyword selected keywords") If Not WinActive("HyperVRE","10 Selected keywords") Then WinActivate("HyperVRE","10 Selected keywords")
WinWaitActive("HyperVRE","10 Selected keywords") Else 
       script_2()
    EndIf
      ;EndIf

  ;Sleep(100); save CPU

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