Philm8888 Posted March 17, 2014 Share Posted March 17, 2014 I had 2 goals in mind. 1 was to make a hotkey so that I could toggle my screensaver on and off. I started out using Autohotkey first and quickly came to not like it. Although, I can't quite firgure out how to translate the code. I just started learning a couple days ago. I then came across AutoIt which seemed more promissing. I had to change up a little on what I wanted and came with ScreenSaverScript.au3. expandcollapse popupHotKeySet("{BROWSER_HOME}", "EnableScreensaver") HotKeySet("{BROWSER_SEARCH}", "DisableScreensaver") HotKeySet("{LAUNCH_MAIL}", "ShowMessage") HotKeySet("+!e", "Terminate") ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func Terminate() Exit 0 EndFunc ;==>Terminate Func _ScreenSaverEnabled() Opt('WinWaitDelay', 100) Opt('WinDetectHiddenText', 1) Opt('MouseCoordMode', 0) EndFunc ;==>_ScreenSaverEnabled Func _ScreenSaverDisabled() Opt('WinWaitDelay', 100) Opt('WinDetectHiddenText', 1) Opt('MouseCoordMode', 0) EndFunc ;==>_ScreenSaverDisabled Func _WinWaitActivate($title, $text, $timeout = 0) WinWait($title, $text, $timeout) If Not WinActive($title, $text) Then WinActivate($title, $text) WinWaitActive($title, $text, $timeout) EndFunc ;==>_WinWaitActivate Func EnableScreensaver() ;Enabled _WinWaitActivate("Program Manager", "FolderView") Send("{LWINDOWN}{LWINUP}") _WinWaitActivate("Start menu", "All Programs") Send("{DOWN}{ENTER}") _WinWaitActivate("Screen Saver Settings", "On &resume, display ") Send("d{ENTER}") ;Sets the Screensaver to "Digital Clock-7" MsgBox(4096, "ScreenSaver", "The ScreenSaver is Enabled", 10) EndFunc ;==>EnableScreensaver Func DisableScreensaver() ;Disabled _WinWaitActivate("Program Manager", "FolderView") Send("{LWINDOWN}{LWINUP}") _WinWaitActivate("Start menu", "All Programs") Send("{DOWN}{ENTER}") _WinWaitActivate("Screen Saver Settings", "On &resume, display ") Send("{SHIFTDOWN}9{SHIFTUP}{ENTER}") ;Disabled MsgBox(4096, "ScreenSaver", "The ScreenSaver is Disabled", 10) EndFunc ;==>DisableScreensaver Func ShowMessage() MsgBox(4096, "Active Keys", "The HotKeys are <<Mail - Show Hotkays>> <<WebHome=ScrSvr On; Search=ScrSvr Off; Ctrl-Alt-e=End Script - on the Keybourd>>", 10) EndFunc ;==>ShowMessage I wasn't quite sure how to make it work with just passing the "Screen Saver Setting" to whatever call it required to make it work. I also wanted to make a hotkey available so that I can launch TrueCrypt and to have it open a container then have that program in the container launch with one keypress. I made it work in AutoHotKey but I haven't got it down yet with AutoIt. Here are what they look like. The first one I tried worked but with not security like you get with AutoIt. KeyCommands.ahk #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Recommended for catching common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ^!f:: Run "c:\Program Files\TrueCrypt\TrueCrypt.exe" /l U "x:\\BlendingStyles.tc" /a /p ; TrueCrypt Container (FF) ^!k:: Run "c:\Program Files\TrueCrypt\TrueCrypt.exe" /l Z "x:\Extention.tc" /a /p ; TrueCrypt Container (KP) ^!+s::run shutdown /f /p ; (Force a Shutdown) This is how far I got transferring it to AutoIt: KeyCommands.au3 HotKeySet("^!f", "LoadFireFox") ;Ctrl-Alt-f HotKeySet("^!+s", "ForceShutdown") ;Ctrl-Alt-Shift-s HotKeySet("^!k", "RunKP") ;Ctrl-Alt-k HotKeySet("+!e", "Terminate") ;Shift-Alt-e ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func LoadFireFox() ShellExecuteWait("TrueCrypt.exe", " /l U x:\BlendingStyles.tc /a /p /q", "",) ShellExecute("FirefoxPortable.exe", "", "u:\FirefoxPortable\") EndFunc Func ForceShutdown() Shutdown(5) ;Force a Shutdown EndFunc Func RunKP() ShellExecuteWait("TrueCrypt.exe", " /l Z x:\Extention.tc /a /p", "",) ShellExecute("KeePass.exe", "", "z:\KeePass-2.23\") EndFunc Func Terminate() Exit 0 EndFunc ;==>Terminate Am I even close to getting this write? I kind of get lost in the help file. Could anyone point me to some examples that I might look through? I would really appriciate any help anyone could give me. Thanks. Phil Link to comment Share on other sites More sharing options...
TechCoder Posted March 17, 2014 Share Posted March 17, 2014 Seems like you are on the right track. You will get a lot more help, though, when you go through the code and discuss what problems you have. Simply posting the shell makes it difficult for anyone to do much (unless they have all the programs you have, etc.) Be more direct on the issues you have and there are plenty of people that will help. 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