Jump to content
Sign in to follow this  
GodForsakenSoul

two GUIS simultaniously

Recommended Posts

GodForsakenSoul

i'm trying to get my proggy to start up with TWO GUIS at the same time.

lots of trial and error lead me to nothing i can work with. is it possible to accomplish, specifically on a machine WITHOUT AutoIT? (no run(<filename.au3>))

Share this post


Link to post
Share on other sites
norax

with 2 autoit scripts possibly, but ive tried this myself from several different approaches and nothing i ended up using a context menu to suit my needs

Share this post


Link to post
Share on other sites
GodForsakenSoul

elaborate on the "context menu" part please O_o

i'm searching the help file as we speak

Edited by GodForsakenSoul

Share this post


Link to post
Share on other sites
PsaltyDS

It's not at all difficult. You can have as many GUIs from one script as you want. Each GuiCreate() returns a unique handle to be used for further processing in either GuiGetMsg() or event modes. If you use a message loop, you'll want it to use the advanced flag (see help file) so you know which GUI the message came from.

:mellow:

Edit: Added fun demo:

#include <GuiConstantsEx.au3>

GuiCreate("Test Multiple GUIs", 300, 300, Random(100, @DesktopWidth - 400, 1), Random(100, @DesktopHeight - 400))
GUICtrlCreateButton("CREATE", 100, 100, 100, 30)
GUICtrlCreateButton("DELETE", 100, 200, 100, 30)
GUISetState()

Do
    $aMsg = GUIGetMsg(1) ; 1 = advanced mode
    Select
        Case $aMsg[0] = $GUI_Event_CLOSE
            GUIDelete($aMsg[1])

        Case ControlGetText($aMsg[1], "", $aMsg[2]) = "CREATE"
            GuiCreate("Test Multiple GUIs", 300, 300, Random(100, @DesktopWidth - 400, 1), Random(100, @DesktopHeight - 400))
            GUICtrlCreateButton("CREATE", 100, 100, 100, 30)
            GUICtrlCreateButton("DELETE", 100, 200, 100, 30)
            GUISetState()

        Case ControlGetText($aMsg[1], "", $aMsg[2]) = "DELETE"
            GUIDelete($aMsg[1])
    EndSelect
Until Not WinExists("Test Multiple GUIs", "")

:P

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
norax

elaborate on the "context menu" part please O_o

i'm searching the help file as we speak

right but when i open a form

$form1 guicreate

$form2 guicreate

etc and try to show them both at same time only 1 will display with data from both, and ive made sure to use only set variables to establish "dialog ids"

this i assume was his issue

Share this post


Link to post
Share on other sites
GodForsakenSoul

so... just write all my guis in one function, have it called, and the figure out what gui sent what?

also, which advanced section? style or exstyle?

Share this post


Link to post
Share on other sites
norax

not multiple controls multiple guicreate that exist with eachother

Share this post


Link to post
Share on other sites
GodForsakenSoul

@psalty: if i got your code correctly,

ControlGetText(<GuiGetMsg variable>, <the text it should expect>, <the variable into which the text is read>) = "<the text>"

am i right?

edit: crud, i'm using images instead of buttons. this doesn't seem to work well on images....

Edited by GodForsakenSoul

Share this post


Link to post
Share on other sites
PsaltyDS

GuiGetMsg() is returning an array ($aMsg in my demo). The handle of the window is in $aMsg[1] and the handle of the control is in $aMsg[2].

So the effect is:

ControlGetText(<handle of the window>, "", <handle of the control>) = "<Text To Match>"

The message (maybe control ID) is in $aMsg[0], but I didn't bother to save those anywhere for future reference when creating the controls, so I don't bother checking it.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
GodForsakenSoul

i see. that was rather educational, but the GUI i'm building is using images instead of buttons because in this case, buttons would look ugly.

the problem of course, is that .bmp's, even if they have text, autoit can't read it.

can i do the same, except with the switch koda offers by default?

will i still get the gui's handle when i press it?

Share this post


Link to post
Share on other sites
norax

i see. that was rather educational, but the GUI i'm building is using images instead of buttons because in this case, buttons would look ugly.

the problem of course, is that .bmp's, even if they have text, autoit can't read it.

can i do the same, except with the switch koda offers by default?

will i still get the gui's handle when i press it?

when u make a gui ctrl do it like this

$Button1 = GUICtrlCreateButton("", 400, 24, 145, 25)

$Button2 = GUICtrlCreateButton("", 400, 0, 145, 25)

then in the event switch all u do is

Switch $nMsg[0]

$case $button 1

button data

$case button 2

button data

endswitch

does that make sense or am i explaining it badly lol

Share this post


Link to post
Share on other sites
PsaltyDS

i see. that was rather educational, but the GUI i'm building is using images instead of buttons because in this case, buttons would look ugly.

the problem of course, is that .bmp's, even if they have text, autoit can't read it.

Then keep track of the ControlIDs/Handles of the controls you create and test for those in your loop.

can i do the same, except with the switch koda offers by default?

will i still get the gui's handle when i press it?

You have been around here too long to still be asking that kind of question. Koda-dependency is stunting your growth.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×