Jump to content
Sign in to follow this  
Milanezi

Optimizing code

Recommended Posts

Milanezi

I recently made a count to switch between FF windows and click somwhere.

But i notice my code sometimes skips one window (seems random).

Is there a problem in my code that i overlook?

$accounts: number of FF windows to switch between.

$sites: number of clicks on each window

Local $var = WinList("[CLASS:MozillaWindowClass]")
Local $accounts = InputBox("Accounts","Aantal")
Local $windows[$accounts]
local $sites = InputBox("Sites","Aantal")

Local $j = 0
For $i = 1 To $var[0][0]
If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
$windows[$j] = $var[$i][1]
$j += 1
EndIf
Next

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

EndFunc

Local $id
Local $l = 0
while $l <> $sites
Local $k = 0
while $k <> $accounts
$id = $windows[$k]
WinActivate($id)
WinWaitActive($id81.198.119.31:8080)
sleep(750)
MouseClick("left",1550,78,1,0)
$k += 1
WEnd
$l +=1
Sleep(Random(40000,45000,1))
WEnd

Share this post


Link to post
Share on other sites
Milanezi

An accidental ctrl + C extra, nothing important :)

Local $var = WinList("[CLASS:MozillaWindowClass]")
Local $accounts = InputBox("Accounts","Aantal")
Local $windows[$accounts]
local $sites = InputBox("Sites","Aantal")

Local $j = 0
For $i = 1 To $var[0][0]
If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
$windows[$j] = $var[$i][1]
$j += 1
EndIf
Next

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

EndFunc

Local $id
Local $l = 0
while $l <> $sites
Local $k = 0
while $k <> $accounts
$id = $windows[$k]
WinActivate($id)
WinWaitActive($id)
sleep(750)
MouseClick("left",1550,78,1,0)
$k += 1
WEnd
$l +=1
Sleep(Random(40000,45000,1))
WEnd

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  

×