Code: Select all
Global A,B$,IqHandle,BUTTON1,BUTTON2
Macro MakeLong(low,high)
(((high&$FFFF)<<16) | (low&$FFFF))
EndMacro
Procedure EnumChildProc(hwnd, lParam)
VALUE=AllocateMemory(128)
; For any hwnd, you can 'nest' calls to EnumChildWindows and to other EnumChildProc
result = #True ; continue searching
If GetWindowText_(hwnd, VALUE, 128)
If PeekS(VALUE)=B$
A=hwnd
result = #False ; search succesful, stop callback, do whatever
EndIf
EndIf
ProcedureReturn result
EndProcedure
Procedure gethandle()
Shared statusbar
;automatically get the handle 2 buttons
HANDLE=IqHandle
If HANDLE
GetWindowThreadProcessId_(HANDLE, @ProcID_)
Global hProc_ = OpenProcess_(#PROCESS_ALL_ACCESS, 0, ProcID_)
B$="1"
EnumChildWindows_(HANDLE, @EnumChildProc(), 0)
BUTTON1=A
B$="2"
EnumChildWindows_(HANDLE, @EnumChildProc(), 0)
BUTTON2=A
EndIf
EndProcedure
Procedure Main()
Protected x,y
Protected point.Point
Protected cursor.Point
;Protected IqHandle
IqHandle=OpenWindow(0,100,100,200,200,"")
ButtonGadget(1,20,20,40,20,"1")
ButtonGadget(2,20,50,40,20,"2")
OpenWindow(1,400,100,200,200,"Control")
ButtonGadget(666,20,20,40,20,"Go 1")
ButtonGadget(999,20,40,40,20,"Go 2")
gethandle()
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 666
SendMessage_(BUTTON1,#WM_LBUTTONDOWN,0,0)
SendMessage_(BUTTON1,#WM_LBUTTONUP,0,0)
SendMessage_(BUTTON2,#WM_LBUTTONDOWN,0,0)
SendMessage_(BUTTON2,#WM_LBUTTONUP,0,0)
Case 999
If IsWindowVisible_(IqHandle)
point\x=25
point\y=50
ClientToScreen_(IqHandle,point)
GetCursorPos_(cursor)
SetCursorPos_(point\x,point\y)
mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
SetCursorPos_(cursor\x,cursor\y)
EndIf
Case 1
MessageRequester("","1")
Case 2
MessageRequester("","2")
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndProcedure
Main()