Hi @ILU
I see. I didn't mean to stress you. I just found this to be a fun function and decided to make a screencast of it. Then I felt like i should include it in this thread 🙂
An implementation of the autoclosing inputbox in your code would look something like this:
Class ThisRule
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA"(ByVal hWndParent As Integer, ByVal hWndChildAfter As Integer, ByVal lpszClass As String, ByVal lpszWindow As String) As Integer
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const BM_CLICK As Integer = &HF5&
Public WithEvents oTimer As New System.Windows.Forms.Timer
Dim second As Integer = 0
Dim oInputBoxName As String
Sub Main
oTimer.Interval = 1000
strClient = "M:\CLIENTS\"
oFilename = ThisDoc.FileName(False)
oProjectfol = (Left(oFilename, 6))
oProjectSubfol = "\3.Production\2.Drawings\1.Production designs\"
Dim dir1() As String = System.IO.Directory.GetDirectories(strClient, oProjectfol & "*")
Dim dir2 As String = String.Concat(dir1) & oProjectSubfol
modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
oTitle = iProperties.Value(modelName, "Summary", "Title")
oInputBoxName = "Save PDF to folder"
oTimer.Start
mbox = InputBox(dir2, oInputBoxName, oProjectfol & " - " & oTitle)
oTimer.Stop()
If mbox = "" Then
Return
Else
strNamePDF = dir2 & mbox
ThisDoc.Document.SaveAs(strNamePDF & (".pdf"), True)
End If
End Sub
Sub oTimer_Tick(ByVal sender As System.Object, ByVal E As System.EventArgs) Handles oTimer.Tick
second = second + 1
If second >= 5 Then
oTimer.Stop()
Try
Dim h1 = FindWindow(Nothing, oInputBoxName)
h2 = FindWindowEx(h1, h2, Nothing, "Cancel")
SendMessage(h2, BM_CLICK, 0, 0)
second = 0
Catch
'Cant find inputbox
End Try
End If
End Sub
End Class