Page 1 of 1
					
				sending mouseclick to other coordinate without movin[SOLVED]
				Posted: Sun Jul 20, 2008 7:43 am
				by .:M:.
				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.
			 
			
					
				
				Posted: Sun Jul 20, 2008 10:19 am
				by Derek
				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
 
			 
			
					
				
				Posted: Sun Jul 20, 2008 2:10 pm
				by Rook Zimbabwe
				This would be perfect to force someone to click OK to download malware!  

 
			 
			
					
				
				Posted: Sun Jul 20, 2008 2:16 pm
				by PB
				But it doesn't do what M wanted, which is to click the mouse at a specific point
without moving the mouse there. I don't think that's possible.
			 
			
					
				
				Posted: Sun Jul 20, 2008 2:24 pm
				by srod
				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!  

 
			 
			
					
				
				Posted: Sun Jul 20, 2008 3:01 pm
				by Derek
				Rook Zimbabwe wrote:This would be perfect to force someone to click OK to download malware!  

 
Only if you can get the id or whatever of the button you want to click.
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.  

 
			 
			
					
				
				Posted: Sun Jul 20, 2008 3:56 pm
				by .:M:.
				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?
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()
 
			 
			
					
				
				Posted: Tue Jul 22, 2008 7:27 am
				by .:M:.
				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.
 
			 
			
					
				
				Posted: Tue Jul 22, 2008 12:57 pm
				by Sparkie
				.:M:. wrote:...because the user shouldn't move over the webgadget
Why not let the user do their own mouse clicking? What are you trying to accomplish here?
 
			 
			
					
				
				Posted: Tue Jul 22, 2008 1:27 pm
				by Derek
				He could be trying to insert data into googles search instead of the user having to type it but you are right it does seem a bit strange.
			 
			
					
				
				Posted: Tue Jul 22, 2008 3:17 pm
				by Rook Zimbabwe
				See!
Age and Paranoia will always triumph over youth and stupidity!
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
			 
			
					
				
				Posted: Tue Jul 22, 2008 5:49 pm
				by .:M:.
				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.