daanodinot Posted December 11, 2012 Author Share Posted December 11, 2012 OK, thanks for the explanation IanN1990, I re-added your code. Though not your crazy long while loop.. sleep(250) does the trick for me Link to comment Share on other sites More sharing options...
IanN1990 Posted December 11, 2012 Share Posted December 11, 2012 (edited) ^^ i am not crazy just in my logic. My computer is sometimes on for 3-6 days at a strench, and i see no reason to keep "cycling" a loop 4 times a second when the while is only here to keep the script alive. So instead of 4 times a second, its 1 time per day. Edited December 11, 2012 by IanN1990 Link to comment Share on other sites More sharing options...
guinness Posted December 11, 2012 Share Posted December 11, 2012 May i ask why its not really recommended?As the while loop is only there to keep the script alive so hooks can process things. I figured have a long sleep in there It's not about not being recommended, but the expression "less is more" comes to mind. I would say if you have to use sleep for more than 10 seconds then use a timer of some description instead of pausing the script. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted December 11, 2012 Share Posted December 11, 2012 (edited) Is Sleep() itself not an active function? I had the idea in my head that long sleeps actually would increase cpu cycles over more shorter sleeps where in between the cpu is completely free. Edited December 11, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted December 11, 2012 Share Posted December 11, 2012 Interesting theory, but I couldn't find anything to back this up. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted December 11, 2012 Share Posted December 11, 2012 Yeah, I never based it on anything really, just was there for some reason. If a process is Spleeping, then an API must be polling the time during that Sleep if there are breaks between that sleep I would assume possibly incorrectly that relief of those polls would equal less cpu cycles. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
daanodinot Posted December 22, 2012 Author Share Posted December 22, 2012 (edited) (Sorry, to extend this topic, but I didn't think it was worth it creating a new topic.) Lately, I've been trying to use a similar script to this one in combination with opening/exiting an application. When I open the application, I want the sound device disabled; when I exit it, I want the sound device enabled again. This is what I have now: AutoItSetOption("SendKeyDownDelay", 0) AutoItSetOption("SendKeyDelay", 0) local $Sound $SystemHook = DllCall('user32.dll', 'int', 'RegisterWindowMessageW', 'wstr', 'SHELLHOOK') GUIRegisterMsg($SystemHook[0], "GUIHook") DllCall('user32.dll', 'int', 'RegisterShellHookWindow', 'hwnd', GUICreate('Autoit Hook GUI')) Run("control mmsys.cpl") Sleep(300) Run("C:\Program Files (x86)\Finale 2012\Finale.exe") While ProcessExists ( "Finale.exe" ) Sleep(1) WEnd Sleep(1000) If Not UBound(ProcessList( "AutoIt3_x64.exe" )) > 1 Then Run("ToggleSound.exe") EndIf Func GUIHook($hWnd,$Msg,$wParam,$lParam) Switch StringRight($wParam, 1) Case 1 If WinGetTitle($lParam) = WinGetTitle("") and $Sound = 0 Then $Sound = 1 WinMove(WinGetTitle(""),"",-500,-500) Send("{DOWN 3}{APPSKEY}{DOWN 10}{ENTER 2}") EndIf EndSwitch EndFunc It works, until the "If Not UBound line". Then, I need to apply some form of recursion, to run the script again. But for some reason I can't get the Guihook method to run for the second time... Edited December 22, 2012 by KeyMs92 Link to comment Share on other sites More sharing options...
IanN1990 Posted December 23, 2012 Share Posted December 23, 2012 While ProcessExists ( "Finale.exe" ) Sleep(1) WEnd In my view, is bad code. I ran it on my pc. Quad core 3.30ghz and it was 3% Cpu. As the same effect could be achived with WinExists and using no cpu. Link to comment Share on other sites More sharing options...
daanodinot Posted December 25, 2012 Author Share Posted December 25, 2012 Ok, thanks, I see. But then how do you get to run the script/function again when the windows/process is closed? Link to comment Share on other sites More sharing options...
faldo Posted August 29, 2013 Share Posted August 29, 2013 (edited) Heya, I'm trying to create a Outlook profile by running the guide (C:Program Files (x86)Microsoft OfficeOffice14MLCFG32.CPL) Now, since i don't want the user to interact with the guide nor to see it, Universalists excelent hook works like a charm. However it only seems to work for a single GUI, once the "Show profiles" button is clicked a new window is opened and the hook looses the "link" and the new window "flickers" before i manage to make it transparent. Could someone help me either modify my script or in some other way hide the guide? Mind the window-titles being in swedish Local $Email $GUIHook = GUICreate('Autoit Hook GUI') ;A GUI is needed to catch the messages. ;~ MsgBox(0, "", $GUIHook) $SystemHook = DllCall('user32.dll', 'int', 'RegisterWindowMessageW', 'wstr', 'SHELLHOOK') ;This the hook cut down and simplifed. Check link for a more detailed info on it. GUIRegisterMsg($SystemHook[0], "GUIHook") ;Is the function you want to regesiter the Hook to. "GUIHook" DllCall('user32.dll', 'int', 'RegisterShellHookWindow', 'hwnd', $GUIHook) ;Links it to your GUI so you can see the messages. Run('control "C:\Program Files (x86)\Microsoft Office\Office14\MLCFG32.CPL"') ;Runs the Program While 1 Sleep(250) ;This is to keep the script alive, check HotKeySet in HelpFile. Its the same idea. WEnd Func GUIHook($hWnd, $Msg, $wParam, $lParam) Switch StringRight($wParam, 1) Case 1 ;Window Created If WinGetTitle("Konfigurera e-post") And $Email = 0 Then $Email = 1 WinSetTrans(WinGetTitle("Konfigurera"), "", 100) ControlClick(WinGetTitle("Konfigurera"), "", "Button3") WinWait("E-post") WinSetTrans(WinGetTitle("E-post"), "", 100) ControlClick(WinGetTitle("E-post"), "", "Button1") Exit EndIf EndSwitch EndFunc ;==>GUIHook Edited August 29, 2013 by faldo Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API Link to comment Share on other sites More sharing options...
Queener Posted August 29, 2013 Share Posted August 29, 2013 Heya, I'm trying to create a Outlook profile by running the guide (C:Program Files (x86)Microsoft OfficeOffice14MLCFG32.CPL) Now, since i don't want the user to interact with the guide nor to see it, Universalists excelent hook works like a charm. However it only seems to work for a single GUI, once the "Show profiles" button is clicked a new window is opened and the hook looses the "link" and the new window "flickers" before i manage to make it transparent. Could someone help me either modify my script or in some other way hide the guide? Mind the window-titles being in swedish Local $Email $GUIHook = GUICreate('Autoit Hook GUI') ;A GUI is needed to catch the messages. ;~ MsgBox(0, "", $GUIHook) $SystemHook = DllCall('user32.dll', 'int', 'RegisterWindowMessageW', 'wstr', 'SHELLHOOK') ;This the hook cut down and simplifed. Check link for a more detailed info on it. GUIRegisterMsg($SystemHook[0], "GUIHook") ;Is the function you want to regesiter the Hook to. "GUIHook" DllCall('user32.dll', 'int', 'RegisterShellHookWindow', 'hwnd', $GUIHook) ;Links it to your GUI so you can see the messages. Run('control "C:\Program Files (x86)\Microsoft Office\Office14\MLCFG32.CPL"') ;Runs the Program While 1 Sleep(250) ;This is to keep the script alive, check HotKeySet in HelpFile. Its the same idea. WEnd Func GUIHook($hWnd, $Msg, $wParam, $lParam) Switch StringRight($wParam, 1) Case 1 ;Window Created If WinGetTitle("Konfigurera e-post") And $Email = 0 Then $Email = 1 WinSetTrans(WinGetTitle("Konfigurera"), "", 100) ControlClick(WinGetTitle("Konfigurera"), "", "Button3") WinWait("E-post") WinSetTrans(WinGetTitle("E-post"), "", 100) ControlClick(WinGetTitle("E-post"), "", "Button1") Exit EndIf EndSwitch EndFunc ;==>GUIHook If this is unrelated to control panel, I suggest you post a new thread. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") 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