473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

unable to execute pyhook script from windows service.

im calling pyhook related script from python windows service its not getting execute but for normal execution and debug its working fine.
Expand|Select|Wrap|Line Numbers
  1. import pythoncom,pyHook , sys
  2. import datetime
  3. import win32api
  4. import ctypes
  5. last_event = ''
  6. def info(idle_time) :
  7.   try :
  8.     fo = open("testschd.txt", "a+")
  9.   except :
  10.     fo = open("testschd.txt", "wb")
  11.   fo.write(str(idle_time))
  12. def OnMouseEvent1(event) :    
  13.     global last_event 
  14.     if last_event :
  15.         before = (datetime.datetime.now() - last_event)
  16.         print before.seconds
  17.         if before.seconds > 60 :
  18.             info(before.seconds)
  19.     last_event = datetime.datetime.now()
  20.     return True
  21. def OnKeyboardEvent(event) :
  22.     global last_event
  23.     if last_event :
  24.         before = (datetime.datetime.now() - last_event)
  25.         if before.seconds > 60 :
  26.             info(before.seconds)
  27.     last_event = datetime.datetime.now()
  28.     return True
  29. def test() :
  30.     hm = pyHook.HookManager()
  31.     hm.KeyDown = OnKeyboardEvent
  32.     hm.SubscribeMouseAllButtonsDown(OnMouseEvent1)
  33.     hm.MouseDown = OnMouseEvent1
  34.     hm.HookKeyboard()
  35.     hm.HookMouse()
  36.     pythoncom.PumpMessages()
  37.  
can anyone help me what is wrong here.
Thanks in Advance.
Jul 12 '16 #1
0 1009

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Amy L. | last post by:
I have a windows service where I would like to launch a script (bat, cmd, vbs, exe, etc) from the service. This script should execute in the background and not require any input from the user...
2
by: Juan Manuel Alegría B. | last post by:
Hi group I have been making a windows service to execute an external application. I use a timer control, I can execute the application but does't appear as a normal windows, just I see it in the...
1
by: JerryK | last post by:
Hi, I have a VB.net windows service that loks up when I attempt to access a share. The code work fine if I run it in the development environment. The code is as follows: Dim sharename as...
1
by: timb | last post by:
Hi, does any have any sample code of the above? i have tried the example from the help but am unable to get my windows service to create a new logfile and start logging to it. I am able to...
2
by: raghavendra | last post by:
Hi, How to run automatically windows service by using setup deployment insatllation script using visual studio 2003.? What i did is :-- 1. created a windows service & tested the same. 2....
1
by: Rajeev Ramanujan | last post by:
Hi All, I'm trying to execute a standalone application written in VB .Net using a windows service developed using VB .Net. But the service is not able to execute the application. How to make...
4
by: stuart.jones | last post by:
Dear all I have a Windows Service that retrieves some data as XML, applies an XSLT to produce a CSV which is saved to the filesystem as a text file. This all works fine. Depending upon the...
5
by: sonali_reddy123 | last post by:
Hello all, I am trying to develop an application which will run as a windows service. The application should have Normal options available with service like start, stop and pause but along...
0
by: Gheorghe Postelnicu | last post by:
Hi, I am trying to create a windows service that will process some keyboard events. For that, i am trying to use pyHook and pythoncom, which work great in a stand-alone application. However,...
6
by: santhugala | last post by:
I am creating an object of servicecontroller() as follows system,.serviceprocess.servicecontroller objService = new servicecontroller(Service Name); Iam trying to stop the service using ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.