Folks, I am still using FileZilla as I prefer it and still cleaning up and adding to my certificate error monitor/killer if anyone is interested. Still a few things I need to do but for now, the current improved code is below.
Code: Select all
#AtTheEndOfTheList = -1
#EditorReadWrite = 0 ; Editable
#EditorReadOnly = 1 ; Readonly
Enumeration 1
#TitleBarClockTimer
EndEnumeration
Define EventID, MenuID, GadgetID, WindowID
Enumeration 1
#Window_Monitor
EndEnumeration
#WindowIndex = #PB_Compiler_EnumerationValue
Enumeration 1
#Gadget_Monitor_Messages
#Gadget_Monitor_Strings
#Gadget_Monitor_MonitorState
#Gadget_Monitor_StringsState
#Gadget_Monitor_StickyWindow
#Gadget_Monitor_ExitProgram
#Gadget_Monitor_Statusbar
EndEnumeration
#GadgetIndex = #PB_Compiler_EnumerationValue
Structure ProgramData
ProgramQuit.i
WindowCounter.i
MonitorStatus.i
EditorStatus.i
WindowStatus.i
EndStructure
Structure WindowStructure
WindowDate.s
WindowTime.s
WindowHandle.i
WindowCounter.i
EndStructure
Global NewList WindowHandlesToKill.WindowStructure()
Global Program.ProgramData
; Setup day and month literal names
Global Dim NameOfDay.s(7) ; Fill an array with the names of the days (Terry Hough I think)
NameOfDay(0) = "Sunday"
NameOfDay(1) = "Monday"
NameOfDay(2) = "Tuesday"
NameOfDay(3) = "Wednesday"
NameOfDay(4) = "Thursday"
NameOfDay(5) = "Friday"
NameOfDay(6) = "Saturday"
Global Dim DaysPerMonth(12) ; Fill an array on how many days per month there are
For X = 0 To 11
DaysPerMonth(X) = 31
Next
DaysPerMonth(1) = 28
DaysPerMonth(3) = 30
DaysPerMonth(5) = 30
DaysPerMonth(8) = 30
DaysPerMonth(10) = 30
Global Dim NameOfMonth.s(12) ; Fill an array with the names of the months
NameOfMonth(0) = "January"
NameOfMonth(1) = "February"
NameOfMonth(2) = "March"
NameOfMonth(3) = "April"
NameOfMonth(4) = "May"
NameOfMonth(5) = "June"
NameOfMonth(6) = "July"
NameOfMonth(7) = "August"
NameOfMonth(8) = "September"
NameOfMonth(9) = "October"
NameOfMonth(10) = "November"
NameOfMonth(11) = "December"
Global Dim Years.s(19) ; Fill an array with the years
Years(0) = "2002"
Years(1) = "2003"
Years(2) = "2004"
Years(3) = "2005"
Years(4) = "2006"
Years(5) = "2007"
Years(6) = "2008"
Years(7) = "2009"
Years(8) = "2010"
Years(9) = "2011"
Years(10) = "2012"
Years(11) = "2013"
Years(12) = "2014"
Years(13) = "2015"
Years(14) = "2016"
Years(15) = "2017"
Years(16) = "2018"
Years(17) = "2019"
Years(18) = "2020"
Declare.i Window_Monitor()
Declare KillaWindow(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)
Declare ToggleMonitorState()
Declare ToggleEditStringsState()
Declare ToggleWindowState()
Procedure.i Window_Monitor()
If OpenWindow(#Window_Monitor,97,92,825,415,"Kill specified windows that match strings",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Minimize|#PB_Window_Invisible)
SetWindowColor(#Window_Monitor,$FFFFFF)
ListIconGadget(#Gadget_Monitor_Messages,5,5,815,290,"Message",280,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
SetGadgetColor(#Gadget_Monitor_Messages,#PB_Gadget_BackColor,$FFFFFF)
AddGadgetColumn(#Gadget_Monitor_Messages,1,"Date",200)
AddGadgetColumn(#Gadget_Monitor_Messages,2,"Time",116)
AddGadgetColumn(#Gadget_Monitor_Messages,3,"Handle",115)
AddGadgetColumn(#Gadget_Monitor_Messages,4,"Counter",100)
SetGadgetFont(#Gadget_Monitor_Messages,LoadFont(#Gadget_Monitor_Messages,"Segoe Print",8,0))
EditorGadget(#Gadget_Monitor_Strings,5,300,815,50,#PB_Editor_ReadOnly|#PB_Editor_WordWrap)
SetGadgetColor(#Gadget_Monitor_Strings,#PB_Gadget_BackColor,$949494)
SetGadgetFont(#Gadget_Monitor_Strings,LoadFont(#Gadget_Monitor_Strings,"Segoe Print",10,0))
ButtonGadget(#Gadget_Monitor_MonitorState,5,355,200,30,"Start monitor")
SetGadgetFont(#Gadget_Monitor_MonitorState,LoadFont(#Gadget_Monitor_MonitorState,"Segoe Print",10,0))
ButtonGadget(#Gadget_Monitor_StringsState,210,355,200,30,"Edit strings")
SetGadgetFont(#Gadget_Monitor_StringsState,LoadFont(#Gadget_Monitor_StringsState,"Segoe Print",10,0))
ButtonGadget(#Gadget_Monitor_StickyWindow,415,355,200,30,"Sticky window")
SetGadgetFont(#Gadget_Monitor_StickyWindow,LoadFont(#Gadget_Monitor_StickyWindow,"Segoe Print",10,0))
ButtonGadget(#Gadget_Monitor_ExitProgram,620,355,200,30,"Exit program")
SetGadgetFont(#Gadget_Monitor_ExitProgram,LoadFont(#Gadget_Monitor_ExitProgram,"Segoe Print",10,0))
StringGadget(#Gadget_Monitor_Statusbar,5,390,815,20,"",#PB_String_ReadOnly|#PB_String_BorderLess)
SetGadgetColor(#Gadget_Monitor_Statusbar,#PB_Gadget_BackColor,$E5E5E5)
SetGadgetFont(#Gadget_Monitor_Statusbar,LoadFont(#Gadget_Monitor_Statusbar,"Segoe Script",8,0))
HideWindow(#Window_Monitor,0)
ProcedureReturn WindowID(#Window_Monitor)
EndIf
EndProcedure
Procedure KillaWindow(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)
ForEach WindowHandlesToKill.i()
ButtonOnCertificateWindow.i = FindWindowEx_(WindowHandlesToKill()\WindowHandle.i, 0, "Button", "OK") ; Must explicitly search for "OK"!
If ButtonOnCertificateWindow.i
AddGadgetItem(#Gadget_Monitor_Messages, #AtTheEndOfTheList, "Killed found window with OK" + #LF$ + ; Window message
WindowHandlesToKill()\WindowDate.s + #LF$ + ; Date of event
WindowHandlesToKill()\WindowTime.s + #LF$ + ; Time of event
Str(WindowHandlesToKill()\WindowHandle.i) + #LF$ + ; Window handle (Id)
Str(WindowHandlesToKill()\WindowCounter.i)) ; Number of the event
SetGadgetItemColor(#Gadget_Monitor_Messages, #PB_All, #PB_Gadget_FrontColor, $0000FF, 0)
SetGadgetItemColor(#Gadget_Monitor_Messages, #PB_All, #PB_Gadget_FrontColor, $FF0000, 1)
SetGadgetItemColor(#Gadget_Monitor_Messages, #PB_All, #PB_Gadget_FrontColor, $008000, 2)
SendMessage_(GadgetID(#Gadget_Monitor_Messages), #LVM_ENSUREVISIBLE, Program\WindowCounter.i, 0) ; Make sure the current line is visible
Program\WindowCounter.i + 1
SetForegroundWindow_(WindowHandlesToKill()\WindowHandle.i)
;SendMessage_(WindowHandlesToKill()\WindowHandle.i, #WM_SYSCOMMAND, #SC_CLOSE, 0)
SendMessage_(ButtonOnCertificateWindow.i, #BM_CLICK, 0, 0)
DeleteElement(WindowHandlesToKill())
EndIf
Next
CertificateWindowHandle.i = FindWindow_(0, "Unknown certificate")
If CertificateWindowHandle.i
LocalTimeDate.i = Date()
DateString.s = NameOfDay(DayOfWeek(LocalTimeDate.i)) + Space(1)
DateNumber.i = Day(LocalTimeDate.i)
Select DateNumber.i
Case 1, 21, 31 : SuffixString.s = "'st"
Case 2, 22 : SuffixString.s = "'nd"
Case 3, 23 : SuffixString.s = "'rd"
Case 4 To 20 : SuffixString.s = "'th"
Case 24 To 30 : SuffixString.s = "'th"
EndSelect
DateString.s + Str(DateNumber) + SuffixString.s + Space(1)
; DateString.s + Str(Day(LocalTimeDate.i)) + Space(1)
DateString.s + NameOfMonth(Month(LocalTimeDate.i) - 1) + Space(1)
DateString.s + Str(Year(LocalTimeDate.i))
; Fangbeast, you have a global for timezone offset, used here as offset had nowhere to come
; from, so nice & simple you were sooooo close :)
; Regards, Baldrick :):)
; UtcTime = AddDate(LocalTimeDate, #PB_Date_Minute,Program\TimeOffset);Offset)
; utc time from local time
HourVal.i = Hour(LocalTimeDate.i)
MinuteVal.i = Minute(LocalTimeDate.i)
SecondVal.i = Second(LocalTimeDate.i)
Hour12.i = HourVal.i % 12 ; Added to fix midnight 0 hour fault
If Not Hour12.i ;= 12 changed see above
Hour12.i = 12 ; HourVal ; 0 will now display as 12
EndIf
If HourVal.i > 11
Suffix.s = " PM"
Else
Suffix.s = " AM"
EndIf
TimeString.s = "(12) " + Str(Hour12.i) + ":" + RSet(Str(MinuteVal.i), 2, "0") + ":" + RSet(Str(SecondVal.i), 2, "0") + Suffix.s
AddElement(WindowHandlesToKill.i())
WindowHandlesToKill()\WindowDate.s = DateString.s
WindowHandlesToKill()\WindowTime.s = TimeString.s
WindowHandlesToKill()\WindowHandle.i = CertificateWindowHandle.i
WindowHandlesToKill()\WindowCounter.i = Program\WindowCounter.i
DateString.s = #Empty$
AddGadgetItem(#Gadget_Monitor_Messages, #AtTheEndOfTheList, "Found OK button on window" + #LF$ + ; Window message
WindowHandlesToKill()\WindowDate.s + #LF$ + ; Date of event
WindowHandlesToKill()\WindowTime.s + #LF$ + ; Time of event
Str(WindowHandlesToKill()\WindowHandle.i) + #LF$ + ; Window handle (Id)
Str(Program\WindowCounter.i)) ; Number of the event
SetGadgetItemColor(#Gadget_Monitor_Messages, #PB_All, #PB_Gadget_FrontColor, $0000FF, 0)
SetGadgetItemColor(#Gadget_Monitor_Messages, #PB_All, #PB_Gadget_FrontColor, $FF0000, 1)
SetGadgetItemColor(#Gadget_Monitor_Messages, #PB_All, #PB_Gadget_FrontColor, $008000, 2)
SendMessage_(GadgetID(#Gadget_Monitor_Messages), #LVM_ENSUREVISIBLE, Program\WindowCounter.i + 1, 0) ; Make sure the current line is visible
Program\WindowCounter.i + 1
EndIf
EndProcedure
Procedure ToggleMonitorState()
If Program\MonitorStatus.i = #False
Program\MonitorStatus.i = #True
SetGadgetText(#Gadget_Monitor_Statusbar, "The process monitor has been started.")
SetGadgetText(#Gadget_Monitor_MonitorState, "Stop the monitor")
SetTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer, 100, @KillaWindow()) ; 1000 = 1 second
ElseIf Program\MonitorStatus.i = #True
Program\MonitorStatus.i = #False
SetGadgetText(#Gadget_Monitor_Statusbar, "The process monitor has been stopped.")
SetGadgetText(#Gadget_Monitor_MonitorState, "Start the monitor")
KillTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer)
EndIf
EndProcedure
Procedure ToggleEditStringsState()
If Program\EditorStatus.i = #EditorReadOnly
Program\EditorStatus.i = #EditorReadWrite ; Turn on edit mode
SetGadgetText(#Gadget_Monitor_Statusbar, "Process strings can be edited now")
SetGadgetText(#Gadget_Monitor_StringsState, "Lock process strings")
SetGadgetAttribute(#Gadget_Monitor_Strings, #PB_Editor_ReadOnly, Program\EditorStatus.i) ; Read Only)
SetGadgetColor(#Gadget_Monitor_Strings, #PB_Gadget_BackColor, $FFFFFF)
ElseIf Program\EditorStatus.i = #EditorReadWrite
Program\EditorStatus.i = #EditorReadOnly ; Turn off edit mode
SetGadgetText(#Gadget_Monitor_StringsState, "Edit process strings")
SetGadgetText(#Gadget_Monitor_Statusbar, "Process strings have been locked")
SetGadgetAttribute(#Gadget_Monitor_Strings, #PB_Editor_ReadOnly, Program\EditorStatus.i) ; Editable)
SetGadgetColor(#Gadget_Monitor_Strings, #PB_Gadget_BackColor, $949494)
EndIf
EndProcedure
Procedure ToggleWindowState()
If Program\WindowStatus.i = #False
Program\WindowStatus.i = #True ; Turn on sticky window mode
StickyWindow(#Window_Monitor, #True)
SetGadgetText(#Gadget_Monitor_StickyWindow, "Sticky window")
SetGadgetText(#Gadget_Monitor_Statusbar, "Monitor window stays on top")
ElseIf Program\WindowStatus.i = #True
Program\WindowStatus.i = #False ; Turn off sticky window mode
StickyWindow(#Window_Monitor, #False)
SetGadgetText(#Gadget_Monitor_StickyWindow, "Hide window")
SetGadgetText(#Gadget_Monitor_Statusbar, "Monitor window stays hidden")
EndIf
EndProcedure
;
If Window_Monitor()
HideWindow(#Window_Monitor, #False)
StickyWindow(#Window_Monitor, #False)
Program\ProgramQuit = #False ; Don't quit
Program\MonitorStatus.i = #False ; Monitor off
Program\EditorStatus.i = #EditorReadOnly ; Strings editable
Program\WindowStatus.i = #False ; Monitor hidden
Program\WindowCounter.i = #False ; No items in list
SetGadgetText(#Gadget_Monitor_Statusbar, "Program started, monitor is not awake. Press 'Start Monitor' to begin")
Repeat
EventID = WaitWindowEvent()
MenuID = EventMenu()
GadgetID = EventGadget()
WindowID = EventWindow()
TimerId = EventTimer()
Select EventID
Case #PB_Event_CloseWindow
Select WindowID
Case #Window_Monitor : Program\ProgramQuit = #True
EndSelect
Case #PB_Event_Timer
Select Timerid
Case #TitleBarClockTimer :
EndSelect
Case #PB_Event_Gadget
Select GadgetID
Case #Gadget_Monitor_MonitorState : ToggleMonitorState()
Case #Gadget_Monitor_StringsState : ToggleEditStringsState()
Case #Gadget_Monitor_StickyWindow : ToggleWindowState()
Case #Gadget_Monitor_ExitProgram : Program\ProgramQuit = #True
EndSelect
EndSelect
Until Program\ProgramQuit
KillTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer)
CloseWindow(#Window_Monitor)
EndIf
End