IIIRAZORIII Posted April 13, 2013 Share Posted April 13, 2013 Hi there i'm trying to get a simple example of... if mouse click is longer than 200ms, then do this xxx So far this is what i have, but when 1 is pressed is basically does an extra click. so i'm thinking is.. if its only a mouse click ignore Send("1") and if mouse is held >=200ms then Send("1") i'm not looking for hand outs, just an example of something similar will be fine. so far i'm unsure exactly what function is needed, and have been unable to find something similar in help/google. thanx in advance #include <Misc.au3> While 1 If _IsPressed(01) Then Sleep(200) Send("1") EndIf Sleep(5) WEnd Link to comment Share on other sites More sharing options...
Celtic88 Posted April 13, 2013 Share Posted April 13, 2013 try with TimerInit() Link to comment Share on other sites More sharing options...
water Posted April 13, 2013 Share Posted April 13, 2013 After _IsPressed("01") = True you need to wait until _IsPressed("01") = False. That's according to the help file. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
IIIRAZORIII Posted April 13, 2013 Author Share Posted April 13, 2013 yes but i'm needing some kindof delay before it checks _ispressed. for example if i do normal left click, then nothing should happen. but if i hold left click down then script would run. TimerInit() shows promise, just researching now for working example for something i can make heads or tails off rofl Link to comment Share on other sites More sharing options...
KaFu Posted April 13, 2013 Share Posted April 13, 2013 I set the timer to 1000 to better demonstrate what's happening... #include <Misc.au3> Global $hDLL_User32 = DllOpen("user32.dll") Global $iTimer_IsPressed_Mouse, $b_IsPressed_Mouse = False, $iTimer_IsPressed_Mouse_Delay = 1000 While 1 If _IsPressed("01", $hDLL_User32) Then If Not $b_IsPressed_Mouse Then If Not $iTimer_IsPressed_Mouse Then $iTimer_IsPressed_Mouse = TimerInit() + 10 If $iTimer_IsPressed_Mouse And TimerDiff($iTimer_IsPressed_Mouse) > $iTimer_IsPressed_Mouse_Delay Then $b_IsPressed_Mouse = True ConsoleWrite("Mouse pressed" & @CRLF) Send("1") EndIf EndIf Else $b_IsPressed_Mouse = False $iTimer_IsPressed_Mouse = 0 EndIf If _IsPressed("1B", $hDLL_User32) Then ExitLoop Sleep(10) WEnd DllClose($hDLL_User32) IIIRAZORIII 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
IIIRAZORIII Posted April 13, 2013 Author Share Posted April 13, 2013 I set the timer to 1000 to better demonstrate what's happening... #include <Misc.au3> Global $hDLL_User32 = DllOpen("user32.dll") Global $iTimer_IsPressed_Mouse, $b_IsPressed_Mouse = False, $iTimer_IsPressed_Mouse_Delay = 1000 While 1 If _IsPressed("01", $hDLL_User32) Then If Not $b_IsPressed_Mouse Then If Not $iTimer_IsPressed_Mouse Then $iTimer_IsPressed_Mouse = TimerInit() + 10 If $iTimer_IsPressed_Mouse And TimerDiff($iTimer_IsPressed_Mouse) > $iTimer_IsPressed_Mouse_Delay Then $b_IsPressed_Mouse = True ConsoleWrite("Mouse pressed" & @CRLF) Send("1") EndIf EndIf Else $b_IsPressed_Mouse = False $iTimer_IsPressed_Mouse = 0 EndIf If _IsPressed("1B", $hDLL_User32) Then ExitLoop Sleep(10) WEnd DllClose($hDLL_User32) this is very close, although i don't rly understand it rofl. only problem is i need to reclick to repeat the loop. basically while key is held down it should loop Sleep(200) Send("1") and when mouse is clicked the loop should be ignored. thank you for that reply, trying to make sense of it now : ) way beyound me at this stage rofl Link to comment Share on other sites More sharing options...
KaFu Posted April 13, 2013 Share Posted April 13, 2013 (edited) #include <Misc.au3> Global $hDLL_User32 = DllOpen("user32.dll") Global $iTimer_IsPressed_Mouse, $iTimer_IsPressed_Mouse_Delay = 200 While 1 If _IsPressed("01", $hDLL_User32) Then If Not $iTimer_IsPressed_Mouse Then $iTimer_IsPressed_Mouse = TimerInit() + 10 If $iTimer_IsPressed_Mouse And TimerDiff($iTimer_IsPressed_Mouse) > $iTimer_IsPressed_Mouse_Delay Then ConsoleWrite("Mouse pressed" & @CRLF) Send("1") $iTimer_IsPressed_Mouse = 0 EndIf EndIf If _IsPressed("1B", $hDLL_User32) Then ExitLoop Sleep(10) WEnd DllClose($hDLL_User32) Edited April 13, 2013 by KaFu IIIRAZORIII 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
IIIRAZORIII Posted April 13, 2013 Author Share Posted April 13, 2013 mate thats working perfect, thank you very much. if its not to much hassle could you tell me in simple man terms what everything is doing. sorry i know i'm a pain, just trying to understand/learn. still very new to this. If not, i thank you again and understand completly that i've already took up much of your time Link to comment Share on other sites More sharing options...
KaFu Posted April 13, 2013 Share Posted April 13, 2013 No problem , I love these little brain teasers, here's a commented version. #include <Misc.au3> Global $hDLL_User32 = DllOpen("user32.dll") ; open DLL only once, makes calls faster Global $iTimer_IsPressed_Mouse, $iTimer_IsPressed_Mouse_Delay = 200 ; initialize global variables While 1 If _IsPressed("01", $hDLL_User32) Then ; if mouse is pressed If Not $iTimer_IsPressed_Mouse Then $iTimer_IsPressed_Mouse = TimerInit() + 10 ; if timer is not initialized, then initialize (current timestamp) + 10 (max delay lost due to last sleep(10)) If $iTimer_IsPressed_Mouse And TimerDiff($iTimer_IsPressed_Mouse) > $iTimer_IsPressed_Mouse_Delay Then ; if timer is initialized and difference is > 200 (global var) then ConsoleWrite("Mouse pressed" & @CRLF) Send("1") $iTimer_IsPressed_Mouse = 0 ; un-initialize timer EndIf EndIf If _IsPressed("1B", $hDLL_User32) Then ExitLoop ; exit on ESC Sleep(10) WEnd DllClose($hDLL_User32) IIIRAZORIII 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
IIIRAZORIII Posted April 13, 2013 Author Share Posted April 13, 2013 thank you again, although working, i have noticed something that might provide a little brain teasing for ya : ) single click still plays through the script on first click. dersired functions should be as follows. (again if to much hassle just ignore me : ) single mouse = single mouse click action (Function like standard mouse click without script) mouse click held over 200ms = run script. continued hold of mouse click will loop the script. Link to comment Share on other sites More sharing options...
KaFu Posted April 13, 2013 Share Posted April 13, 2013 Of course the timer needs to be un-initialized too if mouse is not clicked, had that in the first example but accidentally removed that too ... #include <Misc.au3> Global $hDLL_User32 = DllOpen("user32.dll") ; open DLL only once, makes calls faster Global $iTimer_IsPressed_Mouse, $iTimer_IsPressed_Mouse_Delay = 200 ; initialize global variables While 1 If _IsPressed("01", $hDLL_User32) Then ; if mouse is pressed If Not $iTimer_IsPressed_Mouse Then $iTimer_IsPressed_Mouse = TimerInit() + 10 ; if timer is not initialized, then initialize (current timestamp) + 10 (max delay lost due to last sleep(10)) If $iTimer_IsPressed_Mouse And TimerDiff($iTimer_IsPressed_Mouse) > $iTimer_IsPressed_Mouse_Delay Then ; if timer is initialized and difference is > 200 (global var) then ConsoleWrite("Mouse pressed" & @CRLF) Send("1") $iTimer_IsPressed_Mouse = 0 ; un-initialize timer EndIf Else $iTimer_IsPressed_Mouse = 0 ; un-initialize timer EndIf If _IsPressed("1B", $hDLL_User32) Then ExitLoop ; exit on ESC Sleep(10) WEnd DllClose($hDLL_User32) IIIRAZORIII 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
IIIRAZORIII Posted April 13, 2013 Author Share Posted April 13, 2013 working as intended, again thank you. had been scratching my head on this for last 12 hours, and got nowhere rofl. expandcollapse popup#include <Misc.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("!{PAUSE}", "Terminate") Global $hDLL_User32 = DllOpen("user32.dll") Global $iTimer_IsPressed_Mouse, $iTimer_IsPressed_Mouse_Delay = 200 Global $hDLL_User32 = DllOpen("user32.dll") ; open DLL only once, makes calls faster Global $iTimer_IsPressed_Mouse, $iTimer_IsPressed_Mouse_Delay = 200 ; initialize global variables While 1 If _IsPressed("01", $hDLL_User32) Then ; if mouse is pressed If Not $iTimer_IsPressed_Mouse Then $iTimer_IsPressed_Mouse = TimerInit() + 10 ; if timer is not initialized, then initialize (current timestamp) + 10 (max delay lost due to last sleep(10)) If $iTimer_IsPressed_Mouse And TimerDiff($iTimer_IsPressed_Mouse) > $iTimer_IsPressed_Mouse_Delay Then ; if timer is initialized and difference is > 200 (global var) then ConsoleWrite("Mouse pressed" & @CRLF) Send("1") $iTimer_IsPressed_Mouse = 0 ; un-initialize timer EndIf Else $iTimer_IsPressed_Mouse = 0 ; un-initialize timer EndIf Sleep(10) WEnd DllClose($hDLL_User32) Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is Paused', 1047, 0, " Warning", 0, 4) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
KaFu Posted April 13, 2013 Share Posted April 13, 2013 You're welcome , that's what the forum is for. IIIRAZORIII 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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