caramen Posted March 13, 2019 Share Posted March 13, 2019 (edited) Hello guys, Some of my téléphone operators. Are not working with mouse. It s faster for them to use only keyboard. I would like to do somthing for one of there team to be able to do a MouseDown ('Left') When they pressDown the key Q. I got a sample ready but i am not sure i am doing it the best way. ALso it is not reacting as wanted. I guess it s blocking somehow. #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") While (1) If _IsPressed("51", $hDLL) Then ;If _IsChecked Then While _IsPressed("51", $hDLL) Do MouseDown ("Left") Until Not _IsPressed("51", $hDLL) MouseUp ("Left") WEnd ;EndIf EndIf Sleep(5) WEnd To be the most clear as possible i want my key "Q" controling the left mouseclick exactly as if it s the left mouse button. -I want to be able to keep key pressed to be able to select some texte. Like with double click etc... BTW i added the DO loop for testing purpose and it 's pretty same with or without it. Edited March 13, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
BigDaddyO Posted March 13, 2019 Share Posted March 13, 2019 Maybe try a HotKeySet("q", "MouseClickNow") Link to comment Share on other sites More sharing options...
caramen Posted March 13, 2019 Author Share Posted March 13, 2019 Aww this is the point doing a click is much easy that press left click and hold until i release my key xD And unfortunatly this is what i want 😛 My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2019 Share Posted March 13, 2019 (edited) For one you will need to make it either a CTRL + Letter combo or maybe an un-used F - key otherwise youll be screwing up all kinds of documents 2. you are calling mouse down repeatedly #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $F7 = "76" While (1) If _IsPressed($F7, $hDLL) Then If _IsChecked() Then MouseDown("Left") Do Sleep(100) Until Not _IsPressed($F7, $hDLL) MouseUp("Left") EndIf EndIf Sleep(50) WEnd Func _IsChecked() Return True EndFunc ;==>_IsChecked With LCTRL + S #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $S_KEY = "53" Local Const $LCTRL = "A2" While (1) If _IsPressed($LCTRL, $hDLL) AND _IsPressed($S_KEY, $hDLL) Then If _IsChecked() Then MouseDown("Left") Do Sleep(100) Until Not (_IsPressed($LCTRL, $hDLL) AND _IsPressed($S_KEY, $hDLL)) MouseUp("Left") EndIf EndIf Sleep(50) WEnd Func _IsChecked() Return True EndFunc ;==>_IsChecked Edited March 13, 2019 by Bilgus caramen 1 Link to comment Share on other sites More sharing options...
Bilgus Posted March 13, 2019 Share Posted March 13, 2019 Also don't forget to close user32.dll when you are done with it... Link to comment Share on other sites More sharing options...
caramen Posted March 14, 2019 Author Share Posted March 14, 2019 (edited) @Bilgus First thanks for your help. and now. If i want to improve the tool. I am falling right into an new issue. The purpose goal is to to do a real click on the Q key. So to be confortable i want to made them able to use both thing together to let them choose what do they want to use and even both together... left click AND/OR Q. That mean If someone is selecting some text with Q he can directly click with left click on anythign while he is keeping Q holded. And i want to exit my Do loop after the mouse detection but i can get that work. It is really a simple goal tool but it s really more complicated than i expected before to do lol.... Look i did that so ... With that code : i have no msg box so i am not out from my Do i dont know why. #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $Q_KEY = "51" Local Const $LC = "01" While (1) If _IsPressed($Q_KEY, $hDLL) Then MouseDown("Left") Do Sleep(100) If _IsPressed($LC, $hDLL) Then Do Sleep(100) Until Not _IsPressed( $Q_KEY , $hDLL ) MouseDown("Left") EndIf Until Not _IsPressed($Q_KEY, $hDLL) MsgBox (0 , "" , "" ) MouseUp("Left") EndIf Sleep(50) WEnd And witht that code i have my message box so i understand what is happenning but i just cannot found a solution to make me exit my Do loop anyway... I tryed so much combinason of technique but i just cant figure out how to do. #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $Q_KEY = "51" Local Const $LC = "01" While (1) If _IsPressed($Q_KEY, $hDLL) Then MouseDown("Left") Do Sleep(100) ;~ If _IsPressed($LC, $hDLL) Then ;~ Do ;~ Sleep(100) ;~ Until Not _IsPressed( $Q_KEY , $hDLL ) ;~ MouseDown("Left") ;~ EndIf Until Not _IsPressed($Q_KEY, $hDLL) MsgBox (0 , "" , "" ) MouseUp("Left") EndIf Sleep(50) WEnd If the best world i would like to have the second code working as expected. The best way to try this code. Is to open a new paint document and try the script. You will notice first code is working like a charm. Second code isn't wrking. If i push Q Then i release Q it will keep the mouse down since we are not going out from the Do for unknow reason. It s like i cannot detect 2 action one after one. I have to first release one then detect an other or it doesn't work. I also tryed that : But i am not more able to drag any folder witht hat. #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $Q_KEY = "51" Local Const $LC = "01" While (1) If _IsPressed( $Q_KEY , $hDLL ) Or _IsPressed( $LC , $hDLL ) Then Sleep ( 200 ) MouseDown("Left") Do Sleep(100) ;~ If _IsPressed($LC, $hDLL) Then ;~ Do ;~ Sleep(100) ;~ Until Not _IsPressed( $Q_KEY , $hDLL ) ;~ MouseDown("Left") ;~ EndIf Until Not _IsPressed($Q_KEY, $hDLL) Or Not _IsPressed($LC, $hDLL) ;~ MsgBox (0 , "" , "" ) MouseUp("Left") EndIf Sleep(50) WEnd Edited March 14, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2019 Share Posted March 14, 2019 (edited) You have that MouseDown inside a loop again for every MouseDown you need a MouseUp If _IsPressed($Q_KEY, $hDLL) Then MouseDown("Left") ;MOUSEISDOWN Do Sleep(100) If _IsPressed($LC, $hDLL) Then Do Sleep(100) Until Not _IsPressed( $Q_KEY , $hDLL ) ;MOUSEISDOWN STILL MouseDown("Left") ;MOUSEISDOWN AGAIN EndIf Until Not _IsPressed($Q_KEY, $hDLL) MsgBox (0 , "" , "" ) MouseUp("Left") EndIf Don't put them in loops like that without a MouseUp First But the msgbox is in a bad place anyways it needs to be after that MouseUp By using 'Q' you are going to be typing QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ all over every window it either needs to be CTRL-Q or something like a F-Key otherwise you'll need a low level keyboard hook and its too much like a keylogger to be posted here Edited March 14, 2019 by Bilgus Read after coffee Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2019 Share Posted March 14, 2019 He can't click with 'Q' held because thats like trying to left click while the left mouse button is held down with adhesive tape Link to comment Share on other sites More sharing options...
caramen Posted March 14, 2019 Author Share Posted March 14, 2019 (edited) I know about the Q spam and it s not a problem in my case dont worry. The message box is just here to know if i go further after my Do....loop. And I am not. Do you think io have to use _WinAPI_SetWindowsHookEx ? I know we cannot discuss of that kind of code here but until we dont post code may you can advise me ? Edited March 14, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2019 Share Posted March 14, 2019 You leave it stuck in the loop lets separate it into two code paths #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $Q_KEY = "51" Local Const $LMOUSE = "01" While (1) If _IsPressed($LMOUSE, $hDLL) Or _IsPressed($Q_KEY, $hDLL) Then If Not _IsPressed($LMOUSE, $hDLL) Then MouseDown("Left") Do Sleep(100) Until Not (_IsPressed($LMOUSE, $hDLL) Or _IsPressed($Q_KEY, $hDLL)) MouseUp("Left") Else ;Mouse is down Do Sleep(100) If _IsPressed($Q_KEY, $hDLL) Then MouseUp("Left") Sleep(200) MouseDown("Left") Do Sleep(100) Until Not _IsPressed($Q_KEY, $hDLL) EndIf Until Not (_IsPressed($LMOUSE, $hDLL) Or _IsPressed($Q_KEY, $hDLL)) EndIf EndIf Sleep(50) WEnd caramen 1 Link to comment Share on other sites More sharing options...
caramen Posted March 14, 2019 Author Share Posted March 14, 2019 @Bilgus Try this code on paint and you will see what happen if you try to press Q down and then release Q. You will still keep painting. It does not release Q. So issue is same you cannot drag a folder in case you need it. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2019 Share Posted March 14, 2019 sorry I forgot to remove one of the commands #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local Const $Q_KEY = "51" Local Const $LMOUSE = "01" While (1) If _IsPressed($LMOUSE, $hDLL) Or _IsPressed($Q_KEY, $hDLL) Then If Not _IsPressed($LMOUSE, $hDLL) Then MouseDown("Left") Do Sleep(100) Until Not _IsPressed($Q_KEY, $hDLL) MouseUp("Left") Else ;Mouse is down Do Sleep(100) If _IsPressed($Q_KEY, $hDLL) Then MouseUp("Left") Sleep(200) MouseDown("Left") Do Sleep(100) Until Not _IsPressed($Q_KEY, $hDLL) EndIf Until Not (_IsPressed($LMOUSE, $hDLL) Or _IsPressed($Q_KEY, $hDLL)) EndIf EndIf Sleep(50) WEnd caramen 1 Link to comment Share on other sites More sharing options...
Bilgus Posted March 14, 2019 Share Posted March 14, 2019 If you don't care about the key typing everywhere then no need for a hook Link to comment Share on other sites More sharing options...
caramen Posted March 14, 2019 Author Share Posted March 14, 2019 Ok even if it s interesting to get it work with a hook ? Let me try your code. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
caramen Posted March 14, 2019 Author Share Posted March 14, 2019 (edited) Ok again a new issue. Look if you click while you're holding. You have to Press Q again to continu to paint. I want to paint when I release the left click without press Q again. hmmm But i 've not read your code may i can do that myself. Let me see. I am sorry it look like i am requesting your code for me but that's not the case. I just need logic help. Thanks a lot for your time involved. Edited March 14, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
caramen Posted March 14, 2019 Author Share Posted March 14, 2019 (edited) @Bilgus Look at this little code : Now i see that i am confused and i dont know how to even try more attemps. MouseDown ("Left");51 If _IsPressed( "51" , $hDLL ) Then MsgBox(0,"","MouseClick Detected!") EndIf If we do a MouseDown Event. It's like an _IsPressed "51". So this script is stuck. Becose i want to continu my painting if i drag something but if i drag somthing it's a mouseclick/. May one of you got sollution for that but it seem i'am trying to do somthing illogic. Edited March 14, 2019 by caramen Bilgus 1 My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki 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