AutoHotkey Community

It is currently May 27th, 2012, 3:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: July 25th, 2010, 6:19 pm 
Offline

Joined: April 29th, 2010, 7:04 pm
Posts: 24
So what i want to do:

Auto click "F8" every 20 seconds.

But every 10 minute, i also what it to "Stop" Clicking every 20 sec, send Alt+R and click 2 time on a certain button. Then go back to Clicking F8 every 20 seconds.


I should be more than fine to set up the Click F8 every 20 second with a... Send F8, Sleep 20000 Return methode...

But for the part where it stop and hit Alt+R and click twice, it wont work correctly... And im pretty sure i am not using the best way...

Code:
#Persistent
SetTimer, CheckTime, 45000 ;check time 45sec...?
Return

CheckTime:
if (A_Min=05) [i](insert "OR" 15, 25, 35, 45, 55 somehow here...)[/i]
Sleep 1500
Send {!r}
Sleep 500
MouseMove, 800, 515
Sleep 750
Send {Click}
Sleep 500
MouseMove, 800, 515
Sleep 750
Send {Click}
Return


What happen is that im pretty sure this methode isnt the best AND even with this methode, it doesnt Send !r 75% of the time... it skips it and do the 2 mouse move + 2 Click.... Cant figure why....

Help a noob plz :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2010, 7:07 pm 
Offline

Joined: February 1st, 2010, 2:50 pm
Posts: 237
Location: Netherlands
Quote:
it doesnt Send !r

If you want Alt+r use
Code:
Send !r

If you want !r use
Code:
Send {!}r

or use SendRaw


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2010, 8:05 pm 
I want it to sent alt+r

so i used !r

and it only sent it like 50-75% of the time. Rest of the time it'll just skip it and go to the Click... :/

I mean maybe it send it, but it doesnt trigger what its supposed to trigger in game. And it never fail when i do alt+r myself.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2010, 8:25 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
1) Aren't you forgetting a block after the if statement?
2) FAQ: Why don't Hotstrings, Send, and MouseClick work in certain games?

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2010, 9:06 pm 
I fixed my block problem.

I got this idea.... Since it wont send !r all the time (alt+r) it should send it. Would it be possible to, at the point where it has to send !r, have a loop..

Something like

Code:
Do until color = White
SEND !r (trys to open a window)
SLEEP
MOUSEMOVE x,y (move to where the windows open)
SLEEP
CHECK COLOR (check if the color is white under where the mouse point)
LOOP


So doing this, when ever Autohotkey detects white color where my mouse will be located, it will mean !r was succesfull thus, can move to my next step(get out of the loop). Is this possible? if yes, how could i do this :S
[/code]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2010, 11:00 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
You need:
http://www.autohotkey.com/docs/commands/MouseGetPos.htm
http://www.autohotkey.com/docs/commands ... tColor.htm

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 12:46 am 
Big thx for info... But i couldnt make it work...

This code works... took it from exemple on link u gave me. And the color on the window is 0xFFFFFF (this is what the msg box show.)
Code:
^!z::  ; Control+Alt+Z hotkey.
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
MsgBox The color at the current cursor position is %color%.
return


Now here what i tryed to do:
Code:
^!x::  ; Control+Alt+Z hotkey.
Loop
{
    Sleep 500
    MouseGetPos, MouseX, MouseY
    PixelGetColor, color, %MouseX%, %MouseY%
    If %color% = 0xFFFFFF
        break  ; Terminate the loop
    Else if a_index > 5
        break ; Skip the below and start a new iteration
   Msgbox tryed 5 time, failed.
}
Return


2 problem with my loop.... I don't think i understand how a_index work, cause it doesnt do what i want... i wanted the loop to check 5 time... And give up if it couldnt find it in 5. Or stop if it found white...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 1:00 am 
I keep on trying but i can't figure how to succesfully do my loop...

Incase it inst clear. Im trying to loop so it will check if the color under the mouse is white (0xFFFFFF) if it is, it will stop(break of out the loop). If it failed to get 0xFFFFFF, it will try (up to 5 time befor breaking out of loop).

Anyone can help me :D? But big thx for info i got already.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 1:59 am 
Cookie2 wrote:
I keep on trying but i can't figure how to succesfully do my loop...

Incase it inst clear. Im trying to loop so it will check if the color under the mouse is white (0xFFFFFF) if it is, it will stop(break of out the loop). If it failed to get 0xFFFFFF, it will try (up to 5 time befor breaking out of loop).

Anyone can help me :D? But big thx for info i got already.


Code:
^!x::
Loop, 5       ;this will loop 5 times at most
{
    Sleep 500
    MouseGetPos, MouseX, MouseY
    PixelGetColor, color, %MouseX%, %MouseY%
    If %color% = 0xFFFFFF
        break
    Else if a_index = 5    ;if 5th iteration, loop will finish
        Msgbox tryed 5 time, failed.            ;so msgbox
}
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 2:02 am 
previous post was untested, and heres another solution, also untested, just so you can get ideas of the diff commands you might use for the problem

Code:
^!x::  ; Control+Alt+Z hotkey.
Loop
{
    Sleep 500
    MouseGetPos, MouseX, MouseY
    PixelGetColor, color, %MouseX%, %MouseY%
    If %color% = 0xFFFFFF
        break  ; Terminate the loop
    Else if a_index < 5
        continue ; this is what skips to next iteration, not 'break'
    Else if a_index = 5
    {
        Msgbox tryed 5 time, failed.
        break ; Terminate the loop
   }
}
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 2:31 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Please check this:
Code:
If %color% = 0xFFFFFF


Read: http://www.autohotkey.com/forum/viewtopic.php?t=47791
Specifically: "Syntax for Assignment and Comparison in AutoHotkey"

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 2:58 am 
Offline

Joined: February 19th, 2010, 6:11 pm
Posts: 150
Location: California
This should work for your first request (Unless the mouse location is incorrect):
Code:
count=0
loop
   {
   sleep 20000
   send,{f8}
   count+=1
   if count=1200000
      {
      send,!r
      sleep 100
      click 800,515
      sleep 100
      click 800,515
      count=0
      }
   }


This should work for your second request:
Code:
count=0
Loop
   {
   Sleep 500
   MouseGetPos, MouseX, MouseY
   PixelGetColor,color,%MouseX%,%MouseY%
   If color=0xFFFFFF
      {
      count=0
      break
      return
      }
   count+=1
   if count=5
      {
      tooltip,Failed
      }
   }

I personally would use tooltip over msgbox, just so you dont have to click on anything and it doesnt interrupt anything, but what ever floats your boat.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 1:43 pm 
Msg box or tooltip were just for testing. Once im done i dont want anything poping :P. But i didnt know about tool tips. thanks.

So i kinda edited your above code to what i need. and it this part works like a charm! Thank you so much.

Heres My loops to make sure Ctrl+R was succesfully sent.
Code:
^!x::
count=0
Loop
   {
   count+=1
   Send !r
   Sleep 200
   MouseMove, 800, 515
   Sleep 200
   MouseGetPos, MouseX, MouseY
   PixelGetColor,color,%MouseX%,%MouseY%
   If color=0xFFFFFF
      {
      ;[i]Will insert what the script has to do here if !r was successfull.[/i]
      Msgbox Ctrl+R was success
      count=0
      break
      return
      }
   if count=10
      {
      ;[i]Will insert what the script has to do here if !r was unsuccessful.[/i]
      Msgbox Ctrl+R failed more than 10 time, giving up for now.
      break
      }
   }
Return


Ill have another small question tonight(im at work and missing other code from home so kinda lost in my ideas). But i couldn't thank you all enough for the help... I wish i was this good... But atleast i am better than 3 month ago at this >.>.[/code]


Report this post
Top
  
Reply with quote  
 Post subject: timer
PostPosted: July 29th, 2010, 2:40 pm 
Offline

Joined: November 5th, 2007, 7:25 pm
Posts: 454
Location: canada
I would read up on help for "settimer" instead of loops.

As per checking to see if your alt r was sent properly by moving mouse and checking window color behind it you could read up on "ControlSend" which would work 100% of the time without moving mouse.

Just a FYI

_________________
-=Raz=-


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 4:14 pm 
@Razlin

1st: Maybe itll make more sense when i show my last question/request tonight... Cause what happen is that, the script above need to be triggered at every 10 min. So i use an old script someone helped me to make + some stuff i figured on my own so that it'll trigger at; X:00, X:10, X:20,... X:50. I think it uses a SetTimer... to check every [Insert my desired Milisecond here] If the time is matching. And if it matches will trigger... Anywho, this sounds so unclear until i show the code... I dont feel like im clear atleast lol

2nd: Not sure if i understand the ControlSend info ive found... But FYI, this is for ingame purpose. Duno if it matters...


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], bobbysoon, Yahoo [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group