Sign in to follow this  
Followers 0
cypher175

How Can I Do a Simultaneous Multitask Operation..?

13 posts in this topic

Say I wanted to do this code, but instead of having the message boxes pop up one after the other, I want to have them all pop up at once..

Is there any way to code something like this that will do what a I am asking..??

I Am wanting to do something simultaneously at the same time for each drive found..

is anything like this possible at all..??

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
MsgBox(0,"",$DISK[$I]&"\")
Next

Share this post


Link to post
Share on other sites



Say I wanted to do this code, but instead of having the message boxes pop up one after the other, I want to have them all pop up at once..

Is there any way to code something like this that will do what a I am asking..??

I Am wanting to do something simultaneously at the same time for each drive found..

is anything like this possible at all..??

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
MsgBox(0,"",$DISK[$I]&"\")
Next
Hi there mate,

$output = ""

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
    $output = $output & $DISK[$I] & @CRLF
Next
MsgBox(0, "", $output)

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

From the top off my head. Probably have syntax errors..:)

FileWrite(@TempDir & "/footoo.au3", 'MsgBox(48,"", $CmdLineRaw)')
$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
    Run(@AutoItExe & " /AutoIt3ExecuteScript" & " " & @TempDir & "/footoo.au3" & " " & $DISK[$I])
Next

Rather than writing your utility script (the msgbox in this case) you could use FileInstall.

Edited by Uten

Share this post


Link to post
Share on other sites

From the top off my head. Probably have syntax errors..:)

FileWrite(@TempDir & "/footoo.au3", 'MsgBox(48,"", $CmdLineRaw)')
$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
    Run(@AutoItExe & " /AutoIt3ExecuteScript" & " " & @TempDir & "/footoo.au3" & " " & $DISK[$I])
Next

Rather than writing your utility script (the msgbox in this case) you could use FileInstall.

Hi there :)

I see ... but in some cases, this kind of threading errors (not only bad ones o:) ) are not capture futher in the script!

But in simple cases this is a great multi threading alike

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Yeah as some one mentioned AutoIt don't speak multithreading natively. (Unless something fundamental has changed during the last year). You have to resolve to other ways of doing it. Several suggestions can be found in the examples forum..:)

Share this post


Link to post
Share on other sites

what if i wanted to simultaneously copy a certain folder from each drive over to @HomeDrive&"\DATA"

Would November's code still work or no.

How exactly does November's code work to simulate Multi-Tasking-Threading..??

Share this post


Link to post
Share on other sites

what if i wanted to simultaneously copy a certain folder from each drive over to @HomeDrive&"\DATA"

Would November's code still work or no.

How exactly does November's code work to simulate Multi-Tasking-Threading..??

It doesn't multi task, it goes in synchronous order. There's no real way to do asynchronous methods other than maybe a SetTimer method (Understand that this simply polls like AdlibEnable(), so it will in fact slow the rest of your script down).

Take a look at DllCallBackRegister + SetTimer on the forum. It may give you ideas.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

what if i wanted to simultaneously copy a certain folder from each drive over to @HomeDrive&"\DATA"

Would November's code still work or no.

How exactly does November's code work to simulate Multi-Tasking-Threading..??

Hi again,

Its not multi threading, but a cosmetic operation.

The truth is that you can only start a process after the last process ends.

Returning to the code and answering your question

$output = ""

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
    $copy = FileCopy($i & "\foldertocopy", @HomeDrive & "\DATA", 9)
    if $copy = 1 then 
        $result = " copied"
    Else
        $result = " not copied
    EndIf
    $output = $output & $DISK[$I] & " files were" & $result & @CRLF
Next
MsgBox(0, "", $output)

keep in mind that multi threading is not possible in AutoIT.

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

$output = ""

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
    $copy = FileCopy($i & "\foldertocopy", @HomeDrive & "\DATA", 9)
    if $copy = 1 then 
        $result = " copied"
    Else
        $result = " not copied
    EndIf
    $output = $output & $DISK[$I] & " files were" & $result & @CRLF
Next
MsgBox(0, "", $output)

So will that code only be able to copy the folder from each drive in a first to last order.. not simultaneously..??

Say that on drive F:\ there is a folder that is 5GB that I want to copy over to @HomeDrive&"\DATA"

and on drive G:\ there is a folder that is 3GB that I want to copy over to @HomeDrive&"\DATA"

While its copying the 5GB folder on drive F:\ which might take a while, will your code be able to simultaneously copy over the 3GB folder on drive G:\ at the same time, or will it wait for the 5GB folder to finish then start to copy over the 3GB folder..??

If its not possible to simultaneously copy over multiple folders from diff drives at the same time, would there be a way to like drop another autoit.exe to disk with Drive letter variables in it that are set by the parent process that will execute the copying for each drive simultaneously..?

Something like :

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
$DriveLetter = StringLeft($DISK[$I], 1)
$DriveEXE = @ScriptDir&"\"&$DriveLetter&".exe"
FileInstall("C:\DriveCopy.exe", $DriveEXE)
For $Drive in $DriveEXE 
Assign($Drive, $DriveLetter, 2)
ShellExecute($DriveEXE)
Next
Next

---------------------------------------------------
C:\DriveCopy.exe -AKA- $DriveEXE
---------------------------------------------------
MsgBox(0,"", $Drive&":\")

But it doesn't work, because I don't know yet how to set a variable in another Child Autoit.exe from the Parent Autoit.exe ..??

Edited by cypher175

Share this post


Link to post
Share on other sites

$output = ""

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
    $copy = FileCopy($i & "\foldertocopy", @HomeDrive & "\DATA", 9)
    if $copy = 1 then 
        $result = " copied"
    Else
        $result = " not copied
    EndIf
    $output = $output & $DISK[$I] & " files were" & $result & @CRLF
Next
MsgBox(0, "", $output)

So will that code only be able to copy the folder from each drive in a first to last order.. not simultaneously..??

Say that on drive F:\ there is a folder that is 5GB that I want to copy over to @HomeDrive&"\DATA"

and on drive G:\ there is a folder that is 3GB that I want to copy over to @HomeDrive&"\DATA"

While its copying the 5GB folder on drive F:\ which might take a while, will your code be able to simultaneously copy over the 3GB folder on drive G:\ at the same time, or will it wait for the 5GB folder to finish then start to copy over the 3GB folder..??

If its not possible to simultaneously copy over multiple folders from diff drives at the same time, would there be a way to like drop another autoit.exe to disk with Drive letter variables in it that are set by the parent process that will execute the copying for each drive simultaneously..?

Something like :

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
$DriveLetter = StringLeft($DISK[$I], 1)
$DriveEXE = @ScriptDir&"\"&$DriveLetter&".exe"
FileInstall("C:\DriveCopy.exe", $DriveEXE)
For $Drive in $DriveEXE 
Assign($Drive, $DriveLetter, 2)
ShellExecute($DriveEXE)
Next
Next

---------------------------------------------------
C:\DriveCopy.exe -AKA- $DriveEXE
---------------------------------------------------
MsgBox(0,"", $Drive&":\")

But it doesn't work, because I don't know yet how to set a variable in another Child Autoit.exe from the Parent Autoit.exe ..??

Your question has already been answered twice.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

ok, so then how would I do something like this then..??

how can I set a variable in another Child Autoit.exe from the Parent Autoit.exe ..??

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
$DriveLetter = StringLeft($DISK[$I], 1)
$DriveEXE = @ScriptDir&"\"&$DriveLetter&".exe"
FileInstall("C:\DriveCopy.exe", $DriveEXE)
For $Drive in $DriveEXE
Assign($Drive, $DriveLetter, 2)
ShellExecute($DriveEXE)
Next
Next

---------------------------------------------------
C:\DriveCopy.exe -AKA- $DriveEXE
---------------------------------------------------
MsgBox(0,"", $Drive&":\")

Share this post


Link to post
Share on other sites

ok, so then how would I do something like this then..??

how can I set a variable in another Child Autoit.exe from the Parent Autoit.exe ..??

$DISK = DriveGetDrive("all")
For $I = 1 to $DISK[0]
$DriveLetter = StringLeft($DISK[$I], 1)
$DriveEXE = @ScriptDir&"\"&$DriveLetter&".exe"
FileInstall("C:\DriveCopy.exe", $DriveEXE)
For $Drive in $DriveEXE
Assign($Drive, $DriveLetter, 2)
ShellExecute($DriveEXE)
Next
Next

---------------------------------------------------
C:\DriveCopy.exe -AKA- $DriveEXE
---------------------------------------------------
MsgBox(0,"", $Drive&":\")
You can have parameters in your script and use the same script for different purposes.

Here is a small example. To run it you have to compile it to FolderCopy.exe. Then run the script (must be in the same folder as the exe) or run the exe.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
if $cmdline[0] = 3 then docopy()
if $CmdLine[0] <> 0 then Exit
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 413, 317, 303, 219)
$Input1 = GUICtrlCreateInput("Input1", 16, 32, 327, 21)
$Button1 = GUICtrlCreateButton("Browse", 349, 31, 49, 23, 0)
$Input2 = GUICtrlCreateInput("Input2", 16, 80, 329, 21)
$Button2 = GUICtrlCreateButton("Browse", 349, 79, 49, 23, 0)
$Edit1 = GUICtrlCreateEdit("", 16, 158, 377, 145)
;could be used to show progress rather than have windows pop up

$Label1 = GUICtrlCreateLabel("Copy this folder ..", 16, 8, 85, 17)
$Label2 = GUICtrlCreateLabel(".. to This Folder", 16, 63, 77, 17)
$Label3 = GUICtrlCreateLabel("Progress", 16, 141, 45, 17)
$Button3 = GUICtrlCreateButton("Start Copy", 16, 112, 331, 20, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $copycount = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            GUICtrlSetData($input1,FileSelectFolder("Folder to be copied","\"))
            
        case $Button2
            GUICtrlSetData($input2,FileSelectFolder("Folder to hold copy","\"))
        Case $Button3
            $CopyCount +=1
            Run('foldercopy.exe ' & $copyCount & ' "' & GUICtrlRead($Input1) & '" "' & GUICtrlRead($input2) & '"')
        ;Get the returned pid to be able to know when this process completes
    EndSwitch
WEnd


Func DoCopy()
    GUICreate("Copy from" & $CmdLine[2] & " to " & $CmdLine[3],400,25,0,$CmdLine[1]*31)
    GUISetState()
    sleep(20000);simulate copying
    exit
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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