sending mouseclick to other coordinate without movin[SOLVED]
sending mouseclick to other coordinate without movin[SOLVED]
hello,
is it possible?
i have found no way to "simulate" a Lbutton mouseclick without moving the cursor to exact that point to be clicked.
sendmessage() and mouse_event() have no effect without setting the cursor
before.
why isn't it possible?
Or is there still another way?
thanx a lot.
			
			
													is it possible?
i have found no way to "simulate" a Lbutton mouseclick without moving the cursor to exact that point to be clicked.
sendmessage() and mouse_event() have no effect without setting the cursor
before.
why isn't it possible?
Or is there still another way?
thanx a lot.
					Last edited by .:M:. on Tue Jul 22, 2008 7:28 am, edited 1 time in total.
									
			
									
						Welcome to the forums, try this.
			
			
									
									
						Code: Select all
OpenWindow(0,0,0,800,600,"",$ca0001)
CreateGadgetList(WindowID(0))
ButtonGadget(1,100,100,100,30,"pressed")
Repeat
   If GetAsyncKeyState_(#VK_LBUTTON) And GetActiveWindow()=0
      SendMessage_(GadgetID(1),#WM_LBUTTONDOWN,0,0)
   EndIf
Until WaitWindowEvent()=16- Rook Zimbabwe
 - Addict

 - Posts: 4322
 - Joined: Tue Jan 02, 2007 8:16 pm
 - Location: Cypress TX
 - Contact:
 
Well, sending a #WM_LBUTTONDOWN to a window/control with lParam holding the relevant client coordinates works okay for general GUI stuff. I've done this before without a problem.  It does depend on what the aim of this is though - I mean you will not be able to synthesise a button click, for example, by doing this.
For screens and/or general desktop... well, that's another matter!
			
			
									
									For screens and/or general desktop... well, that's another matter!
I may look like a mule, but I'm not a complete ass.
						Only if you can get the id or whatever of the button you want to click.Rook Zimbabwe wrote:This would be perfect to force someone to click OK to download malware!
Anyway I was assuming he wanted to click on a gadget in a PB program without moving the mouse. Maybe if we are told more of what is needed then it can be figured out.
Hello,
It's for interacting with a WebGadget!
Ok, i want to klick the Button and then automaticly a leftclick should be done on a link in the webgadget.
i have made so many tests and code examples, but nothing works, i think its something wrong with the handle, or the coordinates?
This is my test, but nothing happens?
			
			
									
									
						It's for interacting with a WebGadget!
Ok, i want to klick the Button and then automaticly a leftclick should be done on a link in the webgadget.
i have made so many tests and code examples, but nothing works, i think its something wrong with the handle, or the coordinates?
This is my test, but nothing happens?
Code: Select all
Enumeration 
  #Web1
  #Button1 
EndEnumeration 
Procedure WindowOpen() 
  OpenWindow(1,0,0,500,400,"Window",#PB_Window_TitleBar|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) 
  CreateGadgetList(WindowID(1))  
    ButtonGadget(#Button1, 10, 10, 40, 20, "Test")
    WebGadget(#Web1, 10, 40, 480, 320, "www.google.de")
EndProcedure 
Procedure MakelParam(low.w, high.w)
  ProcedureReturn low + (high << 16)
EndProcedure
Procedure SimulateClick()
  mx.w= 473 ; These Coordinates are where a link should be, please check
  my.w= 376
  lParam = MakelParam(mx.w, my.w)
  SendMessage_(WindowID(1),#WM_LBUTTONDOWN,0,lParam) 
  SendMessage_(WindowID(1),#WM_LBUTTONUP,0,lParam) 
EndProcedure
Procedure EventHandling()
  Repeat 
    ;GetCursorPos_(pt.POINT)    ; Check Please where a Link is set in your WebGadget, I have used google germany.
 	  ;Debug "x:" + Str(pt\x) + "y:" + Str(pt\y)
    EventID=WaitWindowEvent() 
    Select EventID 
      Case #PB_Event_Gadget 
        Select EventGadget() 
          Case #Button1 	
              SimulateClick()     
        EndSelect 
    EndSelect
  Until EventID=#PB_Event_CloseWindow
  CloseWindow(1) 
  End
EndProcedure
Procedure Main()
  WindowOpen()
  EventHandling()
EndProcedure
Main()
Ok, I got it.
The problem with the webgadget is, that the gadgetid() isn't the handle of the browser inside the gadget
 
I have tested with WindowFromPoint().
With the real handle u can simulate clicks into "the browser inside the webgadget
", on every x/y coordinate u want to.
Now i'm looking for another way to get the handle, because the user shouldn't move over the webgadget.
			
			
									
									
						The problem with the webgadget is, that the gadgetid() isn't the handle of the browser inside the gadget
I have tested with WindowFromPoint().
With the real handle u can simulate clicks into "the browser inside the webgadget
Now i'm looking for another way to get the handle, because the user shouldn't move over the webgadget.
- Rook Zimbabwe
 - Addict

 - Posts: 4322
 - Joined: Tue Jan 02, 2007 8:16 pm
 - Location: Cypress TX
 - Contact:
 
You all know those fake popups on the porn sites and fake AV sites (that I never go to!) that say CLICK OK or CANCEL... My bet is he wants to trap the closewindow X and make it OK
no, thats to easy!
my program will let the user have a long and hard fight with his mouse...
http://www.youtube.com/watch?v=PE_YZf6-gRY

Sure, I need these functions for automatisation (thats the reason computers were built for), but not the kind you think of.
i need it for parallelisation (multithreadding) of webgadgets for faster access and better usuability of special websites.
it's neccessary for faster searching, filtering the hits, display the content etc... all confirm to user-agreements.
theres a good reason why not to use special-website-apis, everyone
who has programmed similar applications knows why - api-calls almost have traffic limit and then u have to pay for more.
i will never agree to that - not if i program free applications for everyone.
			
			
									
									
						no, thats to easy!
my program will let the user have a long and hard fight with his mouse...
http://www.youtube.com/watch?v=PE_YZf6-gRY
Sure, I need these functions for automatisation (thats the reason computers were built for), but not the kind you think of.
i need it for parallelisation (multithreadding) of webgadgets for faster access and better usuability of special websites.
it's neccessary for faster searching, filtering the hits, display the content etc... all confirm to user-agreements.
theres a good reason why not to use special-website-apis, everyone
who has programmed similar applications knows why - api-calls almost have traffic limit and then u have to pay for more.
i will never agree to that - not if i program free applications for everyone.


