Jump to content

Recommended Posts

Posted

When I run my script the GUI getting embedded with our ticketing software gets buggy and random white blocks will appear above and below text and buttons if that makes sense. Am I possibly missing something in my script or is it a type of WinAPI issue?

 

#include <File.au3>
#include <WinAPI.au3>
#include <GUIConstants.au3>

Opt("WinTitleMatchMode",2)


Local $msg, $hwnd, $Nhandle
Global Enum $RFS_ERROR_RUN = 2
Global Const $g_sFileName = 'webtms.exe', _
        $g_sFilePath = 'C:\EIS\', _
        $g_sFileMsg = 'file         : "%s"\n(sub-)folder : "%s"\nlocated at   : "%s"\n'


; Launch Ticketing Software
If Not ProcessExists("webtms.exe") then
    $pid = _RunFromSubfolder($g_sFileName, $g_sFilePath)
    ProcessWait($pid)
EndIf

; Wait unti user signs in
Local $webtmsResolution = WinWait("[TITLE:[ohtmsa.oups.org]]")
$pos = WinGetPos($webtmsResolution)

; Create GUI with webTMS Width & Height
$hwnd = GUICreate("WebTMS Ticket Project",$pos[2],$pos[3],0,0, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUISetState()

; Embedding webTMS with AutoIT GUI
$Nhandle = WinGetHandle("[TITLE:[ohtmsa.oups.org]]")
_WinAPI_SetParent($Nhandle, $hwnd)
_WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
WinMove($Nhandle, "", 0, 0)

While ProcessExists("webtms.exe")

    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE ; Exitbutton
            ProcessClose($pid)
            _ProcessCloseEx("webtms.exe")
            ExitLoop
        Case Else
            ; enter other code here
    EndSelect

WEnd

Func _ProcessCloseEx($sPID)
    If IsString($sPID) Then $sPID = ProcessExists($sPID)
    If Not $sPID Then Return SetError(1, 0, 0)

    Return Run(@ComSpec & " /c taskkill /F /PID " & $sPID & " /T", @SystemDir, @SW_HIDE)
EndFunc

Func _RunFromSubfolder(Const $sFile, Const $sFolder)
    Local $sMessage = ''
    Local $iError = 0, _
            $iExtd = 0, _
            $iPID = 0
    Local Const $aItems = _FileListToArrayRec($sFolder, $sFile, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)

    If @error Then

        $iError = @error
        $iExtd = @extended

    Else

        $sMessage = StringFormat($g_sFileMsg, $sFile, $sFolder, $aItems[1])
        $iExtd = $aItems[0]
        $iPID = Run($aItems[1])

        If @error Then

            $iError = $RFS_ERROR_RUN
            $iExtd = @error

        EndIf

        ConsoleWrite($sMessage)

    EndIf

    Return SetError($iError, $iExtd, $iPID)
EndFunc   ;==>_RunFromSubfolder

 

GUI img 1 buggy.png

GUI img 2 Not buggy.png

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...