Jump to content
Sign in to follow this  
themax90

Operating GUI Outside Original Script

Recommended Posts

themax90

Test1.au3

GUICreate("")
IniWrite("Test.ini", "Test", "Test", GUICtrlCreateButton("Sup", 50, 50))
GUISetState()
Run("Test2.exe")
While 1
    Sleep(0x000000)
WEnd

Test2.au3

While 1
    If GUIGetMsg() = IniRead("Test.ini", "Test", "Test", 0) Then MsgBox(0, "", "HRm..it worked.")
    Sleep(0x000000)
WEnd

I've tested with onevent mode to. Basically....I want to be able to operate based on a GUI Event in another script. Is this possible? Can someone point me to the right code or a PoC maybe?

Thanks

~Smith

P.S. If functionality or atleast a workaround for this doesn't exist then I will request it as a new feature.

Edited by AutoIt Smith

Share this post


Link to post
Share on other sites
martin

Test1.au3

GUICreate("")
IniWrite("Test.ini", "Test", "Test", GUICtrlCreateButton("Sup", 50, 50))
GUISetState()
Run("Test2.exe")
While 1
    Sleep(0x000000)
WEnd

Test2.au3

While 1
    If GUIGetMsg() = IniRead("Test.ini", "Test", "Test", 0) Then MsgBox(0, "", "HRm..it worked.")
    Sleep(0x000000)
WEnd

I've tested with onevent mode to. Basically....I want to be able to operate based on a GUI Event in another script. Is this possible? Can someone point me to the right code or a PoC maybe?

Thanks

~Smith

P.S. If functionality or atleast a workaround for this doesn't exist then I will request it as a new feature.

If I understand correctly, you simply want to have one script which can tell when a button is pressed in the other, and the iniwrite bit was just an attempt to get the information on the button id to the second script.

If I understood then it definitely won't work that way. The second script will be 'blind' to the events in the first script.

I would do it with messages. When a button in the first script is pressed then send a message to the second script which can then react as you want.

If you need more information on how to do that just say.


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
themax90

U understand, can I get an example of your concept

Share this post


Link to post
Share on other sites
martin

U understand, can I get an example of your concept

Script 1 below can be run from Scite say

#include <misc.au3>

$gui1 = GuiCreate("Script1")

$but = guictrlcreatebutton("Sup",10,10,60,21)

Guisetstate()

Global $hWnd2 = 0; handle to second script

While 1
    If $hWnd2 = 0 Then
        If WinExists("Script2") Then $hWnd2 = WinGetHandle("Script2")
    EndIf
    
    $Msg =  GUIGetMsg()
    If $Msg = -3 Then ExitLoop
    
    If $Msg = $but And $hWnd2 <> 0 Then
        _SendMessage($hWnd2,$WM_USER + 5001,1,1)
;lets say wparam is used for the control type and we'll say 1 is for a button,
              ; Lparam is for the control No. so 1 ,1 means button no 1 pressed
    EndIf
    
WEnd

Script 2 below can be compiled and run

#include <constants.au3>
Global $TimesPressed = 0
GUICreate("Script2",300,300,400,80)
$lab1 = guictrlcreatelabel("No button pressed yet",20,50,120,21)

GUISetState()
GUIRegisterMsg($WM_USER + 5001,"FromScript1")

While 1
    
    If GUIGetMsg() = -3 Then ExitLoop
WEnd

Func FromScript1($hWndGUI, $MsgID, $WParam, $LParam)
    If $MsgID = $WM_USER + 5001 Then
        Local $CtlType = $Wparam
        Local $CtrNo = $LParam
        If $CtlType = 1 And $CtrNo = 1 Then
            $TimesPressed += 1
            GUICtrlSetData($lab1,"Button 1 pressed (" & $TimesPressed & ")")
        EndIf
    EndIf
EndFunc

More than 15 minutes - problem with my washing machine trying to escape from the kitchen.

Edited by martin

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
themax90

K Thanks alot! It's really going to help with the addon system in Spotlight.

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  

×