Checks to see if a specified window exists?

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2225
Joined: Sun May 14, 2017 1:48 am

Re: Checks to see if a specified window exists?

Post 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.
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Checks to see if a specified window exists?

Post 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)
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Mesa
Enthusiast
Enthusiast
Posts: 447
Joined: Fri Feb 24, 2012 10:19 am

Re: Checks to see if a specified window exists?

Post 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



Post Reply