youtuber Posted October 12, 2018 Share Posted October 12, 2018 friends, slider time not reading. and not working,start and stop from loop. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiSlider.au3> Opt("TrayAutoPause", 1) Global $Paused $Form1 = GUICreate("Form1", 259, 118) $aButtonStartStop = GUICtrlCreateButton("Start", 16, 80, 75, 25) $hSlider = GUICtrlCreateSlider(8, 24, 238, 37, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 20000, 1) GUICtrlSetData(-1, 5) $hSlider_Handle = GUICtrlGetHandle(-1) $hLabel = GUICtrlCreateLabel("", 117, 64, 34, 20) GUISetState(@SW_SHOW) $hWndTT = _GUICtrlSlider_GetToolTips($hSlider) _GUICtrlSlider_SetToolTips($hSlider, $hWndTT) $iLastSlider = 0 GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aButtonStartStop $aReadSlider = GUICtrlRead($hSlider) If GUICtrlRead($aButtonStartStop) = "Pause" Then GUICtrlSetData($aButtonStartStop, "Start") Else GUICtrlSetData($aButtonStartStop, "Pause") _pause() While 1 If ProcessExists('notepad.exe') Then If WinWait("[CLASS:Notepad]", "", 2) Then $hWin = WinGetHandle("[CLASS:Notepad]") WinActivate($hWin) ControlClick($hWin, "", "Edit1") Send("asdf") EndIf Else MsgBox(48, "error", "Notepad is not running!") ExitLoop EndIf Sleep($aReadSlider) WEnd EndIf EndSwitch WEnd Func _pause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('stopped', 0, 0) WEnd ToolTip("") EndFunc ;==>_pause Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If $lParam = $hSlider_Handle Then GUICtrlSetData($hLabel, GUICtrlRead($hSlider)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_H_Slider Link to comment Share on other sites More sharing options...
Developers Jos Posted October 12, 2018 Developers Share Posted October 12, 2018 So your issue is that you have a couple of loop which do not process GUI messages thus the GUI becomes unresponsive...right? Try thinking about what you have done and understanding why things won't work. GUIEvent mode could be an option too here. The helpfile is your friend, Jos 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. Link to comment Share on other sites More sharing options...
careca Posted October 12, 2018 Share Posted October 12, 2018 I want to help you but i don't even understand what you expect to happen. Anyway, check these changes expandcollapse popup;============================================================================= #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon= #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=By: #AutoIt3Wrapper_Res_Description= #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Icon_Add= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;============================================================================= #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiSlider.au3> ;============================================================================= Opt("TrayAutoPause", 1) Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled Global $Paused = 1, $Form1, $aButtonStartStop, $hSlider, $hSlider_Handle, $hLabel, $iLastSlider, $aReadSlider, $hWin, $hWndTT ;============================================================================= $Form1 = GUICreate("Form1", 259, 118) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize") GUISetOnEvent($GUI_EVENT_RESTORE, "Restore") $aButtonStartStop = GUICtrlCreateButton("Start", 16, 80, 75, 25) GUICtrlSetOnEvent($aButtonStartStop, '_pause') $hSlider = GUICtrlCreateSlider(8, 24, 238, 37, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 20000, 1) GUICtrlSetData(-1, 5) $hSlider_Handle = GUICtrlGetHandle(-1) $hLabel = GUICtrlCreateLabel("", 117, 64, 34, 20) GUISetState(@SW_SHOW) $hWndTT = _GUICtrlSlider_GetToolTips($hSlider) _GUICtrlSlider_SetToolTips($hSlider, $hWndTT) $iLastSlider = 0 GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider") ;============================================================================= While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aReadSlider = GUICtrlRead($hSlider) If ProcessExists('notepad.exe') Then ConsoleWrite('Notepad is running! - ' & @MSEC & @CRLF) If $Paused = 0 Then If WinWait("[CLASS:Notepad]", "", 2) Then $hWin = WinGetHandle("[CLASS:Notepad]") WinActivate($hWin) ControlClick($hWin, "", "Edit1") Send("asdf") EndIf EndIf Else ConsoleWrite('Notepad is NOT running! - ' & @MSEC & @CRLF) ;ExitLoop EndIf Sleep(100) WEnd ;============================================================================= Func _pause() If $Paused = 1 Then $Paused = 0 GUICtrlSetData($aButtonStartStop, 'Pause') Else $Paused = 1 GUICtrlSetData($aButtonStartStop, 'Continue') EndIf EndFunc ;==>_pause ;============================================================================= Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If $lParam = $hSlider_Handle Then GUICtrlSetData($hLabel, GUICtrlRead($hSlider)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_H_Slider ;============================================================================= #Region ;Window ;============================================================================= Func Minimize() WinSetState('', '', @SW_MINIMIZE) EndFunc ;==>Minimize ;============================================================================= Func Restore() WinSetState('', '', @SW_RESTORE) EndFunc ;==>Restore ;============================================================================= Func Quit() Exit EndFunc ;==>Quit ;============================================================================= #EndRegion ;Window ;============================================================================= youtuber 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
youtuber Posted October 13, 2018 Author Share Posted October 13, 2018 (edited) In this case Does not work Case expandcollapse popup;============================================================================= #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon= #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=By: #AutoIt3Wrapper_Res_Description= #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Icon_Add= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;============================================================================= #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiSlider.au3> ;============================================================================= Opt("TrayAutoPause", 1) Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled Global $Paused = 1, $Form1, $aButtonStartStop, $hSlider, $hSlider_Handle, $hLabel, $iLastSlider, $aReadSlider, $hWin, $hWndTT ;============================================================================= $Form1 = GUICreate("Form1", 259, 118) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize") GUISetOnEvent($GUI_EVENT_RESTORE, "Restore") $aButtonStartStop = GUICtrlCreateButton("Start", 16, 80, 75, 25) GUICtrlSetOnEvent($aButtonStartStop, '_pause') $hSlider = GUICtrlCreateSlider(8, 24, 238, 37, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 20000, 1) GUICtrlSetData(-1, 5) $hSlider_Handle = GUICtrlGetHandle(-1) $hLabel = GUICtrlCreateLabel("", 117, 64, 34, 20) GUISetState(@SW_SHOW) $hWndTT = _GUICtrlSlider_GetToolTips($hSlider) _GUICtrlSlider_SetToolTips($hSlider, $hWndTT) $iLastSlider = 0 GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider") ;============================================================================= While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aButtonStartStop $aReadSlider = GUICtrlRead($hSlider) While 2 If ProcessExists('notepad.exe') Then ConsoleWrite('Notepad is running! - ' & @MSEC & @CRLF) If $Paused = 0 Then If WinWait("[CLASS:Notepad]", "", 2) Then $hWin = WinGetHandle("[CLASS:Notepad]") WinActivate($hWin) ControlClick($hWin, "", "Edit1") Send("asdf") EndIf EndIf Else ConsoleWrite('Notepad is NOT running! - ' & @MSEC & @CRLF) ;ExitLoop EndIf Sleep(100) WEnd EndSwitch WEnd ;============================================================================= Func _pause() If $Paused = 1 Then $Paused = 0 GUICtrlSetData($aButtonStartStop, 'Pause') Else $Paused = 1 GUICtrlSetData($aButtonStartStop, 'Continue') EndIf EndFunc ;==>_pause ;============================================================================= Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If $lParam = $hSlider_Handle Then GUICtrlSetData($hLabel, GUICtrlRead($hSlider)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_H_Slider ;============================================================================= #Region ;Window ;============================================================================= Func Minimize() WinSetState('', '', @SW_MINIMIZE) EndFunc ;==>Minimize ;============================================================================= Func Restore() WinSetState('', '', @SW_RESTORE) EndFunc ;==>Restore ;============================================================================= Func Quit() Exit EndFunc ;==>Quit ;============================================================================= #EndRegion ;Window ;============================================================================= or button works according to timing. so the start,stop is responding late. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiSlider.au3> Opt("GuiOnEventMode", 1) Global $stop = 1 Global $Form1, $aButtonStartStop, $hSlider, $hSlider_Handle, $hLabel, $iLastSlider, $aReadSlider, $hWin, $hWndTT $Form1 = GUICreate("Form1", 259, 118) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $aButtonStartStop = GUICtrlCreateButton("Start", 16, 80, 75, 25) GUICtrlSetOnEvent($aButtonStartStop, "_stop") $hSlider = GUICtrlCreateSlider(8, 24, 238, 37, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE)) GUICtrlSetLimit(-1, 20000, 1) GUICtrlSetData(-1, 5) $hSlider_Handle = GUICtrlGetHandle(-1) $hLabel = GUICtrlCreateLabel("", 117, 64, 34, 20) GUISetState(@SW_SHOW) $hWndTT = _GUICtrlSlider_GetToolTips($hSlider) _GUICtrlSlider_SetToolTips($hSlider, $hWndTT) $iLastSlider = 0 GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider") While 1 Sleep(20) If Not $stop Then _loop() WEnd Func _stop() $stop = Not $stop EndFunc ;==>_stop Func _loop() While 1 If $stop Then GUICtrlSetData($aButtonStartStop, "Start") ExitLoop Else GUICtrlSetData($aButtonStartStop, "Stop") $aReadSlider = GUICtrlRead($hSlider) If ProcessExists('notepad.exe') Then ConsoleWrite('Notepad is running! - ' & @MSEC & @CRLF) If WinWait("[CLASS:Notepad]", "", 2) Then $hWin = WinGetHandle("[CLASS:Notepad]") WinActivate($hWin) ControlClick($hWin, "", "Edit1") Send("asdf") EndIf Else ConsoleWrite('Notepad is NOT running! - ' & @MSEC & @CRLF) ExitLoop EndIf Sleep($aReadSlider) EndIf WEnd EndFunc ;==>_loop Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If $lParam = $hSlider_Handle Then GUICtrlSetData($hLabel, GUICtrlRead($hSlider)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_H_Slider Func _exit() Exit EndFunc ;==>_exit Edited October 13, 2018 by youtuber Link to comment Share on other sites More sharing options...
careca Posted October 13, 2018 Share Posted October 13, 2018 (edited) Could some mod delete my post? I decided im out of this thread. Edited October 13, 2018 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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