Tech2491 Posted April 24, 2020 Share Posted April 24, 2020 This is the first time I haven't been able to find some code to piece together what I want to accomplish, I know this is super simple. Its for an legacy program that we use for a water plant, you have to left click several times to increase pressure. How would I code left mouse down, left mouse clicks while mouse is down, then stops when mouse is brought back up? Link to comment Share on other sites More sharing options...
Aelc Posted April 24, 2020 Share Posted April 24, 2020 (edited) sorry but in which legacy program you would have to click that often when it's not a game? also weird to start a mouseclick loop with a mouseclick no? Edited April 24, 2020 by Aelc why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Nine Posted April 24, 2020 Share Posted April 24, 2020 Not even sure it is possible to do it. At the moment, I cannot think of a simple way to perform such a task. Maybe someone else will bring a solution. But my first impression is that you would need to use a secondary key. For example, if you press Ctrl and left click, you could continue left clicking until the Ctrl key is released. TinyCoopMan 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Tech2491 Posted April 24, 2020 Author Share Posted April 24, 2020 Its a 30 year old program called "Pressure IT", was custom written for a water plant. Small town, no money, working with what they have. Operator has used this for 30 years and has arthritis now, I wanted to make something beyond simple. "Vern, now you just move the mouse pointer to the INC button hold the mouse button down, no more clicking it 50 times". A secondary key would be ok, or maybe even a toggle so its on then off? I do have a script with a toggle that works well. Link to comment Share on other sites More sharing options...
Nine Posted April 24, 2020 Share Posted April 24, 2020 (edited) 15 minutes ago, Tech2491 said: I do have a script with a toggle that works well. Post it using this tool. Maybe we can enhance it ? Tell Vern we are working on something Edit : I know nothing about Water Plant, but isn't that a bit dangerous to have to key toggle to increase pressure ? I mean, if you forget to put it off ? I think it is preferable to hold a key instead. Edited April 24, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted April 24, 2020 Share Posted April 24, 2020 (edited) 11 minutes ago, Nine said: Post it using this tool. Maybe we can enhance it ? Tell Vern we are working on something Could you please also provide a screenshot just to get an impression of the 'user interface' (blurr sensitive data). Quote I know nothing about Water Plant, but isn't that a bit dangerous to have to key toggle to increase pressure ? I mean, if you forget to put it off ? I think it is preferable to hold a key instead. @Nine : Funny, I was just thinking the same thing . Edited April 24, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Tech2491 Posted April 24, 2020 Author Share Posted April 24, 2020 ; Function to toggle the mouse button ; Hotkeys posted below in red, - on, = off Func ToggleMouse() ; Variable to indicate whether the mouse is already down Global $Down If $Down Then MouseClick('Left') Else MouseDown('Left') EndIf ; Swap the value of the variable to reflect the new state $Down = Not $Down EndFunc ; Function to end the script Func Off() Exit EndFunc ; Set the hotkeys up HotkeySet('-', 'ToggleMouse') HotkeySet('=', 'Off') ; Do nothing (keeps the script around to process the keys) While 1 Sleep(1000) WEnd I found this in my collection, I cant remember what I used it for, but was going to edit it. I found it on the forums at some point I'm sure, I know enough to find something and then edit to make it do what I need, until now. By toggle I meant, press F1 on your keyboard, now when you press the mouse button it repeats pushing the mouse button many times, you just hold it down and it continually clicks. To turn the toggle off, you press F2, now when you press the mouse button its just a single click. With this, I could also control how quickly the mouse button is pressed with a variable, to control how quickly the the button is pressed. The plant is 2 hours away, when I go back I can get a SS. Link to comment Share on other sites More sharing options...
Nine Posted April 24, 2020 Share Posted April 24, 2020 (edited) Here a bit different approach. As I said, I believe it is more reliable to use a key to hold and release : expandcollapse popup#include <Constants.au3> #include <Misc.au3> #include <GUIConstants.au3> #include <WinAPISys.au3> Opt ("GUIOnEventMode", 1) Local $hGUI = GUICreate ("Test") GUISetOnEvent ($GUI_EVENT_CLOSE, _Exit) Local $idButton = GUICtrlCreateButton ("Click", 100, 100, 100, 30) GUICtrlSetOnEvent (-1, _Click) GUISetState () Local $bStart = False, $aPos, $tRect While True While _IsPressed ("11") ; control key If _IsPressed ("01") And Not $bStart Then ; left mouse click $aPos = MouseGetPos () $tRect = _WinAPI_GetWindowRect (GUICtrlGetHandle ($idButton)) ; make sure it is the right contol to increase pressure ; don't know yet if it is possible to get its handle, but we will manage that later $bStart = $aPos[0] >= $tRect.left And $aPos[0] <= $tRect.right And $aPos[1] >= $tRect.top And $aPos[1] <= $tRect.bottom EndIf If $bStart Then ConsoleWrite ("click" & @CRLF) MouseClick ("left", $aPos[0], $aPos[1], 1, 1) ; make sure the click is always performed at the right coordinates EndIf Sleep (50) WEnd $bStart = False Sleep (100) WEnd Func _Exit () Exit EndFunc Func _Click () ConsoleWrite ("Button" & @CRLF) EndFunc The GUI is only there to ensure that the clicks are correctly performed... Edited April 24, 2020 by Nine corrected a small bug “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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