Hi,
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
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Open "Action Item Settings"
-
jmsosullivan
- Posts: 10
- Joined: Thu Aug 11, 2011 1:48 pm
Re: Open "Action Item Settings"
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.
Hope this helps somebody 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
wait()
Else
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("{HOME}")
SendKeys.Send("^f")
SendKeys.Send("USB-UIRT: " & ActionName)
SendKeys.Send("{ENTER}")
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
close("EventGhost")
End If
Loop
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
Else
Return False
End If
Loop
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
instance.CloseMainWindow()
value = True
If Not all Then Exit For
End If
Next
Return value
End Function