Always on top
-
- Posts: 49
- Joined: Dec 16, 2011 3:48
Always on top
Is there a way in freebasic to use left click when mouse pointer is outside of console window or program's screen and not allow the console or program's screen to be minimized and be Always on top and see the coordinates on the window when mouse moves and by clicking save mouse coordinates(x.y) in a file?
Thank you in advance.
Thank you in advance.
Last edited by student1347 on Jun 05, 2017 15:34, edited 1 time in total.
Re: Always on top
Here is a start for your wish list. This will get the screen coordinates of the mouse whether inside or outside of the program windowvdecampo wrote:Yes
Code: Select all
#Include "windows.bi"
Dim As POINT pt
Do
If GetCursorPos(@pt) Then
Print pt.x, pt.y
End If
Sleep 100
Loop Until InKey=Chr(27)
-
- Posts: 49
- Joined: Dec 16, 2011 3:48
Re: Always on top
Thank you.... But when I left click the screen minimizes! (Not Always on top)
Re: Always on top
Code: Select all
#Include "windows.bi"
Dim As POINT pt
Dim As HWND handle
handle = GetConsoleWindow()
Do
If GetCursorPos(@pt) Then
Print pt.x, pt.y
End If
If GetForegroundWindow() <> handle then
SetForegroundWindow(handle)
SetFocus(handle)
End If
Sleep 100
Loop Until InKey=Chr(27)
Re: Always on top
Version with a thread to force the foreground and the focus if necessary:
[edit]
SLEEP was not inside the loop.
Code: Select all
#Include "windows.bi"
Dim As POINT pt
Dim As HWND handle
Dim As Any Ptr ht
Declare Sub Thread (Byval p As Any Ptr)
Dim Shared As Integer halt = 0
handle = GetConsoleWindow()
ht = Threadcreate(@Thread, handle)
Do
If GetCursorPos(@pt) Then
Print pt.x, pt.y
End If
Sleep 100
Loop Until InKey=Chr(27)
halt = 1
ThreadWait(ht)
Sub Thread (Byval p As Any Ptr)
Do
If GetForegroundWindow() <> p then
SetForegroundWindow(p)
SetFocus(p)
End If
Sleep 1
Loop Until halt = 1
End Sub
SLEEP was not inside the loop.
Last edited by fxm on Jun 06, 2017 12:46, edited 1 time in total.
-
- Posts: 49
- Joined: Dec 16, 2011 3:48
Re: Always on top
As always thank you fxm.
-
- Posts: 49
- Joined: Dec 16, 2011 3:48
Re: Always on top
Sorry.... and how can I retrieve mouse left click outside of the console window? GetMouse only retrieve mouse left click inside of the console window.(last part of my question)
Re: Always on top
Code: Select all
#Include "windows.bi"
Dim As POINT pt
Do
If GetCursorPos(@pt) Then
Print pt.x, pt.y
End If
If GetAsyncKeyState(VK_LBUTTON) Then Print "Left Button Pressed"
Sleep 100
Loop Until InKey=Chr(27)
-Vince
-
- Posts: 49
- Joined: Dec 16, 2011 3:48
Re: Always on top
Thanks a lot....vdecampo