makolosz Posted December 19, 2013 Share Posted December 19, 2013 I wanted to change my current script that is running when the pc is idle to the state when a certain window is not minmized. It might be also not in tray, but not active/not active state. Current script: #include <Timers.au3> global $i = 0 While $i < 1 sleep(8000) $idletime = _Timer_GetIdleTime() If $idletime > 7000 Then MsgBox(0, "idle time", $idletime) $i = $i + 1 Else Exit WEnd How can I make such an if? Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted December 19, 2013 Share Posted December 19, 2013 (edited) You need to change your current script by adding line breaks. #include <Timers.au3> Global $i = 0 While $i < 1 sleep(8000) $idletime = _Timer_GetIdleTime() If $idletime > 7000 Then MsgBox(0, "idle time", $idletime) $i = $i + 1 Else Exit EndIf WEnd And a "EndIf". Though I don't know what it does. Edited December 19, 2013 by DatMCEyeBall "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
jdelaney Posted December 19, 2013 Share Posted December 19, 2013 simple example, assumes no notepad is open, prior to run: Run("Notepad.exe") AdlibRegister("PauseIfMinimized") While True ConsoleWrite("Notepad is not minimized!" & WinGetState("[CLASS:Notepad]") & @CRLF) Sleep(500) WEnd Func PauseIfMinimized() While BitAND(WinGetState("[CLASS:Notepad]"),16) ConsoleWrite("Notepad is minimized!" & @CRLF) Sleep(500) WEnd EndFunc IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
makolosz Posted December 19, 2013 Author Share Posted December 19, 2013 Ok, I guess it's all about using function WinGetState(). But it's not notepad in my case - how should I use it? I try full name, partial or class of that window and I get 0 for $state = WinGetState("$windowname", ""), and sometimes I get 23 or 7, which I do not understand - these are not even in the manual: 1 = Window exists 2 = Window is visible 4 = Window is enabled 8 = Window is active 16 = Window is minimized 32 = Window is maximized Failure: Returns 0 and sets @error to 1 if the window is not found. Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted December 19, 2013 Share Posted December 19, 2013 If BitAND(WinGetState("[CLASS:Notepad]"), 16) Then ; Do stuff if notepad is minimized. EndIf "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
makolosz Posted December 19, 2013 Author Share Posted December 19, 2013 Sorry but I do not understand. In my case it's some app window that I want to check for being minimized. As I run a check for that variable I never get 16 most of the time 7. Link to comment Share on other sites More sharing options...
Bert Posted December 19, 2013 Share Posted December 19, 2013 What is the name of the app? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
makolosz Posted December 20, 2013 Author Share Posted December 20, 2013 I tried even with windows calculator and entered Kalkulator or Calcframe, what could code 7 stand for? Link to comment Share on other sites More sharing options...
Bert Posted December 20, 2013 Share Posted December 20, 2013 I tried even with windows calculator and entered Kalkulator or Calcframe, what could code 7 stand for? It stands for the name of your app, that you are not saying what it is. I ask again - what is the name of the app? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
BrewManNH Posted December 20, 2013 Share Posted December 20, 2013 (edited) When you get 23, it's telling you that the window is minimized, window is visible and and the window exists. 16 + 4 + 2 + 1 = 27. When you get 7 it's telling you that the window is enabled, visible and it exists. 4 + 2 + 1 = 7. It's simple math. Edited December 20, 2013 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted December 20, 2013 Share Posted December 20, 2013 And you use BitAND to determine if a certain flag is true. BitAND($iRetFromWinGetState, $iFlag) "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation 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