Chipper Posted December 2, 2008 Share Posted December 2, 2008 Hi, I was asked at work to see if I could write a simple program that would run through all of the running programs at a set cycle (say 15 seconds). There is a few workstations that are used to monitor network items and people wanted an easy method to scroll through them. I have attempted the following, but am a little stuck. When the program is visible, I want it to stop scrolling through the applications. This way the person could change the setting without having to find it again. Thanks for any guidance you can suggest. expandcollapse popup#include <GUIConstantsEx.au3> $time = 15 $var = WinList() Opt("GUIOnEventMode", 1) $msg = GUICreate("Program Switcher", 225, 100) GUICtrlCreateLabel("Enter the time in seconds:",10,20) $Seconds = GUICtrlCreateInput("15", 140, 16,25) $Apply = GUICtrlCreateButton("Apply", 60, 50, 60) GUICtrlSetOnEvent($Apply, "ApplyButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinMinimizeAll() GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() $state = WinGetState("Program Switcher", "") If BitAND($state, 16) Then For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then If $var[$i][0] <> "Program Manager" Then WinSetState($var[$i][0],"",@SW_MAXIMIZE) $totaltime = $time * 1000 Sleep ($totaltime) WinSetState($var[$i][0],"",@SW_MINIMIZE) EndIf EndIf Next EndIf WEnd Func CLOSEClicked() Exit EndFunc Func ApplyButton() $time = GUICtrlRead($Seconds) EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc Link to comment Share on other sites More sharing options...
youknowwho4eva Posted December 2, 2008 Share Posted December 2, 2008 Sounds like you want WinActive to me. Giggity Link to comment Share on other sites More sharing options...
KaFu Posted December 3, 2008 Share Posted December 3, 2008 Maybe just set the GUI of the program to topmost? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Chipper Posted December 3, 2008 Author Share Posted December 3, 2008 Maybe just set the GUI of the program to topmost?You just lost me with that. I have written some basic scripts with AutoIT!, but this is my first GUI one. Link to comment Share on other sites More sharing options...
Chipper Posted December 3, 2008 Author Share Posted December 3, 2008 I added some more checking to the nested loop and I think I have it fixed. It may not be elegant, but it seems to work. I didn't know if an exitloop would work, so I set the loop to the last value. expandcollapse popup#include <GUIConstantsEx.au3> ;Version 1.0 - 12/03/08 $time = 15 $var = WinList() Opt("GUIOnEventMode", 1) $msg = GUICreate("Program Switcher", 225, 100) GUICtrlCreateLabel("Enter the time in seconds:",10,20) $Seconds = GUICtrlCreateInput("15", 140, 16,25) $Apply = GUICtrlCreateButton("Apply", 60, 50, 60) GUICtrlSetOnEvent($Apply, "ApplyButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WinMinimizeAll() GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() $state = WinGetState("Program Switcher", "") If BitAND($state, 16) Then WinMinimizeAll() For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then If $var[$i][0] <> "Program Manager" Then $state = WinGetState("Program Switcher", "") If BitAND($state, 8) Then $i = $var[0][0] Else WinSetState($var[$i][0],"",@SW_MAXIMIZE) EndIf $totaltime = $time * 1000 $state = WinGetState("Program Switcher", "") If BitAND($state, 8) Then $i = $var[0][0] Else Sleep ($Totaltime) EndIf $state = WinGetState("Program Switcher", "") If BitAND($state, 8) Then $i = $var[0][0] Else WinSetState($var[$i][0],"",@SW_MINIMIZE) EndIf EndIf EndIf Next EndIf WEnd Func CLOSEClicked() Exit EndFunc Func ApplyButton() $time = GUICtrlRead($Seconds) EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc 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