monoscout999 Posted May 29, 2011 Share Posted May 29, 2011 (edited) Hi forum I was doing a example for a forum question and happend this... when i put the debug - consolewrite the program minimizes, when i comment out that line the script dont work how it should work :S its something strange to me, maybe i miss something... try it in this way, later un - comment the 19 line and see what happend (the consolewrite line) $gui = GUICreate("MouseClicks Until you hold the mousebutton?", 120, 80) $radio1 = GUICtrlCreateRadio("Left", 5, 5, 50, 20) $radio2 = GUICtrlCreateRadio("Right", 5, 30, 50, 20) Local $a = 2 GUISetState() While 1 $gui = GUIGetMsg() Switch $gui Case -3 Exit ;$GUI_EVENT_CLOSE Case $radio1 $a = 2 Case $radio2 $a = 3 EndSwitch $aMouse = GUIGetCursorInfo() If Not @error Then If $aMouse[$a] = 1 Then MouseClick("left") ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : MouseClick("left") = ' & MouseClick("left") & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console EndIf WEnd Edited May 29, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
MHz Posted May 29, 2011 Share Posted May 29, 2011 (edited) Not sure if I understand what you say the issue is. You do seem to have highlighted the MouseClick() and added it to a debug ConsoleWrite(). The MouseClick happens when the ConsoleWrite() executes so you would have a double left click happening. Edit: Replaced "debug Msgbox()" with "debug ConsoleWrite()" mistake. Edited May 29, 2011 by MHz Link to comment Share on other sites More sharing options...
monoscout999 Posted May 29, 2011 Author Share Posted May 29, 2011 (edited) with the msgbox is the same... Why the evaluation If $aMouse[$a] = 1 Then MouseClick("left") executes the mouseclick as soon i start the script? Why the windows minimize? Why the script dont work when the msgbox or the consolewrite are not pressent? EDIT $gui = GUICreate("MouseClicks Until you hold the mousebutton?", 120, 80) $radio1 = GUICtrlCreateRadio("Left", 5, 5, 50, 20) $radio2 = GUICtrlCreateRadio("Right", 5, 30, 50, 20) Local $a = 2 GUISetState() While 1 $gui = GUIGetMsg() Switch $gui Case -3 Exit ;$GUI_EVENT_CLOSE Case $radio1 $a = 2 Case $radio2 $a = 3 EndSwitch $aMouse = GUIGetCursorInfo() If Not @error Then If $aMouse[$a] = 1 Then MouseClick("left") consolewrite($aMouse[$a]&@CRLF) EndIf WEnd Run This... why the console dont return 1 when i hold down the left mousebutton(primary) but it work fine when i check the "Right" radio and use the right mousebutton? Edited May 29, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
MHz Posted May 29, 2011 Share Posted May 29, 2011 Ok, the ConsoleWrite() happens with each loop rapidly as GuiGetMsg() returns often. Your ConsoleWrite is better enclosed in a If structure so it only writes when the value is 1 and nothing else. This works better to my knowledge of concern. $gui = GUICreate("MouseClicks Until you hold the mousebutton?", 120, 80) $radio1 = GUICtrlCreateRadio("Left", 5, 5, 50, 20) $radio2 = GUICtrlCreateRadio("Right", 5, 30, 50, 20) Local $a = 2 GUISetState() While 1 $gui = GUIGetMsg() Switch $gui Case -3 Exit ;$GUI_EVENT_CLOSE Case $radio1 $a = 2 Case $radio2 $a = 3 EndSwitch $aMouse = GUIGetCursorInfo() If Not @error Then If $aMouse[$a] = 1 Then MouseClick("left") ConsoleWrite($aMouse[$a] & @CRLF) EndIf EndIf WEnd So, I just put the ConsoleWrite within the If...EndIf and only write when your mouse clicks and a radio button is checked. Link to comment Share on other sites More sharing options...
monoscout999 Posted May 29, 2011 Author Share Posted May 29, 2011 Ok, the ConsoleWrite() happens with each loop rapidly as GuiGetMsg() returns often. Your ConsoleWrite is better enclosed in a If structure so it only writes when the value is 1 and nothing else. This works better to my knowledge of concern. $gui = GUICreate("MouseClicks Until you hold the mousebutton?", 120, 80) $radio1 = GUICtrlCreateRadio("Left", 5, 5, 50, 20) $radio2 = GUICtrlCreateRadio("Right", 5, 30, 50, 20) Local $a = 2 GUISetState() While 1 $gui = GUIGetMsg() Switch $gui Case -3 Exit ;$GUI_EVENT_CLOSE Case $radio1 $a = 2 Case $radio2 $a = 3 EndSwitch $aMouse = GUIGetCursorInfo() If Not @error Then If $aMouse[$a] = 1 Then MouseClick("left") ConsoleWrite($aMouse[$a] & @CRLF) EndIf EndIf WEnd So, I just put the ConsoleWrite within the If...EndIf and only write when your mouse clicks and a radio button is checked. you are right i miss that... i think the "why the console dont return 1 when i hold down the left mousebutton(primary) but it work fine when i check the "Right" radio and use the right mousebutton?" question answer is that the aMouse[2] value changes when the mouseclick function send a click(press - release) 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