Open "Action Item Settings"

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Posts: 10
Joined: Thu Aug 11, 2011 1:48 pm

Open "Action Item Settings"

Post by jmsosullivan » Thu Aug 11, 2011 2:11 pm


I've created a remote in Visaul Basic, and I can send events to EvenGhost for activating a USB-UIRT action no problem.

However, I want to be able to send an event, and for the "Action Item Settings" for the associated USB-UIRT action to open.

Is there any way to do this?

Thanks for your help.

EventGhost 0.4.1.r1534

Windows Vista Home Premium
6.0.6001 Service Pack 1 Build 6001

Posts: 10
Joined: Thu Aug 11, 2011 1:48 pm

Re: Open "Action Item Settings"

Post by jmsosullivan » Sat Sep 03, 2011 12:59 pm

I've finally found the solution, although it is in my opinion incredibly complicated. I'll post it here incase anybody else is trying to do the same thing.

To give some background, I wanted, with a click of a button in a Visual Basic application, to open a specified USB-UIRT "Action Item Settings" window. After the IR code is learnt, and the "Ok" button is clicked to save the code and close the "Action Item Settings" window, I then wanted EventGhost to automatically close aswell. Here's the code:

Note: Ensure that a timer is placed on the Visual Basic form, and that its interval is set to 1000.

Code: Select all

Public Class DVD_Remote_Trainer

    Public count As Integer
    Public EventGhost As String = "C:\Program Files\EventGhost\EventGhost.exe"
    'Find Window API
    Private Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If count = 0 Then
            Timer1.Enabled = False
            count -= 1
        End If
    End Sub

    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
        count = 2
        Timer1.Enabled = True
        LearnIR("Action Name")
    End Sub

 'Open EventGhost and emulate keystrokes to open Action Item Settings dialog for USB-UIRT configuration
    Public Sub LearnIR(ByVal ActionName As String)

        Shell(EventGhost, vbNormalFocus, True, 500)
        SendKeys.Send("USB-UIRT: " & ActionName)
        SendKeys.Send("{TAB 6}")
        SendKeys.Send("{ENTER 2}")

    End Sub

    'Wait until Action Item Settings dialog is closed, then close EventGhost
    Public Sub wait()

        Dim open As Boolean = True

        Do Until open = False
            If WaitForWindow("Action Item Settings") = False Then
                open = False
            End If

    End Sub

    'Find window by title, "Action Item Settings" in this case
    Public Function WaitForWindow(ByVal wTitle As String) As Boolean
        Dim hwnd As Int32 = 0 ''''''''''''''''''''''''Initialize handle
        Do                                           'Loop this thread
            hwnd = apiFindWindow(Nothing, wTitle) ''''Find window by title
            If hwnd <> 0 Then ''''''''''''''''''''''''I window is open return true
                Return True
                Return False
            End If
    End Function

    'Function to close the main window of an application
    Public Function close(ByVal name As String, Optional ByVal all As Boolean = True) As Boolean
        Dim value As Boolean = False
        For Each instance As Process In Process.GetProcesses
            If instance.ProcessName.ToLower = name.ToLower Then
                value = True
                If Not all Then Exit For
            End If
        Return value
    End Function
Hope this helps somebody trying to do the same thing

Post Reply