Restored from previous forum. Originally posted by Paul.
Maybe someone can help me...
I'm using SetCursorPos_(x,y) to set the position of the Mouse pointer. Now I want to send a MouseClick so whatever the pointer is over, I can left or right click on it.
I'm assuming that I need to use:
SendMessage_(whnd,#WM_LBUTTONDOWN,0,0)
to send a left mouse click but this doesn't work so either I'm doing this wrong or I'm completely off base.
Anyone have any ideas?
Send Mouse CLick
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Here's another question...
I'm using the following code to get the X/Y position of the mouse cursor over the entire desktop:
This works fine. Now what I want to do is display this information in a form.
When displaying the form, if I use WaitWindowEvent() the TextGadget on the form that is displaying the info is only updated when the mouse passes over the window (this is no good for this application). If I use WindowEvent() the TextGadget is always updated regardless of mouse position (this is good) but now the app is using 100% processing power (no good).
If I add a Delay(10) in there, now the TextGadget is updated properly and processing power is good... but... when the Window is created, the buttons and gadgets on the form are drawn in slow motion before the window is accessable.
Everyone following so far?
Now why are the buttons and gadgets drawn on so slow, especially when we haven't gotten to the loop yet that contains the Delay command??
Any cure for this?
Here's another question...
I'm using the following code to get the X/Y position of the mouse cursor over the entire desktop:
Code: Select all
Structure tagPOINT
x.l
y.l
EndStructure
Point.tagPOINT
GetCursorPos_(@Point)
xpos=Point\x
ypos=Point\y
When displaying the form, if I use WaitWindowEvent() the TextGadget on the form that is displaying the info is only updated when the mouse passes over the window (this is no good for this application). If I use WindowEvent() the TextGadget is always updated regardless of mouse position (this is good) but now the app is using 100% processing power (no good).
If I add a Delay(10) in there, now the TextGadget is updated properly and processing power is good... but... when the Window is created, the buttons and gadgets on the form are drawn in slow motion before the window is accessable.
Everyone following so far?
Now why are the buttons and gadgets drawn on so slow, especially when we haven't gotten to the loop yet that contains the Delay command??
Any cure for this?
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Hi Paul, have you tried to put WindowEvent() before the loop, right after designing all gadgets?
The trick is to put min 2 times WindowEvent() otherwise this workaround will not work.
For myself I made a procedure like:
Procedure ShowGadgets()
WindowEvent() : WindowEvent() : WindowEvent()
EndProcedure
because I have had the same problem after the Delay() command.
Hope this helps...
Have a nice day...
Franco
Hi Paul, have you tried to put WindowEvent() before the loop, right after designing all gadgets?
The trick is to put min 2 times WindowEvent() otherwise this workaround will not work.
For myself I made a procedure like:
Procedure ShowGadgets()
WindowEvent() : WindowEvent() : WindowEvent()
EndProcedure
because I have had the same problem after the Delay() command.
Hope this helps...
Have a nice day...
Franco
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by michaelj.
HTH
Michael.
(Registered PureBasic user)
I'm suprised it slows down quite so much, but I'm sure Franco's advice is good. For efficiency (assuming you don't need cross platform), I'd use Sleep_(0), instead of the Delay. It cuts out one (albeit simple) extra call, and according to the API docs, Sleep given a value of 0 will yield to other threads, but not actually delay. This *may* still show 100% cpu, but won't affect other processes.Thanks for the info Franco, I'll give it a try.
I remember reading about this in another post but did not realize this is what it was relating to.
HTH
Michael.
(Registered PureBasic user)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm