Press OK on an external application form? [Solved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Press OK on an external application form? [Solved]

Post by Fangbeast »

I am using an FTP manager called FileZilla that keeps throwing random certificate errors and it's driving me nuts.

Does anyone have that bit of code that searches for child windows by title?

I want to write a little stub to sit in memory, checking for windows once in a while and closing the certificate form so that I can go to sleep.

I still have over 80,000 files in the transfer queue and am exhausted sitting here:):)

I think the below *should* work..

*Update*. Works a treat

Code: Select all

; 

#AtTheEndOfTheList = -1

; 

Enumeration 1
  #TitleBarClockTimer
EndEnumeration

; 

Define.i  hW_BTN,  WindowHandle
Define    EventID, MenuID, GadgetID, WindowID

; 

Enumeration 1
  #Window_Monitor
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  #Gadget_Monitor_Messages
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

; 

Declare.i Window_Monitor()
Declare   KillCertificate(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)

; 

Procedure.i Window_Monitor()
  If OpenWindow(#Window_Monitor, 87, 82, 400, 300, "Kill FileZilla certificate!", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
      EditorGadget(#Gadget_Monitor_Messages, 5, 5, 390, 290, #PB_Editor_ReadOnly)
        SetGadgetColor(#Gadget_Monitor_Messages, #PB_Gadget_FrontColor, $0000FF)
        SetGadgetFont(#Gadget_Monitor_Messages, LoadFont(#Gadget_Monitor_Messages, "Segoe Print", 10, 0))
      HideWindow(#Window_Monitor, 0)
    ProcedureReturn WindowID(#Window_Monitor)
  EndIf
EndProcedure

; 

Procedure KillCertificate(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)
 
  WindowHandle.i    = FindWindow_(0, "Unknown certificate")
  
  If WindowHandle.i
   
    AddGadgetItem(#Gadget_Monitor_Messages, #AtTheEndOfTheList, "Found target window handle:  " + Str(WindowHandle.i))
   
    hW_BTN = FindWindowEx_(WindowHandle.i, 0, "Button", "OK")    ; Must explicitly search for "OK"!
   
    If hW_BTN
     
      AddGadgetItem(#Gadget_Monitor_Messages, #AtTheEndOfTheList, "Found target ok button handle:  " + Str(hW_BTN))
      
      SetForegroundWindow_(WindowHandle.i)
      
      ; SetActiveWindow_(WindowHandle)
      ; SendMessage_(hW_BTN, #BM_CLICK, 0, 0)
      ; Delay(30)
      ; SetForegroundWindow_(WindowHandle)
      ; SetActiveWindow_(WindowHandle)
      ; SendMessage_(hW_BTN, #BM_CLICK, 0, 0)
      
      SendMessage_(WindowHandle.i, #WM_SYSCOMMAND, #SC_CLOSE, 0)
      
    EndIf
    
  EndIf
  
EndProcedure

; 

If Window_Monitor()

  Define quitMonitor = #False
  
  SetTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer, 5000, @KillCertificate())    ; 1000 = 1 second
  
  Repeat
    EventID  = WaitWindowEvent()
    MenuID   = EventMenu()
    GadgetID = EventGadget()
    WindowID = EventWindow()
    TimerId  = EventTimer()
    Select EventID
      Case #PB_Event_CloseWindow
        Select WindowID
          Case #Window_Monitor      : quitMonitor = #True
        EndSelect
      Case #PB_Event_Timer
        Select Timerid
          Case  #TitleBarClockTimer : 
        EndSelect
      Case #PB_Event_Gadget
        Select GadgetID
          Case #Gadget_Monitor_Messages
        EndSelect
    EndSelect
  Until quitMonitor
  KillTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer)
  CloseWindow(#Window_Monitor)
EndIf
End
On second thought, this is probably better. I was watching as my monitor was killing windows and noticed that some of the files were failing, even though the message about the invalid certificate was killed and I think it is a matter of timing. So I let a linked list track the id's and see how it goes with that now.

Code: Select all

; 

#AtTheEndOfTheList = -1

; 

Enumeration 1
  #TitleBarClockTimer
EndEnumeration

; 

Define    EventID, MenuID, GadgetID, WindowID

; 

Enumeration 1
  #Window_Monitor
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  #Gadget_Monitor_Messages
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

; 

Global NewList CertificateWindowHandlesToKill.i()

; 

Declare.i Window_Monitor()
Declare   KillCertificate(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)

; 

Procedure.i Window_Monitor()
  If OpenWindow(#Window_Monitor, 87, 82, 400, 300, "Kill FileZilla certificate!", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Minimize|#PB_Window_NoActivate|#PB_Window_Invisible)
      EditorGadget(#Gadget_Monitor_Messages, 5, 5, 390, 290, #PB_Editor_ReadOnly)
        SetGadgetColor(#Gadget_Monitor_Messages, #PB_Gadget_FrontColor, $0000FF)
        SetGadgetFont(#Gadget_Monitor_Messages, LoadFont(#Gadget_Monitor_Messages, "Segoe Print", 10, 0))
      HideWindow(#Window_Monitor, 0)
    ProcedureReturn WindowID(#Window_Monitor)
  EndIf
EndProcedure

; 

Procedure KillCertificate(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)
  ForEach CertificateWindowHandlesToKill.i()
    ButtonOnCertificateWindow.i = FindWindowEx_(CertificateWindowHandlesToKill.i(), 0, "Button", "OK")    ; Must explicitly search for "OK"!
    If ButtonOnCertificateWindow.i
      AddGadgetItem(#Gadget_Monitor_Messages, #AtTheEndOfTheList, "Found target ok button handle:  " + Str(ButtonOnCertificateWindow.i))
      ; SetForegroundWindow_(CertificateWindowHandle.i)
      SendMessage_(CertificateWindowHandlesToKill.i(), #WM_SYSCOMMAND, #SC_CLOSE, 0)
      DeleteElement(CertificateWindowHandlesToKill.i())
    EndIf
  Next
  CertificateWindowHandle.i    = FindWindow_(0, "Unknown certificate")
  If CertificateWindowHandle.i
    AddElement(CertificateWindowHandlesToKill.i())
    CertificateWindowHandlesToKill.i() = CertificateWindowHandle.i
    AddGadgetItem(#Gadget_Monitor_Messages, #AtTheEndOfTheList, "Found target window handle:  " + Str(CertificateWindowHandle.i))
  EndIf
EndProcedure

; 

If Window_Monitor()

  Define quitMonitor = #False
  
  SetTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer, 2000, @KillCertificate())    ; 1000 = 1 second
  
  Repeat
    EventID  = WaitWindowEvent()
    MenuID   = EventMenu()
    GadgetID = EventGadget()
    WindowID = EventWindow()
    TimerId  = EventTimer()
    Select EventID
      Case #PB_Event_CloseWindow
        Select WindowID
          Case #Window_Monitor      : quitMonitor = #True
        EndSelect
      Case #PB_Event_Timer
        Select Timerid
          Case  #TitleBarClockTimer : 
        EndSelect
      Case #PB_Event_Gadget
        Select GadgetID
          Case #Gadget_Monitor_Messages
        EndSelect
    EndSelect
  Until quitMonitor
  KillTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer)
  CloseWindow(#Window_Monitor)
EndIf
End
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

I know I marked the topic solved but I still have strange timing issues with closing a certificate window this way and having a download fail when it has done so.

About 1 file in 8 will fail.

I'm wondering if when a invalid certificate window pops up, is there a necessary delay for the underlying application (In this case, FileZilla) to actually register its own child window with the download event so it knows the child has been closed and fails when it's too fast?

I've experimented with different speed timings without much luck such as decreasing the timer, having delays between closes without much luck.

Does anyone have a better idea? The code in the top post works mostly.
Amateur Radio, D-STAR/VK3HAF
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Press OK on an external application form? [Solved]

Post by Dude »

Fangbeast wrote:Does anyone have a better idea?
Hi Fang, can the cert window be closed just by sending an Enter keystroke to it instead? Or with Alt+F4 on it? Or maybe Tabbing to the OK button and then doing an Enter or Space keystroke when it gets the focus (assuming the button always in the same spot).

If so, that would solve the problem of searching for the OK button and "clicking" it. Can you post a screenshot of the cert window (and make sure to blur any identifying info from it).
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

Hi Fang, can the cert window be closed just by sending an Enter keystroke to it instead? Or with Alt+F4 on it? Or maybe Tabbing to the OK button and then doing an Enter or Space keystroke when it gets the focus (assuming the button always in the same spot).

If so, that would solve the problem of searching for the OK button and "clicking" it. Can you post a screenshot of the cert window (and make sure to blur any identifying info from it).
Okay, I am officially an idiot and you reminded me (grin). Closing the window is not the same as clicking okay on it apparently.

If I do this:

SendMessage_(ButtonOnCertificateWindow.i, #BM_CLICK, 0, 0)

It may solve the timing issue. I will let you know in a few hours:):)
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

Well, it sort of worked. I was working on the false premise that I was getting all the windows but I wasn't thinking about it logically as usual (Shaddap srod ya mug!)

FindWindow_ find a SINGLE window so every time the timer fires, it finds a single window and closes it. The routine was firing fast enough to find several windows (luck on my part really) but missing a lot of others.

I should have been using EnumWindows_(@EnumWindowsProc(), 0) to find ALL windows when the timer fires but I am having trouble with it and it's getting late so will play tomorrow.

D'oh!
Amateur Radio, D-STAR/VK3HAF
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Press OK on an external application form? [Solved]

Post by Michael Vogel »

You can also try to check if the needed object has a certain class name, this could make life easier.

I am using tools like Microsofts UISpy to detect the objects class and/or name to get it's handle easily by Handle=FindWindow_("ClassName","") or Handle=FindWindow_(0,"Name"). When doing so, you can send messages like PostMessage_(Handle,#WM_CLOSE,0,0) etc. which may work fine for you...

Here's a code part I am using to control a program which would need tons of clicks - the BM_CLICK message never worked, so I did a workaround (see procedure Click);

Code: Select all

Structure ObjectType
	Handle.i
	Title.s
	Class.s
EndStructure

Global Registered

Procedure Click(button)

	Protected dot.Point
	Protected cur.Point

	;SendMessage_(\Handle,#BM_CLICK,0,0)

	ClientToScreen_(button,dot)
	GetCursorPos_(cur)

	SetCursorPos_(dot\x+50,dot\y+12)
	mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
	mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
	SetCursorPos_(cur\x,cur\y)

EndProcedure
Procedure GetObjectInfo(*Object.ObjectType,Set=#False)

	#MaxTextLength=256

	With *Object

		If Set
			\Handle=Set
		EndIf

		If \Handle
			\Title=Space(#MaxTextLength)
			\Class=Space(#MaxTextLength)
			GetWindowText_(\Handle,\Title,#MaxTextLength)
			GetClassName_(\Handle,\Class,#MaxTextLength)
			ProcedureReturn #True

		Else
			ProcedureReturn #False
		EndIf

	EndWith

EndProcedure


; Example code part:

Protected o.ObjectType

With o
	
	If GetObjectInfo(o,GetWindow_(\Handle,#GW_HWNDNEXT))
		If \Class="ClassEdit"
			If GetObjectInfo(o,GetWindow_(\Handle,#GW_HWNDNEXT))
				If \Class="ClassOkButton"
					Click(\Handle)
				EndIf
			EndIf
		EndIf
	EndIf

EndWith
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

Hi Michael, good code to be sure, thank you. I don't understand it yet though (May never with this brain, heheh).

By the way, to avoid prespacing a buffer (Not sure if it's a title string length limit), I use this

Code: Select all

GetWindowText_(WindowHandle.l, @WindowsTitle.s, [b]GetWindowTextLength_[/b](WindowHandle.l) + SizeOf(Character))
Of course, I am so title that I totally ruined my enumerate code and it now doesn't work when it did 15 minutes ago (LOL!)

It may work tomorrow when I have had some sleep and coffee, lots of it.
Amateur Radio, D-STAR/VK3HAF
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

I had time in between accidents. It's freezing here so I barely can move my fingers to code (and a vein blew in my finger, go figure!)

Nevertheless, I have redone the code and got it all working the way I want and clever people can extend it to suit their needs. It is currently killing invalid certificate popup windows in FileZilla, left, right and centre!!!

A few more things to do but see what you think folks. Done in pb5.62x86, tested in Windows 10x64 only.

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_ExitProgram
  #Gadget_Monitor_Statusbar
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

; 

Structure ProgramData
  ProgramQuit.i
  WindowCounter.i
  MonitorStatus.i
  EditorStatus.i
EndStructure

; 

Structure WindowStructure
  WindowDate.s
  WindowTime.s
  WindowHandle.i
  WindowCounter.i
EndStructure

; 

Global NewList  WindowHandlesToKill.WindowStructure()

Global Program.ProgramData

; 

Declare.i Window_Monitor()
Declare   KillaWindow(ObjectHandle.i, Message.i, EventNumber.i, TimePeriod.i)

; 

Procedure.i Window_Monitor()
  If OpenWindow(#Window_Monitor,97,92,705,385,"Kill specified windows that match user specified strings in the edit box",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Minimize|#PB_Window_NoActivate|#PB_Window_Invisible)
    SetWindowColor(#Window_Monitor,$FFFFFF)
    ListIconGadget(#Gadget_Monitor_Messages,5,5,695,260,"Message",320,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
      SetGadgetColor(#Gadget_Monitor_Messages,#PB_Gadget_BackColor,$FFFFFF)
      AddGadgetColumn(#Gadget_Monitor_Messages,1,"Date",75)
      AddGadgetColumn(#Gadget_Monitor_Messages,2,"Time",75)
      AddGadgetColumn(#Gadget_Monitor_Messages,3,"Handle",100)
      AddGadgetColumn(#Gadget_Monitor_Messages,4,"Counter",100)
      SetGadgetFont(#Gadget_Monitor_Messages,LoadFont(#Gadget_Monitor_Messages,"Courier",8,0))
    EditorGadget(#Gadget_Monitor_Strings,5,270,695,50,#PB_Editor_ReadOnly|#PB_Editor_WordWrap)
      SetGadgetColor(#Gadget_Monitor_Strings,#PB_Gadget_BackColor,$949494)
      SetGadgetFont(#Gadget_Monitor_Strings,LoadFont(#Gadget_Monitor_Strings,"Courier",9,0))
    ButtonGadget(#Gadget_Monitor_MonitorState,5,325,225,30,"Start the monitor")
      SetGadgetFont(#Gadget_Monitor_MonitorState,LoadFont(#Gadget_Monitor_MonitorState,"Courier",9,0))
    ButtonGadget(#Gadget_Monitor_StringsState,240,325,225,30,"Edit process strings")
      SetGadgetFont(#Gadget_Monitor_StringsState,LoadFont(#Gadget_Monitor_StringsState,"Courier",9,0))
    ButtonGadget(#Gadget_Monitor_ExitProgram,475,325,225,30,"Exit the program")
      SetGadgetFont(#Gadget_Monitor_ExitProgram,LoadFont(#Gadget_Monitor_ExitProgram,"Courier",9,0))
    StringGadget(#Gadget_Monitor_Statusbar,5,360,695,20,"",#PB_String_ReadOnly|#PB_String_BorderLess)
      SetGadgetColor(#Gadget_Monitor_Statusbar,#PB_Gadget_BackColor,$FFFFFF)
      SetGadgetFont(#Gadget_Monitor_Statusbar,LoadFont(#Gadget_Monitor_Statusbar,"Courier",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, WindowHandlesToKill()\WindowCounter.i, 0) ; Make sure the current line is visible
      ; 
      WindowHandlesToKill()\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
    ; 
    CurrentDate.i = Date()
    DateString.s  = FormatDate("%dd/%mm/%yyyy", CurrentDate.i)
    TimeString.s  = FormatDate("%hh:%ii:%ss",   CurrentDate.i)
    ; 
    AddElement(WindowHandlesToKill.i())
    WindowHandlesToKill()\WindowDate.s    = DateString.s
    WindowHandlesToKill()\WindowTime.s    = TimeString.s
    WindowHandlesToKill()\WindowHandle.i  = CertificateWindowHandle.i
    WindowHandlesToKill()\WindowCounter.i = Program\WindowCounter.i
    ; 
    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, 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_StringsState, "Lock process strings")
    SetGadgetText(#Gadget_Monitor_Statusbar,    "Process strings can be edited now")
    ; 
    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

; 

If Window_Monitor()
  ; 
  Program\ProgramQuit     = #False             ; Don't quit
  Program\MonitorStatus.i = #False             ; Monitor off
  Program\EditorStatus.i  = #EditorReadOnly    ; Strings editable
  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_ExitProgram  : Program\ProgramQuit = #True
        EndSelect
        ; 
    EndSelect
    ; 
  Until Program\ProgramQuit
  ; 
  KillTimer_(WindowID(#Window_Monitor), #TitleBarClockTimer)
  ; 
  CloseWindow(#Window_Monitor)
  ; 
EndIf
; 
End
Amateur Radio, D-STAR/VK3HAF
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Press OK on an external application form? [Solved]

Post by Marc56us »

Hello Fangbeast,

It won't directly answer your problem, but why not use WinSCP instead of FileZilla ?
It is also an FTP/SFTP client and works the same way as FileZilla, yes, freeware too.
It manages certificates very well and can be used in script mode (which it is able to generate on its own)

:wink:
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

Marc56us wrote:Hello Fangbeast,

It won't directly answer your problem, but why not use WinSCP instead of FileZilla ?
It is also an FTP/SFTP client and works the same way as FileZilla, yes, freeware too.
It manages certificates very well and can be used in script mode (which it is able to generate on its own)

:wink:
But then wouldn't learn to code around my problems and get very lazy. This way is better (Bigger wink)
Amateur Radio, D-STAR/VK3HAF
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Press OK on an external application form? [Solved]

Post by Dude »

Fangbeast wrote:But then wouldn't learn to code around my problems
Good man. :)
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

Dude wrote:
Fangbeast wrote:But then wouldn't learn to code around my problems
Good man. :)
I am not a man, I am a meat popsicle. As I get very close to 60, I find it harder and harder to think and figure things out for myself so I require more help.

If I just sat in the lounge watching tv because everything was just perfect and worked, I would get fat, the diabetes would get right out of control and I would die a few years of heart attack and worse.

Man wasn't meant to sit on his ass and have everything handed to him, he was made to work and think.

Us meat popsicles don't want everything done for us, we like to struggle:):)
Amateur Radio, D-STAR/VK3HAF
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Press OK on an external application form? [Solved]

Post by Dude »

Fangbeast wrote:I find it harder and harder to think and figure things out for myself so I require more help.
Don't let it bother you. I'm the same (albeit "only" 48). I've asked things here that I used to know (and/or should know), and luckily the good people like Rashad and others are happy to guide me. Like you, I try to work it out beforehand though, so I don't come across as "using" them. I post what I've done, what I've read, and what I've tried... because as you said, it's good to learn for yourself.

Lately I've been looking back over my main app (611 KB source, 14000 lines) and when I read the parts that I did myself, I wonder how the heck I did it! :shock: Did I really type that wall of text? I don't remember doing it! :lol:

One of my other apps looks 100% alien to me, which is surreal. It has its own custom icons that I created and so on, but I really have no recollection of creating them and writing the app. Maybe I should be worried that I'm starting to get Alheizmer's or something; I don't know. But yeah, I can't explain this weird fascination I have at reading my code and looking at my work and wondering when I did it and where I had the time. Anyone else ever had this?
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Press OK on an external application form? [Solved]

Post by Marc56us »

I too and worse ("only" 55), sometimes I look for a solution to a new problem, through the forum search engine, and I come across my own answers to people who had asked the same question a year before :o :shock: :mrgreen:

So, although I try to present my codes well and document them (a bit), I still feel one year later that they are uuencoded :?

Curiously, I read and write in Perl and RegEx like a novel.
But I've always been totally unable to do a crossword, even level one.
Go figure out how the brain works :?:

:wink:
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Press OK on an external application form? [Solved]

Post by Fangbeast »

I too and worse ("only" 55), sometimes I look for a solution to a new problem, through the forum search engine, and I come across my own answers to people who had asked the same question a year before :o :shock: :mrgreen:
OOh, I hate that. Lately, I have also found answers to problems I solved years ago. And I wondered why I didn't have my own source for it (I did but couldn't find it)
But I've always been totally unable to do a crossword, even level one.
I am not good at crosswords but am able to find words that my wife cannot and has never heard of so I am marginally useful there:):)

Someone once asked me why I format the way I do and my answer was so that I can read what I wrote 10 minutes later. Give me a week without formatting and kind people using single letter variables and I am so screwed:):)
Amateur Radio, D-STAR/VK3HAF
Post Reply