CzarnyKhaki Posted October 31, 2019 Share Posted October 31, 2019 Hi I used to be good in Autoit in old times but now I forgot everything and can't handle this. I want to create script for my work, which will start different mousemoves + clicks depending on which key was pressed from F5 to F10. I know it is possible because I wrote many scripts like that in past. Why is this not even running and is closed immediately after msgbox? Please help. HotKeySet("{ESC}" , "close") HotKeySet("{F2}" , "pause") HotKeySet("{F5}" , "Fax") MsgBox (64, "Autokonsultant", "ESC = Zamknięcie. F2 = pauza. F5 = Fax.") Func close() Exit EndFunc Func pause() If $click = False Then $click = True ToolTip("Autokonsultant chodzi" , 0 , 0) Else $click = False ToolTip("Autokonsultant zapauzowany" , 0 , 0) EndIf EndFunc Func Fax() MouseMove ( 25, 76 ) EndFunc Link to comment Share on other sites More sharing options...
water Posted October 31, 2019 Share Posted October 31, 2019 Because you need to add statements telling the script to wait until one of the hotkeys was pressed. Usually this is a While loop - insert after MsgBox: While 1 Sleep(100) WEnd CzarnyKhaki 1 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...
CzarnyKhaki Posted October 31, 2019 Author Share Posted October 31, 2019 where should I add it? Link to comment Share on other sites More sharing options...
CzarnyKhaki Posted October 31, 2019 Author Share Posted October 31, 2019 Sorry, I can't edit the post above... ;/ My pause element gives me an error. What's wrong with my pause? Quote HotKeySet("{ESC}" , "close") HotKeySet("{F2}" , "pause") HotKeySet("{F5}" , "Fax") MsgBox (64, "Autokonsultant", "ESC = Zamknięcie. F2 = pauza. F5 = Fax.") While 1 Sleep(100) WEnd Func close() Exit EndFunc Func pause() If $click = False Then $click = True ToolTip("Autokonsultant chodzi" , 0 , 0) Else $click = False ToolTip("Autokonsultant zapauzowany" , 0 , 0) EndIf EndFunc Func Fax() MouseMove ( 25, 76 ) EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted October 31, 2019 Share Posted October 31, 2019 You haven't declared the $click variable anywhere in your script. Suggest that you review the Variables entry in the help file. CzarnyKhaki 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
water Posted October 31, 2019 Share Posted October 31, 2019 „Gives me an error“ Which error? 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...
Musashi Posted October 31, 2019 Share Posted October 31, 2019 38 minutes ago, CzarnyKhaki said: What's wrong with my pause? HotKeySet("{ESC}", "close") HotKeySet("{F2}", "pause") HotKeySet("{F5}", "Fax") Global $g_bClick = True MsgBox(64, "Autokonsultant", "ESC = Zamkniecie. F2 = pauza. F5 = Fax.") While 1 Sleep(100) WEnd Func close() Exit EndFunc ;==>close Func pause() If $g_bClick = False Then $g_bClick = True ToolTip("Autokonsultant chodzi", 0, 0) ConsoleWrite("Autokonsultant chodzi -> Running..." & @CRLF) Else $g_bClick = False ToolTip("Autokonsultant zapauzowany", 0, 0) ConsoleWrite("Autokonsultant zapauzowany -> Paused..." & @CRLF) EndIf EndFunc ;==>pause Func Fax() MouseMove (25, 76 ) ConsoleWrite('Fax() -> MouseMove (25, 76 )' & @CRLF) EndFunc ;==>Fax Next time provide the error message ! CzarnyKhaki 1 "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...
Nine Posted October 31, 2019 Share Posted October 31, 2019 (edited) Well, the pause func should stay in the function when Pause is True. Now the function is simply a toggle of a variable and a display of messages... Edit : Give meaningful name to variables is a good idea ! Edited October 31, 2019 by Nine CzarnyKhaki 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...
CzarnyKhaki Posted October 31, 2019 Author Share Posted October 31, 2019 The error is: in Line 17 If $click = False Then If ^ ERROR Error: Variable used without being declared Can somebody show me how pause after clicking F2 should look like? I copied this element from another script and looks like it's bad here. Link to comment Share on other sites More sharing options...
Musashi Posted October 31, 2019 Share Posted October 31, 2019 3 hours ago, CzarnyKhaki said: Error: Variable used without being declared This has already been answered ; 5 hours ago, Danp2 said: You haven't declared the $click variable anywhere in your script. Please run the following script (Proszę przetestować następujący skrypt) : HotKeySet("{ESC}", "_Exit") HotKeySet("{F2}", "_TogglePause") HotKeySet("{F5}", "_Fax") Global $g_bPaused = False MsgBox(64, "Autokonsultant", "ESC = Zamkniecie. F2 = pauza. F5 = Fax.") While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(100) ToolTip("Autokonsultant zapauzowany -> Script Paused... ", 0, 0) WEnd ToolTip("") EndFunc ;==>_TogglePause Func _Fax() MouseMove (25, 76 ) ConsoleWrite('Fax() -> MouseMove (25, 76 )' & @CRLF) EndFunc ;==>_Fax "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...
CzarnyKhaki Posted November 4, 2019 Author Share Posted November 4, 2019 (edited) Great thanks for help. That worked. Can you help me with next problem? I'd wish to continue this thread. Can coordinates of mousemove or sent text be a bit random? I'd like to replace the MouseClickDrag ( "left", 462, 465, 409, 461, 2) ; (2 is speed) Send("17:55")" in the _Przelozenie function to choose random hour from 17:01 to 19:56 instead always 17:55 or to replace it with mouse move randomly from x=484 to x=533 with stable y=508, something like MouseMove (randomXfrom484to533, 508) MouseClick ("left") The full code is: expandcollapse popupHotKeySet("{ESC}", "_Exit") HotKeySet("{F1}", "_Przygotowanie") HotKeySet("{F2}", "_Fax") HotKeySet("{F3}", "_Pomylka") HotKeySet("{F4}", "_Odmowa") HotKeySet("{F5}", "_Niepracuje") HotKeySet("{F6}", "_Przelozenie") HotKeySet("{F12}", "_TogglePause") Global $g_bPaused = False MsgBox(64, "AUTOKONSULTANT ARTERIA", "Najpierw się zaloguj i wybierz kampanię. Następnie wciśnij F1. Funkcje do zapamiętania (klawisze na klawiaturze): ESC = Zamknięcie. F1 = Przygotowanie. F2 = Fax. F3 = Pomyłka. F4 = Odmowa rozmowy. F5 = Nie ma stałego źródła dochodu. F6 = Przełożenie rozmowy na 17:55. F12 = Pauza Autokonsultanta Arteria.") While 1 Sleep(4) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _Przygotowanie() ToolTip("TRWA PRZYGOTOWANIE PROGRAMU", 0, 0) MouseClickDrag ( "left", 241, 240, 49, 15, 5) ; (5 is speed) MouseClickDrag ( "left", 896, 531, 747, 980, 4) ; (4 is speed) MouseClickDrag ( "left", 739, 972, 745, 979, 2) ; (2 is speed) MouseMove (627, 44) ConsoleWrite('Fax() -> MouseMove (627, 44)' & @CRLF) MouseClick ("left") MouseMove (634, 570) MouseClick ("left") ToolTip("GOTOWE!", 658, 578) Sleep(1400) ToolTip("", 750, 990) EndFunc ;==>_Przygotowanie Func _TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(4) ToolTip("AUTOKONSULTANT ARTERIA ZAPAUZOWANY. WCINIŚNIJ F2 ABY ODPAUZOWAĆ", 0, 0) WEnd ToolTip("", 0, 0) EndFunc ;==>_TogglePause Func _Fax() ToolTip("FAX", 0, 0) MouseMove (25, 76) MouseClick ("left") MouseMove (179, 477) MouseClick ("left") MouseMove (229, 812) MouseClick ("left") ToolTip("", 750, 990) EndFunc ;==>_Fax Func _Pomylka() ToolTip("POMYŁKA", 0, 0) MouseMove (25, 76) MouseClick ("left") MouseMove (180, 611) MouseClick ("left") MouseMove (229, 812) MouseClick ("left") ToolTip("", 750, 990) EndFunc ;==>_Pomylka Func _Odmowa() ToolTip("ODMOWA ROZMOWY", 0, 0) MouseMove (25, 76) MouseClick ("left") MouseMove (179, 708) MouseClick ("left") MouseMove (226, 811) MouseClick ("left") ToolTip("", 750, 990) EndFunc ;==>_Odmowa Func _Niepracuje() ToolTip("NIE MA STAŁEGO ŹRÓDŁA DOCHODU", 0, 0) MouseMove (168, 494) MouseClick ("left") MouseMove (241, 600) MouseClick ("left") MouseMove (175, 564) MouseClick ("left") MouseMove (215, 674) MouseClick ("left") MouseMove (177, 647) MouseClick ("left") MouseMove (243, 728) MouseClick ("left") MouseMove (175, 673) MouseClick ("left") MouseMove (240, 725) MouseClick ("left") MouseMove (198, 574) MouseClick ("left") MouseMove (265, 923) MouseClick ("left") MouseMove (197, 467) MouseClick ("left") MouseMove (223, 520) MouseClick ("left") MouseMove (173, 493) MouseClick ("left") MouseMove (206, 550) MouseClick ("left") ToolTip("", 750, 990) EndFunc ;==>_Niepracuje Func _Przelozenie() ToolTip("PRZEŁOŻENIE ROZMOWY NA 17:55", 0, 0) MouseMove (98, 76) MouseClick ("left") MouseMove (296, 506) MouseClick ("left") MouseMove (226, 811) MouseClick ("left") MouseClickDrag ( "left", 462, 465, 409, 461, 2) ; (2 is speed) Send("17:55") MouseMove (590, 871) MouseClick ("left") MouseMove (167, 809) MouseClick ("left") MouseMove (245, 867) MouseClick ("left") ToolTip("", 750, 990) EndFunc ;==>_Przelozenie Edited November 4, 2019 by CzarnyKhaki duplicate Link to comment Share on other sites More sharing options...
Musashi Posted November 4, 2019 Share Posted November 4, 2019 (edited) ; mouse move randomly from x=484 to x=533 with stable y=508 Local $iRandomX ; $iRandomXfrom484to533 is not a good name for a variable :-) $iRandomX = Random(484, 533, 1) ; choose random hour from 17:00 to 19:59 instead always 17:55 Local $sRandomTime $sRandomTime = StringFormat("%02i:%02i", Random(17, 19, 1) , Random(0, 59, 1)) EDIT : You should use english terms for function- and variable names. This makes it easier for other users to understand them . Edited November 4, 2019 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...
CzarnyKhaki Posted November 4, 2019 Author Share Posted November 4, 2019 Is it possible that the program read the date in format 2019-11-29 written as editeable text and add +1 day to it anyhow, when sending text replacing it? I mean to edit the text after using function MouseClickDrag ( "left", 344, 465, 236, 462, 2) ; (2 is speed) Link to comment Share on other sites More sharing options...
Nine Posted November 4, 2019 Share Posted November 4, 2019 11 minutes ago, CzarnyKhaki said: Is it possible that the program read the date in format 2019-11-29 written as editeable text and add +1 day to it Yes, but "how" will depends of the type of edit box you got, and what application underlies it. Try first using Au3Info.exe tool to see if the control can be identified... “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...
CzarnyKhaki Posted November 4, 2019 Author Share Posted November 4, 2019 I tried Control, HiddenText and VisibleText and other tabs and none showed anything else when I clicked on it. Link to comment Share on other sites More sharing options...
Nine Posted November 4, 2019 Share Posted November 4, 2019 Have you unfreeze the tool ? If so, show the application screen and Au3Info window. “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...
CzarnyKhaki Posted November 4, 2019 Author Share Posted November 4, 2019 I have unfrozen now and still the same. Link to comment Share on other sites More sharing options...
Bert Posted November 4, 2019 Share Posted November 4, 2019 In reading your script, you would be MUCH better off simply by hooking into the control. That way you don't need to worry about your mouse click being misplaced or worse, the wrong window is active and nothing works. Are you trying to automate Salesforce? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted November 4, 2019 Share Posted November 4, 2019 Take a look at ControlClick. CzarnyKhaki 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
CzarnyKhaki Posted November 4, 2019 Author Share Posted November 4, 2019 (edited) I have given the screenshot where you can see it all. I have no idea. I'm working on the phone and want to easily choose status for clients because our application suxx Edited November 4, 2019 by CzarnyKhaki added info 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