Sign in to follow this  
Followers 0
Kenneth

Shift between programs

9 posts in this topic

I would like do a script to shift between program that is running. The shift should do every 10 seconds.

I have 3 programs running. P1 P2 P3

I have tried to do this, but it dosen't work. It only change between P1 and P2. Do you have another solution?

Global $hTimer = TimerStart()

While 1

If TimerStop($hTimer) >= (10000) Then Reconnect()

WEnd

;Code

Func Reconnect()

Send("!{TAB}")

$hTimer = TimerStart(); Reset

EndFunc

Share this post


Link to post
Share on other sites



Try to use ProcessList, see the helpfile, where you can get a list of all running programs, thwn you can use WinActivate to put the program in focus.

Share this post


Link to post
Share on other sites

Try to use ProcessList, see the helpfile, where you can get a list of all running programs, thwn you can use WinActivate to put the program in focus.

But this show me all tasks in the tasklist. I'm only interested in those programs that is active in taskbar.

How can this me done?

Share this post


Link to post
Share on other sites

If you have all the three WinTitles... you can use those in combination with WinSetState :)

Neo


[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Share this post


Link to post
Share on other sites

If you have all the three WinTitles... you can use those in combination with WinSetState :)

Neo

How can this be done?

Share this post


Link to post
Share on other sites

While 1
  WinActivate ("Program1")
  Sleep (20000)
  WinActivate ("Program2")
  Sleep (20000)
  WinActivate ("Program3")
  Sleep (20000)
Wend

An example of how to use WinActivate

Share this post


Link to post
Share on other sites

While 1
  WinActivate ("Program1")
  Sleep (20000)
  WinActivate ("Program2")
  Sleep (20000)
  WinActivate ("Program3")
  Sleep (20000)
Wend

An example of how to use WinActivate

Yes, that seems to very easy.

But IF there was a new program we should watch, then I need to rewrite the code and I would like not to that.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

$var = WinList()

while 1
    $var = Winlist()
    sleep(1000)
    activate()
WEnd

func activate()
    For $i = 1 to $var[0][0]
        If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
        WinActivate($var[$i][0],"")
        sleep(10000)
        EndIf
    Next
EndFunc

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc

This... ?

*Edit: Now keeps on running and checking for new windows... :) (if there is 1 window more, it will take that one too in the loop.. I missed that part of your quest)

Neo

Edited by NeoFoX

[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

$NumOfPrograms = $CmdLine[0]
While 1
  For $x = 1 to $NumOfPrograms
    WinActivate ($CmdLine[$x])
    Sleep (20000)
  Next
Wend

Something like this......

Send the Title of the programs as parameters to the program ...

ShowProg "Program 1" "Program 2" "Program 3"

Edited by Wooltown

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0