Jump to content

Read Variables From Running Script Into Another Running Script


Recommended Posts

First I would just like to say HELLO! to anyone reading. It has been a while since I've posted to the Forums but I'm always crawling around.

Now to the matter at hand. I have been looking high and low for a simplistic answer my burned out brain can find but to no avail. I've only recently upped my AutoIt skill and only by a little bit such as ordering my script neatly with my own UDFs and using Global/Dim more often to make my GUI creation understandable and easy to keep things orderly. My current problem however is figuring out how to make my newest endeavor work which is my own "Debugger". I've made a GUI with an Edit Control to display what my Variables are holding and other information from a concurrently running Script. I have access to all of the scripts I'm attempting to connect but I'm dumbfounded on how I would separately read variable information from one running script into another. I'll provide my "Debugger" script that I want to read variables into and a "Meta Script" I'd want to pass info from.

#Region Include Files

#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ColorConstantS.au3>

#EndRegion

#Region AutoIt Options

;Opt("TrayAutoPause", 0)
;Opt("TrayMenuMode", 3)

#EndRegion

#Region Hotkeys

HotKeySet("{ESC}", "ExitProgram")
HotKeySet("{PGDN}", "PauseProgram")
HotKeySet("!1", "Snippet_1")
HotKeySet("!2", "Snippet_2")
HotKeySet("!3", "Snippet_3")
HotKeySet("!4", "Snippet_4")
HotKeySet("!5", "Snippet_5")
HotKeySet("!6", "Snippet_6")
HotKeySet("!7", "Snippet_7")
HotKeySet("!8", "Snippet_8")
HotKeySet("!9", "Snippet_9")

#EndRegion

#Region Global Variables
#Region Globals
Global $gMain, $ctrlEdit ;, $gParent
#EndRegion
#Region $gMain Params
Dim $gMainW = @DesktopWidth / 2
Dim $gMainH = @DesktopHeight / 2
Dim $gMainX = (@DesktopWidth / 2) - ($gMainW / 2)
Dim $gMainY = (@DesktopHeight / 2) - ($gMainH / 2)
Dim $gMainStyle = $WS_POPUP
Dim $gMainStyleEx = -1
;Dim $gMainParent = $gParent
#EndRegion
#Region $ctrlEdit Params
Dim $ctrlEditW = Round($gMainW * 0.98)
Dim $ctrlEditH = Round($gMainH * 0.98)
Dim $ctrlEditX = ($gMainW - $ctrlEditW) / 2
Dim $ctrlEditY = ($gMainH - $ctrlEditH) / 2
Dim $ctrlEditStyle = -1
Dim $ctrlEditStyleEx = -1
#EndRegion
#EndRegion

#Region GUI Initialization

;$gParent = GUICreate("", -1, -1, -1, -1, -1, $WS_EX_TOOLWINDOW)
$gMain = GUICreate("", $gMainW, $gMainH, $gMainX, $gMainY, $gMainStyle, $gMainStyleEx)
GUISetBkColor($COLOR_BLACK, $gMain)
$ctrlEdit = GUICtrlCreateEdit("MainW: " & $gMainW & @CRLF & "MainH: " & $gMainH & @CRLF & "EditW: " & $ctrlEditW & @CRLF & "EditH: " & $ctrlEditH, $ctrlEditX, $ctrlEditY, $ctrlEditW, $ctrlEditH, $ctrlEditStyle, $ctrlEditStyleEx)

GUISetState(@SW_SHOW, $gMain)

#EndRegion

MainFunction()

#Region Main Function (GUI)
Func MainFunction()

    While 1

        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then
            Exit
        EndIf

    WEnd

EndFunc
#EndRegion

#Region Functions

Func Functions()

EndFunc

#EndRegion

#Region Program 1

Func Snippet_1()

EndFunc

#EndRegion

#Region Program 2

Func Snippet_2()

EndFunc

#EndRegion

#Region Program 3

Func Snippet_3()

EndFunc

#EndRegion

#Region Program 4

Func Snippet_4()

EndFunc

#EndRegion

#Region Program 5

Func Snippet_5()

EndFunc

#EndRegion

#Region Program 6

Func Snippet_6()

EndFunc

#EndRegion

#Region Program 7

Func Snippet_7()

EndFunc

#EndRegion

#Region Program 8

Func Snippet_8()

EndFunc

#EndRegion

#Region Program 9

Func Snippet_9()

EndFunc

#EndRegion

#Region Pause/Exit Functions

Func PauseProgram()
    While 1
        Sleep(1000)
    WEnd
EndFunc

Func ExitProgram()
    Exit
EndFunc

#EndRegion Pause/Exit Functions

#Region Snippets
#cs

#CE
#EndRegion

#Region Other Information
#CS

#CE
#EndRegion

That's the Debugger script. Please forgive anything ignorant but point it out if you will, I'll take any pointers to get better! (I usually use a Select to get $GUI_EVENT_CLOSE but this is early on)

Now if I made another script with a basic GUI similar to this and wanted to read say the GUI Width ($gMainW) into the Debugger Edit Control could I do it? If so, could I do it for every variable I have in a script? I read something about the Run function and adding the variables as an option parameter I believe which I think I could do with an array to keep it from being super long and ugly but would that be the only way to do this? Any information is going to be appreciated and thank you in advance for your time!

 

Edit: Sadly it just dawned on me that I could make a UDF that will create a child window that will do this instead of having a separate script trying to invade another... I'll still be keeping an eye on this for any comments but I apologize if I wasted your time!

Edited by Pickpocketz88
epiphany
Link to comment
Share on other sites

If you are trying to build a "better mouse trap", maybe the debugger below can give you some ideas and inspiration.  I've used it in the past and have found it very useful at times.

 

 

Link to comment
Share on other sites

56 minutes ago, TheXman said:

If you are trying to build a "better mouse trap", maybe the debugger below can give you some ideas and inspiration.  I've used it in the past and have found it very useful at times.

 

 

Well this completely nullifies what I was trying to do! lol. Well I'm still going to create my own personal "debugger" for my own coding necessities but this is pretty much exactly what I was attempting to do. I hate that my searches didn't include "Debug" or "Debugger" instead it was "How to read vars from running script to another" etc...

Thank you so much for this reply because it completely answered my question essentially since everything I need should be in this script. Once again the incredible AutoIt community comes to my aid and saves my butt! I'll have to include you as well as the DBUG creators in my script so if I release a public version you guys will get your credit!

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

×
×
  • Create New...