AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

script running as a service

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ahk_man



Joined: 20 Jun 2004
Posts: 39

PostPosted: Thu Sep 09, 2004 6:21 am    Post subject: script running as a service Reply with quote

I want to create a ahk script to run as a service. This script will run 24hrs on a system and will launch 3 times in a day at different time. When the script launch it will move the mouse to a coordinate and look for a black color. If it's black it will double click on black. After 2 hours, the script will move the mouse to the same coordinate and look for a yellow color. The script will double click on yellow if it finds it at that coordinate. Note, I want this script to launch everyday at specific time and it will run 24hrs seven days a week. Could someone tell me how I should approach this script or better yet, send me an example how the syntax would look like.
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Thu Sep 09, 2004 7:15 am    Post subject: Reply with quote

Standard would be to run a service to accomplish a task regardless that the screen is locked for security reasons and therefore can't be accessed by a user. If the screen is locked - it will won't change its appearance - no pixel will change its color. Any AHK Pixel command works on pixels you can see. AFAIK there's no option to see/detect pixels at another "layer" (eg. the desktop, which you seems to expect, is still "behind" the locked screen). But pixels are "replaced" - there's no overlay. "What you see is what you get" Shocked

Have a try. (Screen resolution 1024x768!)

Code:
Run, mspaint,,MAX
Run, notepad,,MAX
MsgBox, 0, Test, Notepad should now be in front.`nOnce MS - Paint gets active (after 5 sec),`nwe should be notified about a successfull pixel detection.

Loop
   {
   Sleep, 1000
   If A_Index = 5
      WinActivate, untitled - Paint
   PixelGetColor, PCol, 10, 685
   If PCol = 0
      Break
   }
MsgBox, Got it !
ExitApp


Untested :!
Back to top
beardboy



Joined: 02 Mar 2004
Posts: 444
Location: SLC, Utah

PostPosted: Thu Sep 09, 2004 7:24 am    Post subject: Reply with quote

How to setup a program as a service, there is a program called srvany.exe that can do it.
http://www.autohotkey.com/forum/viewtopic.php?t=95

Here is another example of how you could set up your AHK program:
Code:
Loop
{
  time = %a_hour%:%a_min%:%a_sec%
  if time = 08:00:00 ; Time is 8am
    GoSub, BlackCheck
  if time = 10:00:00 ; Time is 10am
    GoSub, YellowCheck
  Sleep, 100
}

BlackCheck:
PixelSearch, , , 5, 5, 10, 10, 65535
if errorlevel = 0
  MouseClick, L, 10, 10
return

YellowCheck:
PixelSearch, , , 5, 5, 10, 10, 65535
if errorlevel = 0
  MouseClick, L, 10, 10
return

thanks,
beardboy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
BoBo
Guest





PostPosted: Thu Sep 09, 2004 8:59 am    Post subject: Reply with quote

Quote:

PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID [, Variation]

The region to be searched must be visible; in other words, it is not possible to search a region of a window hidden behind another window.

PixelGetColor, OutputVar, X, Y

The pixel must be visible; in other words, it is not possible to retrieve the pixel color of a window hidden behind another window.


So if the screen is unlocked beardboy's code would fit, but I can't see the benefit to run it as a service (beside that in this case there won't be any obvious hint that a script is running)

My assumption is/was that the screen is locked while ahk_man/ahk_woman is away. Cool
Back to top
beardboy



Joined: 02 Mar 2004
Posts: 444
Location: SLC, Utah

PostPosted: Thu Sep 09, 2004 4:00 pm    Post subject: Reply with quote

I wouldn't run the program as a service, I would just put it in the startup or the Registry's Run, so that it started at startup. Then it would do the checks when the times were equal to what you specified. I have multiple scripts like this, the only time I ever ran into a spot where I wanted to run it as a service was when I wanted the ability to remotely start and stop the program.

thanks,
beardboy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group