TrickyDeath Posted September 26, 2015 Share Posted September 26, 2015 Hello everyone, I am messing with a Do loop, and i wana know, how can i set it to finish the loop, when i release Mosue button. (Was started with mouse button press)Used _IsPressed to startAny idea how to tell it to the program something like this:Do ToolTip("Still pressing", 0, 0) Sleep(100) Until ; Here i need to make it stop, when i release the mouse button Tricky Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 26, 2015 Moderators Share Posted September 26, 2015 Trickydeath,_IsPressed.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...
TrickyDeath Posted September 26, 2015 Author Share Posted September 26, 2015 (edited) I tried that one as well, but i bet i made mistake. _IsPressed is not for pressing the button only?I see now, i am so lame....Until _IsPressed("01", $hDLL) = False Thank You, Edited September 26, 2015 by TrickyDeath Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
TLM Posted September 26, 2015 Share Posted September 26, 2015 (edited) How this:#include <Misc.au3> While 1 If _IsPressed(1) Then ;Check press of left mouse While _IsPressed(1); while is working when hold leftmouse ToolTip("LeftMouse Down") WEnd ToolTip("LeftMouse UP") EndIf sleep(10) WEnd Edited September 26, 2015 by TLM soluve wrong Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 26, 2015 Moderators Share Posted September 26, 2015 TLM,I would strongly suggest a Sleep(10) inside that very tight loop to save the CPU.And when you post code please use Code tags - see here how to do it. Then you get syntax colouring as you can see above now I have added the tags.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...
TrickyDeath Posted September 26, 2015 Author Share Posted September 26, 2015 (edited) How this:#include <Misc.au3> While 1 If _IsPressed(1) Then ;Check press of left mouse While _IsPressed(1); while is working when hold leftmouse ToolTip("LeftMouse Down") WEnd ToolTip("LeftMouse UP") EndIf sleep(10) WEndWell i did different, and about your code, it run the second while loop for 1 "ms" cause the button is pressed (argument succesful), the tooltip is displaied "ToolTip("LeftMouse Down")" and instatnly the second tooltip pop up.Ok, i checked your code and also work, my bad sry. Will test that way as well.For my logic, Do loop was better idea, since i have to hold down the button for a while and the code have to run over and over till the mouse button is down. When i release it, it have to stop. So M23 helped me out, cause seams like i was too tired and did not think i can put "= False" (_IsPressed("01", $hDLL) = False). Funy part is with different way i did try like that, but not with _IsPressed... With _IsPressed i had to notice if i press AltGR and the sleep is too long, it pressing multiple button cause it is groupped button. Still did not identify few button, and unfortunately, not working that function with my media buttons on my keyboard, but still cool stuff. Edited September 26, 2015 by TrickyDeath Tested TLM's code Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei) Link to comment Share on other sites More sharing options...
TLM Posted September 27, 2015 Share Posted September 27, 2015 Well i did different, and about your code, it run the second while loop for 1 "ms" cause the button is pressed (argument succesful), the tooltip is displaied "ToolTip("LeftMouse Down")" and instatnly the second tooltip pop up.Ok, i checked your code and also work, my bad sry. Will test that way as well.For my logic, Do loop was better idea, since i have to hold down the button for a while and the code have to run over and over till the mouse button is down. When i release it, it have to stop. So M23 helped me out, cause seams like i was too tired and did not think i can put "= False" (_IsPressed("01", $hDLL) = False). Funy part is with different way i did try like that, but not with _IsPressed... With _IsPressed i had to notice if i press AltGR and the sleep is too long, it pressing multiple button cause it is groupped button. Still did not identify few button, and unfortunately, not working that function with my media buttons on my keyboard, but still cool stuff.Ok use this it is better than allexpandcollapse popup#include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <Misc.au3> ; Create GUI Global $GUI = GUICreate('Test', 1, 1) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x02) ; Mouse DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $GUI) _WinAPI_RegisterRawInputDevices($tRID) GUIRegisterMsg($WM_INPUT, 'WM_INPUT') GUISetState(@SW_HIDE) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $GUI Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then Local $iFlags = DllStructGetData($tRIM, 'Flags') Select Case BitAND($iFlags, $MOUSE_ATTRIBUTES_CHANGED) ; You need to query the mouse attributes and update bitmap... Case Else EndSelect $iFlags = DllStructGetData($tRIM, 'ButtonFlags') If BitAND($iFlags, BitOR($RI_MOUSE_MIDDLE_BUTTON_DOWN, $RI_MOUSE_MIDDLE_BUTTON_UP, $RI_MOUSE_LEFT_BUTTON_DOWN, $RI_MOUSE_LEFT_BUTTON_UP, $RI_MOUSE_RIGHT_BUTTON_DOWN, $RI_MOUSE_RIGHT_BUTTON_UP)) Then Select Case BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_DOWN) If Not _CheckOtheBtnPress(1) Then ToolTip("Mouse Left btn down") EndIf Case BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_UP) If Not _CheckOtheBtnPress(1) Then ToolTip("Mouse Left btn up") EndIf Case BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_DOWN) If Not _CheckOtheBtnPress(2) Then ToolTip("Mouse Right btn down") EndIf Case BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_UP) If Not _CheckOtheBtnPress(2) Then ToolTip("Mouse Right btn up") EndIf EndSelect EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT Func _CheckOtheBtnPress($keytoIGNORE) For $C = 1 To 222 Step 1 If $C = $keytoIGNORE Then ContinueLoop If _IsPressed(Hex($C, 2)) Then Return 1 Next Return 0 EndFunc 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