Sign in to follow this  
Followers 0
mestre

Show AutoIt Made Program Window

6 posts in this topic

I'm having some trouble with this one if anyone wants to help. What I'm trying to do is show a window in the running process created with AutoItV3. The window shows but the buttons won't work.

I've created a sample "Program" script which is the program running with the GUI and a "ShowWindow" script.

When I use GuiSetState(@SW_SHOW) from inside the "Program" the Save and Cancel buttons work, and the check box in the list works.

When I use WinSetState("$WindowName", "", @SW_SHOW) from "ShowWindow" program, the $WindowName from the running program shows like expected but, the Save and Cancel buttons don't work and the check box in the list does!

Thanks in Advance.

"Program" Script:

#include <Guiconstants.au3>
#include <guilistview.au3>

$guiwindow = "Window1"
$window = GUICreate($guiwindow, 620, 385)

; Create Buttons
$BtnSave = GuiCtrlCreateButton("Save", 15, 330, 80, 40)
$BtnCancel = GuiCtrlCreateButton("Cancel", 110, 330, 80, 40)

; Create Tray
Opt("TrayMenuMode",1)
$TrayOpen = TrayCreateItem("Open")
$TrayExit = TrayCreateItem("Exit")
TraySetState()

; Create ListView with CheckBoxes
$listView1 = GuiCtrlCreateListView("Auto", 210, 10, 40, 365, $LVS_NOSORTHEADER, $LVS_EX_CHECKBOXES)
_GUICtrlListViewSetColumnWidth($listview1,0,40)

; Put test checkbox in ListView
GuiCtrlCreateListViewItem("", $listView1)


while 1
    $MSG = GUIGetMsg()
    $TrayMSG = TrayGetMsg()
    Select
    case $MSG = $BtnSave
        MsgBox("","Save","You clicked the save button")
    case $MSG = $BtnCancel
        MsgBox("","Cancel","You clicked the cancel button")
    Case $MSG = $GUI_EVENT_CLOSE
        GUISetState(@SW_HIDE)
    Case $TrayMSG = $TrayOpen
        GuiSetstate(@SW_SHOW)
    Case $TrayMSG = $TrayExit
        Exit
    EndSelect
WEnd

"ShowWindow" Script:

WinSetState("Window1", "", @SW_SHOW)

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

i would like to use the guieventmode (help file)

in my opinion way easier

Edited by Pakku

Share this post


Link to post
Share on other sites

Check out (or search for) GuiSwitch in the help file.

I need to be able to show the window from an outside program. GuiSwitch works from within the program.

Share this post


Link to post
Share on other sites

i would like to use the guieventmode (help file)

in my opinion way easier

Arjan

Tried that too.

GuiSetOnEvent "Program" Script:

#include <Guiconstants.au3>
#include <guilistview.au3>

Opt("GUIOnEventMode", 1)

$guiwindow = "Window1"
$window = GUICreate($guiwindow, 620, 385)
GUISetOnEvent($GUI_EVENT_CLOSE, "Hide")

; Create Buttons
$BtnSave = GuiCtrlCreateButton("Save", 15, 330, 80, 40)
GUICtrlSetOnEvent(-1, "BtnSave")
$BtnCancel = GuiCtrlCreateButton("Cancel", 110, 330, 80, 40)
GUICtrlSetOnEvent(-1, "BtnCancel")

; Create Tray
Opt("TrayMenuMode",1)
$TrayOpen = TrayCreateItem("Open")
$TrayExit = TrayCreateItem("Exit")
TraySetState()

; Create ListView with CheckBoxes
$listView1 = GuiCtrlCreateListView("Auto", 210, 10, 40, 365, $LVS_NOSORTHEADER, $LVS_EX_CHECKBOXES)
_GUICtrlListViewSetColumnWidth($listview1,0,40)

; Put test checkbox in ListView
GuiCtrlCreateListViewItem("", $listView1)


while 1
    $TrayMSG = TrayGetMsg()
    Select
    Case $TrayMSG = $TrayOpen
        GuiSetstate(@SW_SHOW)
    Case $TrayMSG = $TrayExit
        Exit
    EndSelect
WEnd

Func BtnSave()
    MsgBox("","Save","You clicked the save button")
EndFunc

Func BtnCancel()
    MsgBox("","Cancel","You clicked the cancel button")
EndFunc

Func Hide()
    GUISetState(@SW_HIDE)
EndFunc

"ShowWindow" Script:

CODEWinSetState("Window1", "", @SW_SHOW)

Share this post


Link to post
Share on other sites

I guess I did not read your post wery well. But then again I don't think there is really good corespondence between your topic title and the problems you describe in your first post.

To get the created controls to show you have to use GuiSetState(...) as the last line when you have finished creating the GUI.

; Put test checkbox in ListView
   GuiCtrlCreateListViewItem("", $listView1)
   GuiSetState()

If you want to launche a window (as in a program) you will have to use Run(<pahtname to app>) and then get a handel to the window through one of the Win* Functions ( WinActive("") ) .

Considering thatyou missed the GuiSetState function in your sample I think you will benefit from doing some searching and try out solutions allready provided in the forum. :lmao:

Wish you the best of luck and happy scripting.

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