cmb99 Posted February 13, 2005 Posted February 13, 2005 (edited) Why does this script never repsond to mouse clicks (either, buttons or closing): expandcollapse popup#include <GUIConstants.au3> HotKeySet("^!x", "MyExit") Opt("MouseCoordMode", 0) Opt("WinWaitDelay", 0) GUICreate("ActiveScript", 165, 66) $startButton = GUICtrlCreateButton("Start", 20, 22, 60) $stopButton = GUICtrlCreateButton("Stop", 90, 22, 60) GUISetState(@SW_SHOW) WinSetOnTop("ActiveScript", "", 1) $runState = 1 $winList = WinList() $numWin = $winList[0][0] While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $startButton $runState = 1 Case $GUIMsg = $stopButton $runState = 0 Case $GUIMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect If $runState Then ; Loop thrugh windows $mousePos = MouseGetPos() For $i = 1 to $numWin If StringInStr($winList[$i][0], "mywin") Then WinActivate($winList[$i][0]) Send("{ENTER}") EndIf Next MouseMove($mousePos[0], $mousePos[1], 0) EndIf Sleep(3500) Wend Func MyExit() Exit EndFunc When I set Sleep to a much shorter time interval, paradoxically, the buttons start working, but this is much too much cpu load. Edited February 13, 2005 by cmb99
Developers Jos Posted February 13, 2005 Developers Posted February 13, 2005 what about just running the update portion only every 3.5 seconds? For example like the below or using adlibenable(): expandcollapse popup#include <GUIConstants.au3> HotKeySet("^!x", "MyExit") Opt("MouseCoordMode", 0) Opt("WinWaitDelay", 0) GUICreate("ActiveScript", 165, 66) $startButton = GUICtrlCreateButton("Start", 20, 22, 60) $stopButton = GUICtrlCreateButton("Stop", 90, 22, 60) GUISetState(@SW_SHOW) WinSetOnTop("ActiveScript", "", 1) $runState = 1 $winList = WinList() $numWin = $winList[0][0] $updtimer = TimerInit() While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $startButton $runState = 1 Case $GUIMsg = $stopButton $runState = 0 Case $GUIMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect If $runState and TimerDiff($updtimer) > 3500 Then ; Loop thrugh windows $updtimer = TimerInit() $mousePos = MouseGetPos() For $i = 1 to $numWin If StringInStr($winList[$i][0], "mywin") Then WinActivate($winList[$i][0]) Send("{ENTER}") EndIf Next MouseMove($mousePos[0], $mousePos[1], 0) EndIf Wend Func MyExit() Exit EndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
cmb99 Posted February 13, 2005 Author Posted February 13, 2005 Wow, fast response! Your solution works great!
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