Jump to content

animate systray while doing other stuff


Recommended Posts

okey

so I created four systray icons that will show the user that the script is active

$iconindex = 1

func animateico()

TraySetIcon("icon/ani" & $iconindex & ".ICO")

$iconindex +=1

if $iconindex > 4 then $iconindex = 1

endfunc

I have no special code at the moment to show, but I was thinking of doing the animation while the script maps networkdrives...

$Driveletter = DriveMapAdd("*", $serverpath, 0, $domain & "\" & $username, $password)

so this is how I imagine it to work(thinking a little like VIsual basic):

timer1.interval = 200ms

sub timer1

animateico()

end sub

;mapping networkdrives

timer1.enable

$Driveletter = DriveMapAdd("*", "\\server\\folder1", 0, $domain & "\" & $username, $password)

$Driveletter = DriveMapAdd("*", "\\server\\folder2", 0, $domain & "\" & $username, $password)

$Driveletter = DriveMapAdd("*", "\\server\\folder3", 0, $domain & "\" & $username, $password)

$Driveletter = DriveMapAdd("*", "\\server\\folder4", 0, $domain & "\" & $username, $password)

$Driveletter = DriveMapAdd("*", "\\server\\folder5", 0, $domain & "\" & $username, $password)

how can one do something like this in autoit?

Thanks for all the guideance I get on this forum :shocked:

Link to comment
Share on other sites

okei.

I found out that AdlibEnable could be used.

but it seems the while mapping the adlibfunction will also not be executed

$iconindex = 1
Func _mytrayanimation()
    TraySetIcon("icon/ani" & $iconindex & ".ICO")
        $iconindex +=1
        if $iconindex > 4 then $iconindex = 1
EndFunc

AdlibEnable("_mytrayanimation")
$Driveletter = DriveMapAdd("*", "\\server\\folder1", 0, $domain & "\" & $username, $password)
$Driveletter = DriveMapAdd("*", "\\server\\folder2", 0, $domain & "\" & $username, $password)
$Driveletter = DriveMapAdd("*", "\\server\\folder3", 0, $domain & "\" & $username, $password)
$Driveletter = DriveMapAdd("*", "\\server\\folder4", 0, $domain & "\" & $username, $password)
$Driveletter = DriveMapAdd("*", "\\server\\folder5", 0, $domain & "\" & $username, $password)
AdlibDisable()
Link to comment
Share on other sites

Well, AutoIt can't do two things at once. The current line needs to finish before the Adlib fires, you can't pause a drive mapping halfway through and come back to it later. You could try fake multi-threading by splitting it into two separate scripts and having one call the other, but that seems like too much work just for a little animating icon.

Link to comment
Share on other sites

Well, AutoIt can't do two things at once. The current line needs to finish before the Adlib fires, you can't pause a drive mapping halfway through and come back to it later. You could try fake multi-threading by splitting it into two separate scripts and having one call the other, but that seems like too much work just for a little animating icon.

yes I read somewhere about that, but still with only one thread you should be able to have some doevents in between the work.... the reason I wan't the animation is because mapping takes time(horrible long time in my case, because it's a remote connection... 3 maps can take aboute half a min and more), and I want the users to see that it's working on something, and not standing still. the adlib function do work good when doing all sort of stuff that seems to be done at the same time (not real multithreading offcource)...

I agree that it would be an overkill to do two scripts just to animate a little icon :shocked: but I'm hoping offcource there is a way for me to work this out

Link to comment
Share on other sites

strangly. when I tried putting the drivemap in another script that is called in a seperate process, the mapping time went drasticly down... and it seems to solve the script pausing. the animation goes non stop while mapping now!

now the only thing that is missing is how i can give back the driveletter to the main script...

and how to deal whit spaces in parameters..... some encoding/decoding perhaps?

main script

$val = RunWait("AutoIt3.exe internal/drivemap.au3 * " & $serverpath & " 1 " & $domain & "\" & $auth[0] & " " & $auth[1])
SetError($val)

external script

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.3.2 (beta)
 Author:         thor918

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#NoTrayIcon
; Script Start - Add your code below here
if $CmdLine[0] == 0 Then exit 10;no parameters
$device    = $CmdLine[1]
$serverpath   = $CmdLine[2]
if $CmdLine[0] > 2 Then
    $flags  = $CmdLine[3]
    $username = $CmdLine[4]
    $password = $CmdLine[5]

    $driveletter = DriveMapAdd($device, $serverpath, $flags , $username,$password)
Else
    $driveletter = DriveMapAdd($device, $serverpath) 
EndIf
    exit @error
Edited by thor918
Link to comment
Share on other sites

For spaces in parametres: use quotes:

$val = RunWait('AutoIt3.exe internal/drivemap.au3 * "' & $serverpath & '" 1 "' & $domain & '\' & $auth[0] & '" "' & $auth[1] & '"')
ConsoleWrite(Chr($val) & ':' & @CRLF)oÝ÷ Ùú+¥«,+Þëmz»¬y«­¢+ØÀÌØíÉ¥Ù±ÑÑÈôÉ¥Ù5Á ÀÌØíÙ¥°ÀÌØíÍÉÙÉÁÑ ¤ìè(ÀÌØíÉ¥Ù±ÑÑÈôMÑÉ¥¹IÁ± ÀÌØíÉ¥Ù±ÑÑÈ°ÌäìèÌäì°ÌäìÌäì¤ì)á¥ÐÍ ÀÌØíÉ¥Ù±ÑÑȤìØà
Edited by Zedna
Link to comment
Share on other sites

:shocked:

thanks alot Zedna

I was thinking of something like converting ascii to number, but you beat me to it.

it seems that runwait is working out wonderfull.

I also discovered another possible way to give variabels back to parent script:

http://www.autoitscript.com/forum/index.php?showtopic=41894

the drivemapping is as fast with that function as with runwait, and it resturns consolewrite from the child process...

however, it seems that this function suffers from pausing the animation while it waits for the child process to finish...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...