Jump to content

A little add-on(attaching a gui to another window)


Wombat
 Share

Recommended Posts

Ok, so I'm working on extending the capabilities of a piece of software.

I'm working on making it an add-on.

I found, through some googling, a piece of code written by Melba23 a year ago, and edited it while playing with it...

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

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnEsc", 1)

Global $hGUI_Child

$hGUI_Main = GUICreate("Main", 300, 300, 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainGUIClose")
GUISetBkColor(0xFFCCCC)
$cButton = GUICtrlCreateButton("Show Child", 10, 10, 80, 30)
GUICtrlSetOnEvent(-1, "_SH_Child")
GUISetState()

Global $aGUI_Main_Pos = WinGetPos($hGUI_Main)
GUIRegisterMsg($WM_MOVE, "_Position_Child_Show")
GUIRegisterMsg($WM_MOVE, "_Position_Child_Hide")


While 1
Sleep(100)
WEnd

Func _Create_Child()
    $aGUI_Main_Pos = WinGetPos($hGUI_Main)
    $hGUI_Child = GUICreate("Follower", 175, 324, $aGUI_Main_Pos[0]+125, $aGUI_Main_Pos[1], BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) ; <<<<<<<<<<<<<<
    GUISetBkColor(0xCCFFCC)
EndFunc

Func _SH_Child()
    If GUICtrlRead($cButton)="Show Child" Then
        _Create_Child()
        GUISetState(@SW_SHOW, $hGUI_Child)
        GUICtrlSetData($cButton, "Hide Child")
        WinActivate($hGUI_Main)
        _Position_Child_Show($hGUI_Main, 0, 0, 0)
    Else
        _Position_Child_Hide($hGUI_Main, 0, 0, 0)
        GUISetState(@SW_HIDE, $hGUI_Child)
        GUICtrlSetData($cButton, "Show Child")
        GUIDelete($hGUI_Child)
    EndIf
EndFunc

Func _Position_Child_Show($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hGUI_Main Then Return

    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2] + 2, $aGUI_Main_Pos[1], Default, Default, 10) ; <<<<<<<<<<<<<<<<

EndFunc

Func _Position_Child_Hide($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hGUI_Main Then Return

    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + 2, $aGUI_Main_Pos[1], Default, Default, 10) ; <<<<<<<<<<<<<<<<

EndFunc

Func MainGUIClose()
    Exit
EndFunc

Melba23's original code:

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

$hGUI_Main = GUICreate("Main", 300, 300, 200, 200)
GUISetBkColor(0xFFCCCC)
$cButton = GUICtrlCreateButton("Show Child", 10, 10, 80, 30)
GUISetState()

$hGUI_Child = GUICreate("Follower", 150, 324, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) ; <<<<<<<<<<<<<<
GUISetBkColor(0xCCFFCC)
_Position_Child($hGUI_Main, 0, 0, 0)
GUISetState(@SW_HIDE, $hGUI_Child)

GUIRegisterMsg($WM_MOVE, "_Position_Child")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            Switch GUICtrlRead($cButton)
                Case "Show Child"
                    GUISetState(@SW_SHOW, $hGUI_Child)
                    GUICtrlSetData($cButton, "Hide Child")
                    WinActivate($hGUI_Main)
                Case Else
                    GUISetState(@SW_HIDE, $hGUI_Child)
                    GUICtrlSetData($cButton, "Show Child")
            EndSwitch
    EndSwitch
WEnd

Func _Position_Child($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hGUI_Main Then Return

    Local $aGUI_Main_Pos = WinGetPos($hGUI_Main)
    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) ; <<<<<<<<<<<<<<<<

EndFunc ;==>_Position_Child

Ok so first why does in Melba's code dragging the parent drag the child and not in my code?

Secondly, how could set the parent to be always on top of the child window, even while performing WinMove(possible?)

Thirdly, are there any better ways I can go about this, or any tips/criticisms?

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

  • Moderators

Wombat,

This OnEvent version works for me:

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

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnEsc", 1)

Global $hGUI_Child

$hGUI_Main = GUICreate("Main", 300, 300, 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainGUIClose")
GUISetBkColor(0xFFCCCC)
$cButton = GUICtrlCreateButton("Show Child", 10, 10, 80, 30)
GUICtrlSetOnEvent(-1, "_SH_Child")
GUISetState()

_Create_Child()

GUIRegisterMsg($WM_MOVE, "_Position_Child")

While 1
    Sleep(10)
WEnd

Func _Create_Child()
    $hGUI_Child = GUICreate("Follower", 175, 324, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main)
    GUISetBkColor(0xCCFFCC)
    _Position_Child($hGUI_Main, 0, 0, 0)
    GUISetState(@SW_HIDE, $hGUI_Child)
EndFunc   ;==>_Create_Child

Func _SH_Child()
    If GUICtrlRead($cButton) = "Show Child" Then
        GUISetState(@SW_SHOW, $hGUI_Child)
        GUICtrlSetData($cButton, "Hide Child")
        WinActivate($hGUI_Main)
    Else
        GUISetState(@SW_HIDE, $hGUI_Child)
        GUICtrlSetData($cButton, "Show Child")
    EndIf
EndFunc   ;==>_SH_Child

Func _Position_Child($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hGUI_Main Then Return
    Local $aGUI_Main_Pos = WinGetPos($hGUI_Main)
    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2] + 2, $aGUI_Main_Pos[1]) ; Removed speed, why slow it it all down? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndFunc   ;==>_Position_Child

Func MainGUIClose()
    Exit
EndFunc   ;==>MainGUIClose
Look at how the functions are written - your initial script spread bits of the required code all over the place. :)

And have you looked at my GUIExtender UDF? You might find it an easier solution to having extra bits of GUI appear and disappear that creating children like this. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I'm actually trying to make the child window slide out from behind the parent. I'll take a look at your GUIExtender UDF

This is a mockup of what I'm trying to achieve:

e0fy.png

h0ik.png

When the arrow/tab is pressed the child gui slides out from behind the parent, when pressed again the child slides behind the parent and is hidden/deleted/etc....

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

  • Moderators

Wombat,

I am on my phone at the moment so I cannot post code, but we should be able to do what you want

by animating the child as it appears/disappears. I will try to develop something this evening. :)

My GUIExtender UDF does not slide, but I think it would be worth a look. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I downloaded the zip and perused through it, it's awesome but not what I'm attempting to accomplish.

Just a heads up, the child gui will be an autoit window and the parent will not. I have all the information on the non-autoit window.

for now though we can run tests on anything really, notepad or whatever you find easiest, in the mean time I'll be pouring over the forum, help file, and google, to see what I can come up with. I'm trying hard to not rely on the community as much and learn via the help file and examples on the forum to teach myself what i need but this one has me stumped.

thanks, btw

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

  • Moderators

Wombat,

A "proof of concept" script that uses "q" as a HotKey for child activation:

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

If Not WinExists("Untitled - Notepad") Then
    Run("Notepad.exe")
    $hNotepad = WinWaitActive("Untitled - Notepad")
Else
    $hNotepad = WinGetHandle("Untitled - Notepad")
EndIf
WinMove($hNotepad, "", 100, 100, 500, 500)

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnEsc", 1)

Global $fChild = False

HotKeySet("q", "_SH_Child")

Global $hGUI_Child

_Create_Child()

GUIRegisterMsg($WM_MOVE, "_Position_Child")

While 1
    Sleep(10)
    If Not WinExists($hNotepad) Then
        Exit
    EndIf
WEnd

Func _Create_Child()
    $hGUI_Child = GUICreate("Follower", 200, 500, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hNotepad)
    GUISetBkColor(0xCCFFCC)
    _Position_Child($hNotepad, 0, 0, 0)
EndFunc   ;==>_Create_Child

Func _SH_Child()
    $fChild = Not $fChild
    If $fChild Then
        If Not $hGUI_Child Then
            _Create_Child()
        EndIf
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI_Child, "int", 1000, "long", 0x00040001) ; $AW_SLIDE_IN_LEFT
        WinActivate($hNotepad)
    Else
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI_Child, "int", 1000, "long", 0x00050002) ; $AW_SLIDE_OUT_LEFT
    EndIf
EndFunc   ;==>_SH_Child

Func _Position_Child($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hNotepad Then Return
    Local $aGUI_Main_Pos = WinGetPos($hNotepad)
    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2] + 2, $aGUI_Main_Pos[1])
EndFunc   ;==>_Position_Child
Let me know if you are interested and we can work on getting it as you want. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

we're getting closer, needs to update the childGUI with the parents when dragged, I'll dig into the code in a bit. Looks absolutely amazing, thank you.

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

  • Moderators

Wombat,

Oops, forgot that bit! :D

How about this:

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

If Not WinExists("Untitled - Notepad") Then
    Run("Notepad.exe")
    $hNotepad = WinWaitActive("Untitled - Notepad")
Else
    $hNotepad = WinGetHandle("Untitled - Notepad")
EndIf
WinMove($hNotepad, "", 100, 100, 500, 500)

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnEsc", 1)

Global $fChild = False

HotKeySet("q", "_SH_Child")

Global $hGUI_Child

_Create_Child()

While 1
    Sleep(10)
    If Not WinExists($hNotepad) Then
        Exit
    EndIf
    _Position_Child($hNotepad)
WEnd

Func _Create_Child()
    $hGUI_Child = GUICreate("Follower", 200, 500, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hNotepad)
    GUISetBkColor(0xCCFFCC)
    _Position_Child($hNotepad)
EndFunc   ;==>_Create_Child

Func _SH_Child()
    $fChild = Not $fChild
    If $fChild Then
        If Not $hGUI_Child Then
            _Create_Child()
        EndIf
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI_Child, "int", 1000, "long", 0x00040001) ; $AW_SLIDE_IN_LEFT
        WinActivate($hNotepad)
    Else
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI_Child, "int", 1000, "long", 0x00050002) ; $AW_SLIDE_OUT_LEFT
    EndIf
EndFunc   ;==>_SH_Child

Func _Position_Child($hNotepad)
    Local $aGUI_Main_Pos = WinGetPos($hNotepad)
    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2] + 2, $aGUI_Main_Pos[1])
EndFunc   ;==>_Position_Child
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Alright, so Melba, your script is just what i needed to get me started...Thank you very very much!

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Actually I'm getting an odd error:

C:\Documents and Settings\Edgeware\Desktop\webtests.au3 (92) : ==> Subscript used with non-Array variable.:
WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2]-2, $aGUI_Main_Pos[1])
WinMove($hGUI_Child, "", $aGUI_Main_Pos^ ERROR

Here's my full code edited per my requirements:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=ET_2.0_.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <file.au3>
#include <ComboConstants.au3>
#include <ScreenCapture.au3>

If Not WinExists("Mat. Iss -  Version: 2013.10.25.0") Then
    Run("ABC_Desktop.exe")
    $hABCDesktop = WinWaitActive("Mat. Iss -  Version: 2013.10.25.0")
Else
    $hABCDesktop = WinGetHandle("Mat. Iss -  Version: 2013.10.25.0")
EndIf

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnEsc", 1)

Global $fChild = False
Global Const $SYSTEMDRIVE = EnvGet('systemdrive')

HotKeySet("^z", "_SH_Child")

Global $hGUI_Child

_Create_Child()



Global $MIERToMyRet[2]
Global $MIERToMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

While 1
    Sleep(10)
    If Not WinExists($hABCDesktop) Then
       Sleep(10)
    EndIf
    _Position_Child($hABCDesktop)
WEnd

Func _Create_Child()
    Local $aGUI_Main_Pos = WinGetPos($hABCDesktop)
    $hGUI_Child = GUICreate("Follower", $aGUI_Main_Pos[2]-5, $aGUI_Main_Pos[3]-2, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hABCDesktop)

    Global $MIERTTitle = GUICtrlCreateLabel("MIERT Ticket Commenting Window", 166, 16, 215, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

    Global $MIERTdescrp1 = GUICtrlCreateLabel("Please use this window to add any needed comments to the ticket you are sending.", 75, 56, 397, 17)

    Global $MIERTdescrp2 = GUICtrlCreateLabel("If no comments are needed then simply add your Employee ID Number by scanning it into the first box.", 32, 96, 483, 17)

    Global $MIERTIDfield = GUICtrlCreateInput("0", 167, 160, 217, 21)

    Global $MIERTeID = GUICtrlCreateLabel("Employee ID Number:", 221, 136, 107, 17)

    Global $MIERTComLabel = GUICtrlCreateLabel("Comments:", 245, 185, 56, 17)

    Global $MIERTErrorCombo = GUICtrlCreateCombo("", 175, 200, 200, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, " WH Shortage|Wrong WH|Wrong LOT#|Ivalid LOT#|Invalid BIN|Incorrect Weight|Different Weight| |Custom Comment", "")
    GUICtrlSetOnEvent(-1, "_ShowComntBox")

    Global $MIERTCmntBox = GUICtrlCreateEdit("", 59, 248, 449, 121, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL))
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetData(-1, "")

    Global $MIERTButton1 = GUICtrlCreateButton("SEND", 149, 392, 249, 65)
    GUICtrlSetOnEvent(-1, "_SendEmail")

    GUISetBkColor(0xFFFFFF)
    _Position_Child($hABCDesktop)
EndFunc   ;==>_Create_Child

Func _SH_Child()
    $fChild = Not $fChild
    If $fChild Then
        If Not $hGUI_Child Then
            _Create_Child()
        EndIf
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI_Child, "int", 1000, "long", 0x00040001) ; $AW_SLIDE_IN_LEFT
        WinActivate($hABCDesktop)
    Else
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI_Child, "int", 1000, "long", 0x00050002) ; $AW_SLIDE_OUT_LEFT
    EndIf
EndFunc   ;==>_SH_Child

Func _Position_Child($hABCDesktop)
    Local $aGUI_Main_Pos = WinGetPos($hABCDesktop)
    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2]-2, $aGUI_Main_Pos[1])
EndFunc   ;==>_Position_Child


Func _SendEmail()
    Local $MIERTIDcheck = GUICtrlRead($MIERTIDfield)
    If $MIERTIDcheck = 0 Then
        MsgBox(1, "Required Input", "You must enter your Employee ID to contiue" & @CRLF & "If you wish to exit this tool, press the ESCAPE key")
    Else
        Local $MIERTuID = GUICtrlRead($MIERTIDfield)
        Local $MIERTcom = GUICtrlRead($MIERTCmntBox)
        Global $MIERTComments = "Employee ID: " & $MIERTuID & @CRLF & @CRLF & "Comments:" & @CRLF & $MIERTcom

        Send("^q")
        Sleep(10)
        _ScreenGrab()
    EndIf
EndFunc

Func _ScreenGrab()
    FileDelete($SYSTEMDRIVE & "\MIERT\System\Screens\MIERT_SC.jpg")
    WinActivate("Program Manager")
    Send("{F5}")
    Sleep(10)
    Local $MIERThBmp
    Sleep(10)
    ; Capture full screen
    $MIERThBmp = _ScreenCapture_Capture("")
    Sleep(10)
    ; Save bitmap to file
    _ScreenCapture_SaveImage($SYSTEMDRIVE & "\MIERT\System\Screens\MIERT_SC.jpg", $MIERThBmp)
    Sleep(2000)
    _EmailResults()
EndFunc

Func _EmailResults()

Global $MIERTSmtpServer = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "SmtpServer", Default)              ; address for the smtp-server to use - REQUIRED
Global $MIERTFromName = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "FromName", Default)   ; name from who the email was sent
Global $MIERTFromAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "FromAddress", Default) ; address from where the mail should come
Global $MIERTToAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "ToAddress", Default)   ; destination address of the email - REQUIRED
Global $MIERTSubject = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Subject", Default)                   ; subject from the email - can be anything you want it to be
Global $MIERTBody = $MIERTErrorCombo & @CR & $MIERTComments         ; the messagebody from the mail - can be left blank but then you get a blank mail
Global $MIERTAttachFiles = @ScriptDir & IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "AttachFiles", Default)          ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
Global $MIERTCcAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "CcAddress", Default)       ; address for cc - leave blank if not needed
Global $MIERTBccAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "BccAddress", Default)     ; address for bcc - leave blank if not needed
Global $MIERTImportance = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Importance", Default)                  ; Send message priority: "High", "Normal", "Low"
Global $MIERTUsername = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Username", Default)                    ; username for the account used from where the mail gets sent - REQUIRED
Global $MIERTPassword = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Password", Default)                  ; password for the account used from where the mail gets sent - REQUIRED
Global $MIERTIPPort = Number(IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "IPPort", Default))                            ; port used for sending the mail
Global $MIERTssl = Number(IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "SSL", Default))                                ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $MIERTIPPort=465                          ; GMAIL port used for sending the mail
;~ $MIERTssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS


$MIERTrc = _INetSmtpMailCom($MIERTSmtpServer, $MIERTFromName, $MIERTFromAddress, $MIERTToAddress, $MIERTSubject, $MIERTBody, $MIERTAttachFiles, $MIERTCcAddress, $MIERTBccAddress, $MIERTImportance, $MIERTUsername, $MIERTPassword, $MIERTIPPort, $MIERTssl)

    If @error Then
        MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $MIERTrc)
    Else
        _NotifySuccess()
    EndIf
    Exit
EndFunc

Func _NotifySuccess()
    MsgBox(0, "Ticket Submitted", "The Error Tool successfuly submitted your ticket")
EndFunc

;##################################
; Function that sends the email
;##################################
Func _INetSmtpMailCom($MIERTs_SmtpServer, $MIERTs_FromName, $MIERTs_FromAddress, $MIERTs_ToAddress, $MIERTs_Subject = "", $MIERTas_Body = "", $MIERTs_AttachFiles = "", $MIERTs_CcAddress = "", $MIERTs_BccAddress = "", $MIERTs_Importance="Normal", $MIERTs_Username = "", $MIERTs_Password = "", $MIERTIPPort = 25, $MIERTssl = 0)
    Local $MIERTobjEmail = ObjCreate("CDO.Message")
    $MIERTobjEmail.From = '"' & $MIERTs_FromName & '" <' & $MIERTs_FromAddress & '>'
    $MIERTobjEmail.To = $MIERTs_ToAddress
    Local $MIERTi_Error = 0
    Local $MIERTi_Error_desciption = ""
    If $MIERTs_CcAddress <> "" Then $MIERTobjEmail.Cc = $MIERTs_CcAddress
    If $MIERTs_BccAddress <> "" Then $MIERTobjEmail.Bcc = $MIERTs_BccAddress
    $MIERTobjEmail.Subject = $MIERTs_Subject
    If StringInStr($MIERTas_Body, "<") And StringInStr($MIERTas_Body, ">") Then
        $MIERTobjEmail.HTMLBody = $MIERTas_Body
    Else
        $MIERTobjEmail.Textbody = $MIERTas_Body & @CRLF
    EndIf
    If $MIERTs_AttachFiles <> "" Then
        Local $MIERTS_Files2Attach = StringSplit($MIERTs_AttachFiles, ";")
        For $MIERTx = 1 To $MIERTS_Files2Attach[0]
            $MIERTS_Files2Attach[$MIERTx] = _PathFull($MIERTS_Files2Attach[$MIERTx])
;~          ConsoleWrite('@@ Debug : $MIERTS_Files2Attach[$MIERTx] = ' & $MIERTS_Files2Attach[$MIERTx] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
            If FileExists($MIERTS_Files2Attach[$MIERTx]) Then
                ConsoleWrite('+> File attachment added: ' & $MIERTS_Files2Attach[$MIERTx] & @LF)
                $MIERTobjEmail.AddAttachment($MIERTS_Files2Attach[$MIERTx])
            Else
                ConsoleWrite('!> File not found to attach: ' & $MIERTS_Files2Attach[$MIERTx] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $MIERTs_SmtpServer
    If Number($MIERTIPPort) = 0 then $MIERTIPPort = 25
    $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $MIERTIPPort
    ;Authenticated SMTP
    If $MIERTs_Username <> "" Then
        $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $MIERTs_Username
        $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $MIERTs_Password
    EndIf
    If $MIERTssl Then
        $MIERTobjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $MIERTobjEmail.Configuration.Fields.Update
    ; Set Email Importance
    Switch $MIERTs_Importance
        Case "High"
            $MIERTobjEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $MIERTobjEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $MIERTobjEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $MIERTobjEmail.Fields.Update
    ; Sent the Message
    $MIERTobjEmail.Send
    If @error Then
        SetError(2)
        Return $MIERToMyRet[1]
    EndIf
    $MIERTobjEmail=""
EndFunc   ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $MIERTHexNumber = Hex($MIERToMyError.number, 8)
    $MIERToMyRet[0] = $MIERTHexNumber
    $MIERToMyRet[1] = StringStripWS($MIERToMyError.description, 3)
    FileWriteLine($SYSTEMDRIVE & "\MIERT\System\ErrorLogs\MIERT_error_log_" & @MON & "." & @MDAY & "." & @SEC & ".txt", "### COM Error !  Number: " & $MIERTHexNumber & "   ScriptLine: " & $MIERToMyError.scriptline & "   Description:" & $MIERToMyRet[1] & @LF & "END COM ERROR ####")
    SetError(1); something to check for when this function returns
    Return
EndFunc   ;==>MyErrFunc

Func WM_NCHITTEST($MIERThWnd, $MIERTiMsg, $MIERTwParam, $MIERTlParam);Window Dragging
    #forceref $MIERThWnd, $MIERTiMsg, $MIERTwParam, $MIERTlParam
    Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func MainGUIClose()
    Exit
EndFunc

Func _ShowComntBox()
    If GUICtrlRead($MIERTErrorCombo)="Custom Comment" Then
        GUICtrlSetState($MIERTCmntBox, $GUI_SHOW)
    EndIf

    If Not(GUICtrlRead($MIERTErrorCombo)="Custom Comment") Then
        GUICtrlSetState($MIERTCmntBox, $GUI_HIDE)
    EndIf

EndFunc

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

I can only imagine that an error occurred. According to the help file:

"Returns 0 and sets @error to 1 if window is not found."

So I suggest to check @error for a non zero value after calling WinGetPos.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Solved it, as the function that moves the child gui is constantly running, but i needed the script to still run after the parent GUI was closed and only function(show the child gui) if the parent exists...

So I added:

Func _Position_Child($hABCDesktop)
    Local $aGUI_Main_Pos = WinGetPos($hABCDesktop)
    If Not WinExists($hABCDesktop) Then
       GUIDelete($hGUI_Child)
    Else
       WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2]-2, $aGUI_Main_Pos[1])
    EndIf
EndFunc   ;==>_Position_Child
Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

I would first check the existance of the window and then - if it exists - grab the position:

Func _Position_Child($hABCDesktop)
    If Not WinExists($hABCDesktop) Then
       GUIDelete($hGUI_Child)
    Else
       Local $aGUI_Main_Pos = WinGetPos($hABCDesktop)
       WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2]-2, $aGUI_Main_Pos[1])
    EndIf
EndFunc   ;==>_Position_Child
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

 

I would first check the existance of the window and then - if it exists - grab the position:

Func _Position_Child($hABCDesktop)
    If Not WinExists($hABCDesktop) Then
       GUIDelete($hGUI_Child)
    Else
       Local $aGUI_Main_Pos = WinGetPos($hABCDesktop)
       WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2]-2, $aGUI_Main_Pos[1])
    EndIf
EndFunc   ;==>_Position_Child

 

good point, I'm in a rush and looked over it sorry :/

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

Your code works as well. But I try to avoid unnecessary code.

In a few months you would ask yourself why you get the position of awindow before you check if it exists. Been there, done that ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...