Now a little bit has changed the code with the coordinates
Code: Select all
RunProgram("chrome.exe","https://www.purebasic.fr/english/index.php","",#PB_Program_Open)
Global r.RECT
Procedure.l EnumWindowsProc_(lhWnd.l, lJunk.l)
If GetWindowModuleFileName_(lhWnd, @sFileName.s{#MAX_PATH}, #MAX_PATH)
If GetWindowText_(lhWnd, @sWindowTitle.s{#MAX_PATH}, #MAX_PATH)
If FindString(sWindowTitle,"Chrome")
GetWindowRect_(lhWnd, r.RECT)
EndIf
EndIf
EndIf
ProcedureReturn #True
EndProcedure
EnumWindows_(@EnumWindowsProc_(), #Null)
Delay (Random(5000,2000))
SetCursorPos_(Random(r\right,r\left),Random(r\bottom,r\top))
Temp.POINT ;
MouseX=(Random(8, 900));
MouseY=(Random(8, 800))
MessageRequester("Window position","Left "+r\left+" | Right "+r\right+" | Top "+r\top+" | Bottom "+r\bottom, #PB_MessageRequester_Ok | #PB_MessageRequester_Info)
Delay (Random(6000,5000))
KillProgram(Prog)
CloseProgram(Prog)
and here I also made a mistake, clicking does not happen in the browser window.
clicks elsewhere
and the browser after the action, does not close
Code: Select all
KillProgram(Prog)
CloseProgram(Prog)
experimenting, I'm not entirely sure,
but it seems click occurs
not in the browser window.
click occurs in the computer operating system window
Code: Select all
RunProgram("chrome.exe","https://www.purebasic.fr/english/index.php","",#PB_Program_Open)
Global r.RECT
Procedure.l EnumWindowsProc_(lhWnd.l, lJunk.l)
If GetWindowModuleFileName_(lhWnd, @sFileName.s{#MAX_PATH}, #MAX_PATH)
If GetWindowText_(lhWnd, @sWindowTitle.s{#MAX_PATH}, #MAX_PATH)
If FindString(sWindowTitle,"Chrome")
GetWindowRect_(lhWnd, r.RECT)
EndIf
EndIf
EndIf
ProcedureReturn #True
EndProcedure
EnumWindows_(@EnumWindowsProc_(), #Null)
Delay(Random(20000,10000))
Temp.POINT ;
MouseX=(Random(800, 9)) ;
MouseY=(Random(800, 9))
GetCursorPos_(@Temp) ;
SetCursorPos_(MouseX, MouseY) ;
mouse_event_(#MOUSEEVENTF_ABSOLUTE | #MOUSEEVENTF_LEFTDOWN, MouseX,MouseY,0,0) ;
Delay(Random(60000, 3600)) ;
mouse_event_(#MOUSEEVENTF_ABSOLUTE | #MOUSEEVENTF_LEFTUP, MouseX,MouseY,0,0) ;
SetCursorPos_(Temp\x, Temp\y) ;
mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0)
mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0)
MessageRequester("Window position","Left "+r\left+" | Right "+r\right+" | Top "+r\top+" | Bottom "+r\bottom, #PB_MessageRequester_Ok | #PB_MessageRequester_Info)
Delay (Random(6000,5000))
KillProgram(Prog)
CloseProgram(Prog)
but here different values
so the program did not automatically close
Code: Select all
RunProgram("chrome.exe","https://www.purebasic.fr/english/index.php","",#PB_Program_Open)
instead
Code: Select all
Prog=RunProgram("chrome.exe","https://www.purebasic.fr/english/index.php","",#PB_Program_Open)
Code: Select all
Delay (Random(6000,5000))
KillProgram(Prog)
CloseProgram(Prog)