Jump to content

Recommended Posts

Posted (edited)

^^ i am not crazy :D 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 by IanN1990
Posted

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

Posted

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

Posted

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.

  • 2 weeks later...
Posted (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 by KeyMs92
  • 8 months later...
Posted (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 by faldo
Posted

 

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.")

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...