nmontec Posted January 22, 2010 Share Posted January 22, 2010 Hello All, I've got the following function: Func StoreCoordinate() WinActivate("PPP") WinWaitActive("PPP") while 1 $msg=GUIGetMsg () if $msg<>0 Then if $msg==$GUI_EVENT_PRIMARYDOWN Then $Stella=MouseGetPos() ConsoleWrite($Stella[0]& " " & $Stella[1] & chr(13)) ExitLoop EndIf EndIf WEnd Return $Stella EndFunc This function never ends despite I clicked with the mouse many times. Do you know why the loop never ends? Thanks for the help Nicola Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 22, 2010 Moderators Share Posted January 22, 2010 nmontec, This function returns for me every time: Func StoreCoordinate() WinActivate("PPP") WinWaitActive("PPP") While 1 If GUIGetMsg() = $GUI_EVENT_PRIMARYDOWN Then $Stella = MouseGetPos() ConsoleWrite($Stella[0] & " " & $Stella[1] & @CRLF) Return $Stella EndIf WEnd EndFunc ;==>StoreCoordinate I hope it works for you too. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nmontec Posted January 23, 2010 Author Share Posted January 23, 2010 This function returns for me every time: No it does not work also in the way you rewrote it. This is the full code I tried: #include <GUIConstantsEx.au3> Func StoreCoordinate() WinActivate("PHD") WinWaitActive("PHD") While 1 If GUIGetMsg() = $GUI_EVENT_PRIMARYDOWN Then $Stella = MouseGetPos() ConsoleWrite($Stella[0] & " " & $Stella[1] & @CRLF) Return $Stella EndIf WEnd EndFunc AutoItSetOption("WinTitleMatchMode",2) AutoItSetOption ( "MouseCoordMode" , 0) $Stella=StoreCoordinate() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 23, 2010 Moderators Share Posted January 23, 2010 nmontec,You do realise that you can only click within the "PHD" window? As before, this code works for me - please try it and see it if works for you when you click within the "PHD" GUI:#include <GUIConstantsEx.au3> #include <Array.au3> $hGUI = GUICreate("PHD", 500, 500) GUISetState() Func StoreCoordinate() WinActivate("PHD") WinWaitActive("PHD") While 1 If GUIGetMsg() = $GUI_EVENT_PRIMARYDOWN Then $Stella = MouseGetPos() ConsoleWrite($Stella[0] & " " & $Stella[1] & @CRLF) Return $Stella EndIf WEnd EndFunc AutoItSetOption("WinTitleMatchMode",2) AutoItSetOption ( "MouseCoordMode" , 0) $Stella=StoreCoordinate() _ArrayDisplay($Stella)The Array stuff is just there to doublecheck the return - you can delete it later. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nmontec Posted January 23, 2010 Author Share Posted January 23, 2010 (edited) You do realise that you can only click within the "PHD" window? Yes, this is the intended purpose of this piece of code. It does not work anywhere within the PHD window or outside of it. Edit: I just tried to print out the GUIGetMsg() and it always returns 0. I guess this means that it never gets for any reason any event...this is weird. It's my first time to get events, but the code to me seems treally simple that I don't know where I could have mistaken. Func StoreCoordinate() WinActivate("PHD") WinWaitActive("PHD") While 1 $msg=GUIGetMsg() ConsoleWrite($msg & @CRLF) If $msg = $GUI_EVENT_PRIMARYDOWN Then $Stella = MouseGetPos() ConsoleWrite($Stella[0] & " " & $Stella[1] & @CRLF) Return $Stella EndIf WEnd EndFunc Edited January 23, 2010 by nmontec Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 23, 2010 Moderators Share Posted January 23, 2010 nmontec,Are you telling me that the code I posted above does not run when pasted on its own into SciTE? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nmontec Posted January 23, 2010 Author Share Posted January 23, 2010 (edited) nmontec,Are you telling me that the code I posted above does not run when pasted on its own into SciTE? M23yes it does work, but what's the difference between my application "PHD" and your window "PHD"?I don't understand...PS: I tried also with other windows like firefox, same thing, I don't get the event. Edited January 23, 2010 by nmontec Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 23, 2010 Moderators Share Posted January 23, 2010 nmontec,On reflection, I believe the event is only fired when you are within your own GUI. So as soon as you activate another - which of course you do by clicking on it - you are immediately in another GUI and the event does not fire.So let use use _IsPressed to solve this. We can easily convert the coordinates fron absolute screen to the PHP client area by using the WinAPI call.Please try this code:expandcollapse popup#include <GUIConstantsEx.au3> #include <Misc.au3> #include <WinAPI.au3> $hGUI = GUICreate("PHP", 500, 500) GUISetState() Func StoreCoordinate() Local $tPoint = DllStructCreate("int X;int Y") $dll = DllOpen("user32.dll") While 1 If _Ispressed("01", $dll) = 1 Then $Stella = MouseGetPos() ConsoleWrite("Screen coords: " & $Stella[0] & " - " & $Stella[1] & @CRLF) ExitLoop EndIf WEnd DllClose($dll) WinActivate("PHP") WinWaitActive("PHP") $hWnd = WinGetHandle("PHP") DllStructSetData($tPoint, "X", $Stella[0]) DllStructSetData($tPoint, "Y", $Stella[1]) _WinAPI_ScreenToClient($hWnd, $tPoint) $Stella[0] = DllStructGetData($tPoint, "X") $Stella[1] = DllStructGetData($tPoint, "Y") ConsoleWrite("PHP coords: " & $Stella[0] & " - " & $Stella[1] & @CRLF) Return $Stella EndFunc AutoItSetOption("WinTitleMatchMode",2) ;AutoItSetOption ( "MouseCoordMode" , 0) $Stella=StoreCoordinate()Now you should see 2 rows of info in the SciTE console. The first line is the absolute screen coords, the second the coords relative to the client area of the PHP window.Does this work for you? And, more importantly, does it work when you use your own "PHP" window?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nmontec Posted January 23, 2010 Author Share Posted January 23, 2010 Does this work for you? And, more importantly, does it work when you use your own "PHP" windowYes, it does work and it works with my window!Now, this is nice, but I don't understand how you reached this, I never use the WinAPI so I don't know how to use it. Can you point me out to some documentation regarding this API? I'm also relatively new to Windows... Link to comment Share on other sites More sharing options...
Mat Posted January 23, 2010 Share Posted January 23, 2010 MSDN = MicroSoft Developers Network. Its the developers guide to life the universe and just about everything. ScreenToClient is found here: http://msdn.microsoft.com/en-us/library/ms932582.aspx Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 24, 2010 Moderators Share Posted January 24, 2010 nmontec,Mat is quite correct in pointing you towards the MSDN - this is the "bible" which tells you in great detail (practically!?!) everything you could ever want to know about the Windows API.However, as a mere hobbyist coder, I can get very easily lost in there and as a beginner you would need more breadcrumbs that Hansel and Gretel to get out again! What I recommend is a look through the WInAPI section of the Help file - you find it under the bottom item in the menu <User Defined Functions reference - WInAPI Management>. There are lots of interesting functions there which are easy to use in AutoIt and which can help solve some tricky problems - like this one!I often bemoan the fact that the Help file appears to be ignored by many AutoIt users - wait until they try some other languages and they will realise how lucky we are to have such a resource. A little time spent perusing the Help file will repay itself a thousand times over when a little light goes on - "Ah, I remember reading something about that.....! ".So, I would recommend leaving MSDN alone at the moment - stick with the AutoIt specific commands in the Help file until you are a bit more comfortable with teh API. And of course you know where we are if you need a bit of advice. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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