Jump to content

msgbox focus


Recommended Posts

i want to position the mouse pointer on the msgbox when i send the message

the only way is see to do it is give the msgbox a title

have a seperate script running wait for the box to appear 

use the mousegetpos and move the mouse to the msgbox

*** this did not work ***


while 1

winwait("commsg")


$mp = mousegetpos()
$mx = $mp[0]
$my = $mp[1]

mousemove($mx,$my)

wend
 

i just used the info tool to find the pos of the msgbox on the screen

and used those coordinates to move the mouse prior to using msgbox

problem resolved

 

Edited by serena_knight
Link to comment
Share on other sites

@ioa747  Did you try your code ?

@serena_knight You should know by now how to post code, please refer to the previous link,

Solved it for another function, but it can easily be applied to MsgBox :

 

Edited by Nine
Link to comment
Share on other sites

you did 😀 , msgbox is blocking element in script, so there is not a way to position mouse in this case while msgbox is still on the screen from the same script. that is probably what he is referring to

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Ah, I got it, I tried the script and the mouse went to msgbox , that's why I didn't notice it , probably didn't catch it, it was very fast?

 

edit:
I found it, it was running second instance in background
 

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

As an alternative, I remember @KaFu did something interesting using Timers, in this link
Adapted to OP's need :

#include <MsgBoxConstants.au3>
#include <WinAPISysWin.au3>

MouseMove(200, 200, 0) ; 0 = fastest mouse move
ToolTip("See the mouse pointer ?")
Sleep(2000) ; just to see where is the mouse pointer on the screen (200, 200)
ToolTip("")

Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword')
Local $iTimerID = _WinAPI_SetTimer(0, 0, 10, DllCallbackGetPtr($hTimerProc))

MsgBox($MB_TOPMOST, "_WinAPI_SetTimer", "Does not block") ; mouse moved automatically over Msgbox

_WinAPI_KillTimer(0, $iTimerID)
DllCallbackFree($hTimerProc)

;===============================================
Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime)
    Local $hActive = WinActive("_WinAPI_SetTimer")
    If $hActive Then
        _WinAPI_KillTimer(0, $iTimerID)
        Local $Wpos = WinGetPos($hActive)
        MouseMove($Wpos[0] + $Wpos[2] /2,  $Wpos[1] + $Wpos[3] /2, 0)       
    EndIf
EndFunc   ;==>_TimerProc

 

Link to comment
Share on other sites

Alternatively you could create a custom gui, which would act as a message box. 

In that way you could control where the Gui appear and move the mouse to the desired position.

 

There are few custom msg boxes which you can find on this forum.

I have one for the input box and one as a msg box with a slightly different button placement. 

Some of my script sourcecode

Link to comment
Share on other sites

If you don't need the return value of the MsgBox you can use this:

 

#include <Misc.au3>

Global $WinTitle = "Title"

_MsgBox(48, $WinTitle, "Some text", 1)
WinWait($WinTitle)

Global $aPos = WinGetPos($WinTitle)

_MouseTrap($aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3])

While WinExists($WinTitle)
    Sleep(50)
WEnd

_MouseTrap()


Func _MsgBox($iFlag, $sTitle, $sMsg, $iOnTop = 0, $iTimeout = 0, $hParent = 0)
    ;Nonblocking MessageBox
    ;funkey 2010.05.20
    If $iOnTop <> 0 Then $iOnTop = 0x40000
    Local $str = "MsgBox('" & $iOnTop + $iFlag & "', '" & $sTitle & "', '" & $sMsg & "', '" & $iTimeout & "', '" & $hParent & "')"
    Local $Exe = @AutoItExe
    Run('"' & $Exe & '" /AutoIt3ExecuteLine "' & $str & '"')
EndFunc   ;==>_MsgBox

 

 

Edit: Just saw now, that @mikell already presented this kind of solution.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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...