Jump to content

Gaining the position of the cursor


Recommended Posts

Hi, maybe noob question but how can i get the id of the inputbox in which the cursor is?

I need it because i have buttons which would send keys to the inputbox in which the cursor is.. I can't do this since when i press the button the the cursor diappears so the only method is to record the cursor position constantly..

thx for the help

My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
Link to comment
Share on other sites

Well, I think this is what you want:

$pos = MouseGetPos ()
MsgBox(0,"","X position of mouse = " & $pos[0] & @CRLF & "Y position of mouse = " & $pos[1])

Description of MouseGetPos():

Returns a two-element array that containing the mouse coordinates: $array[0] = X coord (horizontal), $array[1] = Y coord (vertical)

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

Well, I think this is what you want:

$pos = MouseGetPos ()
MsgBox(0,"","X position of mouse = " & $pos[0] & @CRLF & "Y position of mouse = " & $pos[1])

Description of MouseGetPos():

Returns a two-element array that containing the mouse coordinates: $array[0] = X coord (horizontal), $array[1] = Y coord (vertical)

Kurt

Anwsering without reading the post, smart :) Thx anyway
My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
Link to comment
Share on other sites

I have not used it, but I think you would use ControlGetFocus()

Can't realy make it work, i would only want to get the control id if its an inputbox, any idea on doing that ?

The other solution would be if buttons couldn't get focus..is that solveable ?

My programs:[topic="40019"]Sudoku[/topic], [topic="41258"]Suitcase game & Random jokes[/topic], [topic="41641"]8 Queens[/topic], [topic="41679"]Puzzle Generator[/topic], [topic="42045"]Snake[/topic]My UDFs:[topic="41309"]Prime functions & Prime game[/topic]Other:Fake emailer
Link to comment
Share on other sites

I think this may do what you want:

;Control Id from ClassnameNN --eltorro <steve at ocotillo sytes net>
$Gui = GuiCreate("Input Test")
$Input1 = GUICtrlCreateInput("",5,5,100,20)
$Input2 = GuiCtrlCreateInput("",5,25,100,20)
$Input3 =  GuiCtrlCreateInput("",5,50,100,20)
GUISetState()

$lastCNN =""
  
Opt("WinTitleMatchMode",4)
While 1
    $nMsg = GuiGetMsg()
    if $nMsg = -3 then Exit
    $control = ControlGetFocus("Input Test","")
    if StringLeft($control,4) = "Edit" then
        if $lastCNN <> $control Then
            $lastCNN = $control
            ConsoleWrite($control&@LF)
            $cHwnd = ControlGetHandle("Input Test","",$control)
            if $cHwnd Then
            $CtrlId = _GetDlgCtrlID($cHwnd)
            ConsoleWrite("Control ID = "&$CtrlId&@LF)
            EndIf
        EndIf
    EndIf
    
    Switch $nMsg
        Case -3
            Exit
        Case $Input1 
            ConsoleWrite("Control Id ="&$Input1&@LF)
        Case $Input2 
            ConsoleWrite("Control Id ="&$Input2&@LF)
        Case $Input3 
            ConsoleWrite("Control Id ="&$Input3&@LF)
        Case Else
            ;;;
    EndSwitch
    sleep(10)
WEnd
Exit

;===============================================================================
; Function Name:    GetDlgCtrlID
; Description:
; Parameter(s):        $hwnd    Handle of control
; Requirement(s):    Beta (for dllcall)
; Return Value(s):    Control Id on success
; Author(s):
;===============================================================================
Func _GetDlgCtrlID($hwnd)
    $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd)
    if IsArray ($ID) Then Return $ID[0]
    Return 0
EndFunc   ;==>GetDlgCtrlID

Regards,

eltorro

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...