serena_knight Posted March 23, 2023 Share Posted March 23, 2023 is there a way to get the mouse pointer on a msgbox when it appears on the screen? Link to comment Share on other sites More sharing options...
ioa747 Posted March 23, 2023 Share Posted March 23, 2023 MouseGetPos() I know that I know nothing Link to comment Share on other sites More sharing options...
serena_knight Posted March 23, 2023 Author Share Posted March 23, 2023 ??? dont understand Link to comment Share on other sites More sharing options...
serena_knight Posted March 23, 2023 Author Share Posted March 23, 2023 (edited) 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 March 23, 2023 by serena_knight Link to comment Share on other sites More sharing options...
ioa747 Posted March 23, 2023 Share Posted March 23, 2023 something like that? MsgBox(4096, "title", "message") Local $hWin = WinWait("title") Local $Wpos = WinGetPos($hWin) MouseMove($Wpos[0] + $Wpos[2] /2, $Wpos[1] + $Wpos[3] /2) I know that I know nothing Link to comment Share on other sites More sharing options...
Nine Posted March 23, 2023 Share Posted March 23, 2023 (edited) @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 March 23, 2023 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ioa747 Posted March 23, 2023 Share Posted March 23, 2023 1 hour ago, Nine said: @ioa747 Did you try your code ? yes did I miss something? I know that I know nothing Link to comment Share on other sites More sharing options...
mikell Posted March 23, 2023 Share Posted March 23, 2023 2 hours ago, serena_knight said: used those coordinates to move the mouse prior to using msgbox More reliable (basic) Opt("MouseCoordMode", 2) Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(4096, ''test1'', ''This is a test'')"') $hw = WinWaitActive("test1") $posC = ControlGetPos($hw, "", "Button1") MouseMove($posC[0]+30, $posC[1]+10, 0) Link to comment Share on other sites More sharing options...
bogQ Posted March 23, 2023 Share Posted March 23, 2023 (edited) 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 March 23, 2023 by bogQ ioa747 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) 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 More sharing options...
ioa747 Posted March 23, 2023 Share Posted March 23, 2023 (edited) 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 March 23, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
pixelsearch Posted March 23, 2023 Share Posted March 23, 2023 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 KaFu 1 Link to comment Share on other sites More sharing options...
Dan_555 Posted March 23, 2023 Share Posted March 23, 2023 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 More sharing options...
funkey Posted March 23, 2023 Share Posted March 23, 2023 (edited) 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 March 23, 2023 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now