acoustique Posted November 5, 2008 Share Posted November 5, 2008 Hi I have written the following function - ;Function to Enumerate windows and return handle of the windows with same process id Func EnumerateWindows() $aWindows = _WinAPI_EnumWindows() For $iCnt = 1 To UBound($aWindows) - 1 ;Current handle $l_hHandle = $aWindows[$iCnt][0] ;Current PID _WinAPI_GetWindowThreadProcessId($l_hHandle,$l_pPID) ;If current PID and clnpack PID match we have a valid handle [b] if($l_pPID == $l_pidProcess) Then;Here I am checking which windows belong to my process[/b] Return $l_hHandle Else ContinueLoop EndIf Next Return 0 EndFunc The above function returns a handle each time a window handle belonging to my process ($l_pidProcess) is found. It returns 0 if no windows belonging to my process are found. I am using Windows XP SP2. Now my problem is that this function works perfectly when I am logged on or when the machine is locked but it returns 0 (function failed) when I log off from the machine(machine still running). I have a requirement where the above function must work even after the machine has been logged off. Can anyone please help me out here? The problem obviously lies with the _WinAPI_EnumWindows() API call... Link to comment Share on other sites More sharing options...
rasim Posted November 5, 2008 Share Posted November 5, 2008 acoustiqueWelcome to the forum!Example Link to comment Share on other sites More sharing options...
acoustique Posted November 7, 2008 Author Share Posted November 7, 2008 acoustiqueWelcome to the forum!Example So if I call _EnumWindows as mentioned in example link it will work even when PC is logged off? Link to comment Share on other sites More sharing options...
AgentSmith15 Posted November 7, 2008 Share Posted November 7, 2008 I believe services can run when users are logged off. So if you were to run it as a service... [center][/center] Link to comment Share on other sites More sharing options...
acoustique Posted November 7, 2008 Author Share Posted November 7, 2008 I believe services can run when users are logged off. So if you were to run it as a service...@AgentSmith : Thanks. I guess that will be the last option to try.@raisim : I tried your example. It works fine when I am logged on or the machine is locked. However, when I logoff from the machine it does not work. I am sure the script is running because I have added Beep() and can hear the machine beeping. However the EnumWindows API fails when the machine is logged off.Anyone know a workaround for this problem? Link to comment Share on other sites More sharing options...
ProgAndy Posted November 7, 2008 Share Posted November 7, 2008 if noone is logged on, there are no windows ... *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
LarryDalooza Posted November 7, 2008 Share Posted November 7, 2008 This comes up time and again... The desktop of the user that the script runs as is where the windows come. The SYSTEM or NETWORKSERVICE or like context does not have access to any desktop. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now