Jump to content
Sign in to follow this  
SmOke_N

Dire Need Of Help!

Recommended Posts

I posted before, but I don't think I got out what I was trying to do. I am running 2 programs, one is a window reader, that has a control ID, classname is static (if that matters). You'll see the label for it "Untitled2".

I'm trying to get the script to read the "text" in the control under mouse section, and take an action in the 2nd window which is $1t. I see it reading both, but no action is being taken.

The only time I can get an action is at the end of the function, that I have:

WinActivate($1t);
   Return 1;
EndFunc  ;==>Action

This does return to $takeaction = 1, so I guess the "text" isn't being read. I have turned the helpmenu upside down, but it doesn't give specific examples of these types of scenerios all together. I've searched all over the search in the forum also. I am so knew to this (less than a week), but I am diligently trying.

If you could take a lookat at the script and tell me what I can do to make this work. Thanks

; Read active window, Mouse click based upon text in that window in $t1 window

; Window Name to do action
Global $1t = "Window to take action in here"


; Wait for the window of table to become active
WinWaitActive($1t)

; Main Loop
While WinExists($1t)
   Sleep(300);
  ; Actions to be taken from script read
   $takeaction = Action();
   If $takeaction = 1 Then
     ; Mouse clicking from text found in window 2 reading  "blah1"
      WinWait($1t)
      If Not WinActive($1t) Then WinActivate($1t)
      WinWaitActive($1t)
      MouseMove(440, 538)
      MouseDown("left")
      MouseUp("left")
      Sleep(Random(0, 3000))
   EndIf
   If $takeaction = 2 Then
     ; Mouse clicking from text found in window 2 reading  "blah2" and "blah3"
      WinWait($1t)
      If Not WinActive($1t) Then WinActivate($1t)
      WinWaitActive($1t)
      MouseMove(621, 540)
      MouseDown("left")
      MouseUp("left")
      Sleep(1000)
      MouseDown("left")
      MouseUp("left")
      Sleep(Random(0, 3000))
   EndIf
   If $takeaction = 3 Then
     ; Mouse Clicking from text found in window 2 reading "blah4"
      WinWait($1t)
      If Not WinActive($1t) Then WinActivate($1t)
      WinWaitActive($1t)
      MouseMove(683, 470)
      MouseDown("left")
      MouseMove(697, 470)
      MouseUp("left")
      Sleep(1000)
      MouseMove(709, 534)
      MouseDown("left")
      MouseUp("left")
      Sleep(Random(0, 3000))
   EndIf
   If $takeaction = 4 Then
     ; Mouse clicking from text found in window 2 reading  "blah5"
      WinWait($1t)
      If Not WinActive($1t) Then WinActivate($1t)
      WinWaitActive($1t)
      MouseMove(684, 473)
      MouseDown("left")
      MouseMove(705, 469)
      MouseUp("left")
      Sleep(1000)
      MouseMove(720, 529)
      MouseDown("left")
      MouseUp("left")
      Sleep(Random(0, 3000))
   EndIf

WEnd

; Active Program Window to Read
Func Action()
   WinActivate("Untitled2 """ & $1t);
   
  ; Text to take to action 1
   $text = ControlGetFocus("Untitled2", "Blah1");
   If $text = ("Blah1") Then
      WinActivate($1t);
      Return 1;
   EndIf
   
  ; Text to take to action 2
   $text2 = ControlGetFocus("Untitled2", "Blah2");
   If $text2 = ("Blah2") Then
      WinActivate($1t);
      Return 2;
   EndIf
   
  ; Text to take to action 2
   $text3 = ControlGetFocus("Untitled2", "Blah3");
   If $text3 = ("Blah3") Then
      WinActivate($1t);
      Return 2;
   EndIf
   
  ; Text to take to action 3
   $text4 = ControlGetFocus("Untitled2", "Blah4");
   If $text4 = ("Blah4") Then
      WinActivate($1t);
      Return 3;
   EndIf
   
  ; Text to take to action 4
   $text5 = ControlGetFocus("Untitled2", "Blah5");
   If $text5 = ("Blah5") Then
      WinActivate($1t);
      Return 4;
   EndIf
   
   WinActivate($1t);
   Return 1;
EndFunc  ;==>Action

Also, is there a way to do random mouse clicks to an area, I thought I read somewhere about that, but when I try to use the 3 Random scenerios provided in help I keep getting errors.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Ok, a few more hours at it and a whole lot more reading. I've found that the instead of:

; Text to take to action 1
   $text = ControlGetFocus("Untitled2", "Blah1");
   If $text = ("Blah1") Then
      WinActivate($1t);
      Return 1;
   EndIf

That:

; Text to take to action 1
   $text = WinGetText("Untitled2", "");

Actually has the text I'm looking for in it. But how do I get that specific text to be recognized, and take action (Return 1;) on that specific text?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Ahh well, guess no one either knows what I am talking about or doesn't care to help a newbie. I'm sure the script is completely wrong, just looking to be led in the right diriection. :lmao:


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Solved the issue, might be "Cavematic", but it works all the same :lmao:


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Solved the issue, might be "Cavematic", but it works all the same :lmao:


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...