Jump to content

Pass variable to another script


Recommended Posts

Hey guys, I am sure this has come up before but I searched for it (Same search string as the title is) and got

The error returned was:

One or all of your search keywords were below 3 characters or you searched for words which are not allowed, such as 'html', 'img', etc, please go back and increase the length of these search keywords or choose different keywords.

Anyway, anyone have any tips on how to pass variables to another compiled script? I need a download progress bar, and if I try to use INetGet() in the background it doesn't work, won't update the progress bar properly... So I'm thinking of having another script run just the progress bar, but I need to pass the @INetGetBytesRead to the other script.

Or, if someone has tips on how to get the progressbar to work...

Edited by koresho
Link to comment
Share on other sites

In the called script, use $CmdLine[1] to get the first parameter ($CmdLine[2] for second, and so on).

Hey guys, I am sure this has come up before but I searched for it (Same search string as the title is) and got

Anyway, anyone have any tips on how to pass variables to another compiled script? I need a download progress bar, and if I try to use INetGet() in the background it doesn't work, won't update the progress bar properly... So I'm thinking of having another script run just the progress bar, but I need to pass the @INetGetBytesRead to the other script.

Or, if someone has tips on how to get the progressbar to work...

Link to comment
Share on other sites

The receiver with the progressbar

Global Const $WM_USER = 0x400 
$GuiTitle = "The Progress Bar Script"
$gui = GuiCreate($GuiTitle,500,200)
$progress = GUICtrlCreateProgress(10,10,400,20)
GUISetState()
GUIRegisterMsg($WM_USER, "MY_MSGS_HANDLER")



While 1
    Sleep(100)
WEnd


Func MY_MSGS_HANDLER($hWnd, $nMsg, $wParam, $lParam)
    GUICtrlSetData($progress, Dec(StringTrimLeft($wParam,2)))
EndFunc ;==>MY_MSGS_HANDLER

The sender...

Global Const $WM_USER = 0x400 
Const $ProgressGuiTitle = "The Progress Bar Script"

$wHwnd = WinGetHandle($ProgressGuiTitle )

For $i = 1 to 100
    If $wHwnd <> "" then PostMessage($wHwnd,$WM_USER, $i, "")
    Sleep(200)
Next


Func PostMessage($hWnd, $msg, $wParm, $lParm)
    Return DllCall("user32.dll", "int", "PostMessage", _
            "hwnd", $hWnd, _
            "int", $msg, _
            "int", $wParm, _
            "int", $lParm)
EndFunc ;==>PostMessage
Edited by ChrisL
Link to comment
Share on other sites

Ok, I must admit I just answered after reading the "Topic" of the post, and I think the answer was correct.

In that if your script is "Script1.Au3" and your second script is "Script2.Au3"

Script1.Au3 could call Script2.Au3 passing it a parameter.

Script2.Au3 would use $Command[1] to get the passed parameter.

In your case, I think you are better off creating a GUI for the progress and updating it as needed.

Edit: ChrisL has posted some elegant code that might do exactly what you are looking for.

Are you saying to use the ConsoleWrite/Read functions?

Edited by DaRam
Link to comment
Share on other sites

ChrisL, that looks like it will work, thanks muttley

DaRam, I wouldn't have been able to do that because I need to have both scripts compiled :) thanks for the help though.

...pass variables to another compiled script?...

Edited by koresho
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...