AutoHotkey Community

It is currently May 27th, 2012, 12:12 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: May 11th, 2011, 5:52 pm 
Offline

Joined: May 11th, 2011, 5:36 pm
Posts: 1
Hello Guys! I am pretty much new to this so I hope I can get some help from you gurus and experts. I simply just need a script that taps keyboards and clicks mouse to avoid going AFK in a browser.

I used the Auto Script Writer (Recorder) for this. I basically added a loop but I don't know how to stop it by pressing a Spacebar or Backspace.

Loop, 5
{
WinWait, AutoHotkey Tutorial: Macro and Hotkey Creation - Mozilla Firefox,
IfWinNotActive, AutoHotkey Tutorial: Macro and Hotkey Creation - Mozilla Firefox, , WinActivate, AutoHotkey Tutorial: Macro and Hotkey Creation - Mozilla Firefox,
WinWaitActive, AutoHotkey Tutorial: Macro and Hotkey Creation - Mozilla Firefox,
MouseClick, left, 1018, 57
Sleep, 1000
MouseClick, left, 1018, 57
MouseClick, left, 1018, 57
Sleep, 1000
MouseClick, left, 1018, 57
MouseClick, left, 1018, 57
Sleep, 1000
MouseClick, left, 987, 52
Sleep, 1000
MouseClick, left, 991, 52
MouseClick, left, 991, 52
Sleep, 1000
Send, {RIGHT}{RIGHT}
MouseClick, left, 991, 52
Sleep, 1000
Send, {RIGHT}{RIGHT}
MouseClick, left, 991, 52
Sleep, 1000
Send, {RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}
MouseClick, left, 1000, 60
Sleep, 1000
Send, {RIGHT}
MouseClick, left, 1000, 60
Sleep, 1000
Send, {RIGHT}
MouseClick, left, 836, 60
Sleep, 1000
}
Return


And also how come when I open a new tab this Script Stopped working? :cry:

Thanks a lot!

Aloid


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2011, 6:09 pm 
Offline

Joined: March 19th, 2009, 5:08 pm
Posts: 548
Location: Texas, USA
Read:
http://www.autohotkey.com/docs/Tutorial.htm

Add this at the bottom:
Code:
SPACE::ExitApp
BKSP::ExitApp


In the beginning of your loop you are looking for a window with a specific window title. The script waits for that window title to appear each time you iterate through the loop. If you go to a new tab, the window title changes. So... the script waits and waits, all because you told it to.

Read the docs!!!!!

_________________
Aren't you glad that I didn't put an annoying gif here?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2011, 7:25 pm 
Offline

Joined: March 24th, 2004, 2:34 pm
Posts: 299
I'm fairly certain there are some real simple ways to do this. Unfortunately, I'm just not that well experienced with AHK to know what they are off the top of my head.

The problem to watch out for with this kind of task is that you don't want to click the mouse or have the keyboard send some characters if either of those actions will cause something to happen that will interfere with what you are doing.

For example, if you click the mouse and it happens to be sitting on top of some app, then you might just start the app running and that could cause you problems. Similarly, if you send some keys when the script "taps" the keyboard, it could interfere with what you are currently doing.

One starting point could be that you don't need to both click the mouse and tap something on the keyboard to let the system know you are not AFK. You only need to do one of these things.

My first thought is that it would be much better if you could just move the mouse instead of clicking it as that is much less likely to cause any problems. Maybe move it one pixel to the left and then move it back one pixel to the right. Or even better, try to move it zero pixels. That just might work too and would have the added benefit that moving the mouse zero pixels would not likely cause you any problems.

I put the number "15" next to loop as a kind of safety valve. This way the script will run for a maximum of 15 minutes.
If you find that it works OK for 15 minutes, then you can adjust the number "15" or just remove it to have it run until you stop it.

You can always stop this process by right-click on the small green AHK icon in the lower right corner of your screen and select "Exit". That will terminate AHK. I suggest that because it may well be the smiplest way for you to terminate the script when you are done.




Code:
Loop, 100 {
  MouseMove 0, 0, 0, R
  Sleep 60000             ; sleep one minute
}



Instead of moving the mouse zero pixels, it might be good enough to just have the script sleep for a millisecond and then wake up. That might be good enough to convince Windows you are not AFK. You can always try that and it would be better than moving the mouse - if it works.


Code:
Loop, 100 {
  Sleep 1                    ; sleep one millisecond
  Sleep 60000             ; sleep one minute
}


Of course, it's kind of silly to have two "Sleep" statements and if this works, you can probably just remove the "Sleep 1" statement.

You know, I'm sure there are other simple ways of causing Windows to know you are not AFK. I just wish I could think of what they are.

Look up the variable "A_TimeIdlePhysical" in the AHK help file. That is a variable that measures how long it's been since some event last happened that meant you weren't AFK. The documentation for that variable might just discuss some events that identify you are not AFK.

Also, look up the command "Shutdown". That may also have some info on some simple kinds of events you might be able to cause that will force Windows to realize you are not AFK.

Good Luck!


Last edited by JDN on May 11th, 2011, 7:42 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2011, 7:35 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
If you check the rapidfire guide in my sig, you will find multiple ways of doing this, specifically, "the simple pause" and "the toggle"

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2011, 7:36 pm 
Offline

Joined: March 24th, 2004, 2:34 pm
Posts: 299
See?

I told you there were simpler ways to do this.

LOL.

Thank you very much nimda!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2011, 10:12 pm 
Offline

Joined: March 19th, 2009, 5:08 pm
Posts: 548
Location: Texas, USA
Watch out for clicking on links that you might not want to go to. You seem to have aimless clicks there...

and why not use A_TimeIdlePhysical?
http://www.autohotkey.com/docs/Variables.htm#BuiltIn

_________________
Aren't you glad that I didn't put an annoying gif here?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, Yahoo [Bot] and 15 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