Page 2 of 2

Re: Checks to see if a specified window exists?

Posted: Thu Apr 20, 2023 4:18 pm
by AZJIO
BarryG wrote: Thu Apr 20, 2023 8:45 am Anything AutoIt can do, so can PureBasic
Can you write ControlTreeView + Expand + Select to work with a third party window?
I understand that you can write photoshop, but some things that AutoIt3 gives out of the box I can't write in PureBasic, but not because PureBasic can't do it.
In AutoIt3, using a regular expression, you can make a replacement in a binary file.

Re: Checks to see if a specified window exists?

Posted: Fri Apr 21, 2023 4:42 am
by jacdelad
RK_aus_S wrote: Thu Apr 20, 2023 9:50 am I can't expect that PureBasic will deliver all the comparable functions of AutoIt, there will certainly be "only" a more or less big overlap (and vica-versa).
Challenge accepted! 8)

Re: Checks to see if a specified window exists?

Posted: Fri Apr 21, 2023 10:14 am
by Mesa
Should be multiplatform :?:

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
	Import ""
		PB_Object_EnumerateStart(PB_Objects)
		PB_Object_EnumerateNext(PB_Objects, *ID.Integer)
		PB_Object_EnumerateAbort(PB_Objects)
		PB_Object_GetObject(PB_Object , DynamicOrArrayID)
		PB_Window_Objects
		
	EndImport
CompilerElse
	ImportC ""
		PB_Object_EnumerateStart(PB_Objects)
		PB_Object_EnumerateNext(PB_Objects, *ID.Integer)
		PB_Object_EnumerateAbort(PB_Objects)
		PB_Object_GetObject(PB_Object , DynamicOrArrayID)
		PB_Window_Objects.i
		
	EndImport
CompilerEndIf


Procedure WinExists(Title$)
	Protected  titlefound$
	PB_Object_EnumerateStart(PB_Window_Objects)
	While PB_Object_EnumerateNext(PB_Window_Objects, @object)
		If IsWindow(object)
			titlefound$= GetWindowTitle(object)
			If titlefound$=Title$
				result=#True
				Break
			Else
				result=#False
			EndIf
		EndIf
	Wend
	PB_Object_EnumerateAbort(PB_Objects)
	ProcedureReturn result
EndProcedure


win=10
OpenWindow(win, 50, 50, 222, 150, "Tests10", #PB_Window_SystemMenu|#PB_Window_NoActivate )
ButtonGadget(0, 10, 10, 200, 25, "Standard Button")
ButtonGadget(1, 10, 40, 200, 25, "Left Button", #PB_Button_Left)

OpenWindow(1, 300, 50, 222, 150, "Tests1", #PB_Window_SystemMenu) 
OpenWindow(2, 50, 300, 222, 150, "Tests2", #PB_Window_SystemMenu|#PB_Window_Invisible ) 
ww=OpenWindow(#PB_Any,300,300,200,150,"#PB_Any", #PB_Window_SystemMenu|#PB_Window_Tool) 


Debug WinExists("Tests10");1
Debug WinExists("Tests2");1
Debug WinExists("Tests1");1
Debug WinExists("Tests");0
Debug WinExists("#PB_Any");1


Repeat
	
	Event = WaitWindowEvent()
	
Until Event = #PB_Event_CloseWindow