Lokomass Posted December 17, 2019 Share Posted December 17, 2019 Hi, I've written a little "auto moving mouse" program. There is 2 buttons : start and quit. Start button execute auto move. And quit button kill script and exit (like cross click) But after launch start function, I can't exit the program, can you help me ? Do i made something wrong ? #include <Timers.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $Off = 0 $Sleep = 10 $Speed = 10 $Windows = GUICreate("Auto Mouse Mover", 300, 150) $Start = GUICtrlCreateButton("Start", 50, 50, 75, 50) $Quit = GUICtrlCreateButton("Quit", 175, 50, 75, 50) GUISetState(@SW_SHOW) $Size = WinGetClientSize("Program Manager") $Width = $Size[0] / 2 $Height = $Size[1] / 2 While 1 $Message = GUIGetMsg() Switch $Message Case $Start While 1 MouseMove($Width - 50, $Height - 50, $Speed) MouseMove($Width + 50, $Height - 50, $Speed) MouseMove($Width + 50, $Height + 50, $Speed) MouseMove($Width - 50, $Height + 50, $Speed) Sleep($Sleep * 1000) Wend Case $Quit Exit Case -3 Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Nine Posted December 17, 2019 Share Posted December 17, 2019 You cannot have 2 embedded loops with GUIs. Make a single ! Also make sure you read forum rules, especially the part about game automation.... “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...
Lokomass Posted December 17, 2019 Author Share Posted December 17, 2019 Thanks for your rpely, but I don't see how I can do with only one loop Link to comment Share on other sites More sharing options...
Nine Posted December 17, 2019 Share Posted December 17, 2019 I will help you if you confirm it is not for a game... “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...
Lokomass Posted December 17, 2019 Author Share Posted December 17, 2019 no, Not for a game ! it's for force my windows don't sleep if a can't move mouse during a few minutes Link to comment Share on other sites More sharing options...
Nine Posted December 17, 2019 Share Posted December 17, 2019 (edited) Alright, here : #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Local $bStarted = False, $Sleep = 10, $Speed = 10 Local $Windows = GUICreate("Auto Mouse Mover", 300, 150) Local $Start = GUICtrlCreateButton("Start", 50, 50, 75, 50) Local $Quit = GUICtrlCreateButton("Quit", 175, 50, 75, 50) GUISetState(@SW_SHOW) Local $Size = WinGetClientSize("Program Manager"), $Width = $Size[0] / 2, $Height = $Size[1] / 2 Local $hTime While True Switch GUIGetMsg() Case $Start $bStarted = True $hTime = TimerInit () Case $Quit, $GUI_EVENT_CLOSE Exit EndSwitch If $bStarted And TimerDiff ($hTime) > $Sleep * 1000 Then MouseMove($Width - 50, $Height - 50, $Speed) MouseMove($Width + 50, $Height - 50, $Speed) MouseMove($Width + 50, $Height + 50, $Speed) MouseMove($Width - 50, $Height + 50, $Speed) $hTime = TimerInit () EndIf WEnd Edited December 17, 2019 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...
Lokomass Posted December 17, 2019 Author Share Posted December 17, 2019 Thank you very much Link to comment Share on other sites More sharing options...
Lokomass Posted December 18, 2019 Author Share Posted December 18, 2019 Sometimes, I have this error : Link to comment Share on other sites More sharing options...
Nine Posted December 18, 2019 Share Posted December 18, 2019 Which version of autoit ? You are on VM ? Line 17 is when you press Start. Rewrite the line manually...Working fine for me. “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...
Lokomass Posted December 18, 2019 Author Share Posted December 18, 2019 I use last version of Autoit (I've juste update the version) I'm on Windows 10 (not a VM) I try to rewrite but same error. Link to comment Share on other sites More sharing options...
Nine Posted December 18, 2019 Share Posted December 18, 2019 Tested few times, no problem here. “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...
Earthshine Posted December 18, 2019 Share Posted December 18, 2019 I tested the code @Nine posted, copy that exact code and test it, what do you get? it's working for me My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Lokomass Posted December 18, 2019 Author Share Posted December 18, 2019 Yes, right click, new autoit v3 script, copy/paste and, this error Link to comment Share on other sites More sharing options...
Danp2 Posted December 18, 2019 Share Posted December 18, 2019 Probably a hidden character due to the forum's copy / paste bug. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Lokomass Posted December 18, 2019 Author Share Posted December 18, 2019 Ok re-write 2 lines and before it's ok, thanks for help Link to comment Share on other sites More sharing options...
Lokomass Posted December 26, 2019 Author Share Posted December 26, 2019 Hello, I've update the script, to add a combobox with multiple times (time to quit). I have an error on my countdown, if I choose for example 2 hours, this don't go under 1 hour, I don't understand what I have made wrong. Can you help me ? Thanks for reply expandcollapse popup#include <_AudioEndpointVolume.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ColorConstants.au3> #include <GuiConstantsEx.au3> #include <GuiComboBox.au3> #pragma compile(Icon, "Icone.ico") $Sleep = 10 $Speed = 10 Local $Time Local $Mute Local $Volume Local $Started = False Local $Style_1 = BitOr($WS_CAPTION, $WS_SYSMENU); Local $Window = GUICreate("Auto Mouse Mover", 180, 120, -1, -1, $Style_1) Local $Start = GUICtrlCreateButton("Start", 10, 40, 160, 30) Local $Quit = GUICtrlCreateButton("Quit", 10, 80, 160, 30) Local $Style_2 = BitOr($CBS_DROPDOWNLIST, $SS_CENTER, $SS_CENTERIMAGE) Local $Combo = GUICtrlCreateCombo("", 10, 10, 160, 20, $Style_2) GUICtrlSetData($Combo, "10 minutes|30 minutes|1 heure|2 heures|3 heures|4 heures") _GUICtrlComboBox_SetCurSel($Combo, 2) GUISetState(@SW_SHOW) $Position = WinGetPos("Auto Mouse Mover") While 1 $Message = GUIGetMsg() Switch $Message Case $Start $Volume = Int(_GetMasterVolumeLevelScalar()) $Mute = _GetMute() VolumeUp() $Started = True $Time = TimerInit() GUICtrlSetData($Start, "Running...") GUICtrlSetBkColor($Start, 0x90EE90) GUICtrlSetState($Start, $GUI_disable) $Value = GUICtrlRead($Combo) GUICtrlDelete($Combo) $Style_3 = BitOr($SS_CENTER, $SS_CENTERIMAGE) $Timer = TimerInit() $Duree = Temps($Value) $Label = GUICtrlCreateLabel(Timer($Timer, $Duree), 10, 10, 160, 20, $Style_3) Case $Quit, $GUI_EVENT_CLOSE If $Started Then VolumeDown($Volume, $Mute) EndIf Exit EndSwitch If $Started And TimerDiff($Timer) > 60 * 1000 Then $Secondes = Timer($Timer, $Duree) If ($Secondes == "0 minute") Then VolumeDown($Volume, $Mute) Exit EndIf GUICtrlSetData($Label, $Secondes) EndIf If $Started And TimerDiff($Time) > $Sleep * 1000 Then MouseMove($Position[0], $Position[1], $Speed) MouseMove($Position[0] + $Position[2], $Position[1], $Speed) MouseMove($Position[0] + $Position[2], $Position[1] + $Position[3], $Speed) MouseMove($Position[0], $Position[1] + $Position[3], $Speed) $Time = TimerInit() EndIf WEnd Func Temps($Value) $Nombre = StringSplit($Value, ' ') $Heure = StringInStr($Value, "heure") $Minute = StringInStr($Value, "minute") If ($Heure > 0) Then $Duree = $Nombre[1] * 3600 ElseIf ($Minute > 0) Then $Duree = $Nombre[1] * 60 EndIf Return $Duree EndFunc Func Timer($Timer, $Temps) Local $Progression = 0 Local $Time = 0 Local $Virgule = 0 $Timeout = TimerDiff($Timer) $Time = $Timeout / 1000 If ($Time < 10) Then $Virgule = StringLeft($Time, 1) ElseIf ($Time > 10 And $Time < 100) Then $Virgule = StringLeft($Time, 2) ElseIf ($Time > 100) Then $Virgule = StringLeft($Time, 3) EndIf $Secondes = $Temps - $Virgule Return _FormatElapsedTime($Secondes) EndFunc Func _FormatElapsedTime($Input_Seconds) If $Input_Seconds < 1 Then Return Global $ElapsedMessage = '' Global $Input = $Input_Seconds Switch $Input_Seconds Case 0 To 3599 GetMinutes() Case Else GetHours() GetMinutes() EndSwitch Return $ElapsedMessage EndFunc Func GetHours() $Hours = Int($Input / 3600) $Input -= ($Hours * 3600) If ($Hours > 1) Then $ElapsedMessage &= $Hours & ' heures' Else $ElapsedMessage &= $Hours & ' heure' EndIf Return $ElapsedMessage EndFunc Func GetMinutes() $Minutes = Int($Input / 60) $Input -= ($Minutes * 60) If ($ElapsedMessage <> "") Then $ElapsedMessage &= ', ' EndIf If ($Minutes > 1) Then $ElapsedMessage &= $Minutes & ' minutes' Else $ElapsedMessage &= $Minutes & ' minute' EndIf Return $ElapsedMessage EndFunc Func VolumeUp() _SetMute(0) _SetMasterVolumeLevelScalar(100) EndFunc Func VolumeDown($Volume, $Mute) Beep(500, 1000) _SetMute($Mute) _SetMasterVolumeLevelScalar($Volume) 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