JustMeAgain
Members-
Posts
6 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
JustMeAgain's Achievements
Seeker (1/7)
0
Reputation
-
This has probably been submitted about 3,497,103 times so what's 3,497,104 times? I think the comments pretty much tell it all. This might work for W2k3 and Vista, but I haven't tried it out. I have only tested this on my XP SP2 PC and not w2k. I only put put w2k as a valid OS b/c the help file said it would work. If someone could tell me a better way to... 1. figure out which program the user had "runtransparent" launch (WinSetTrans requires a window title) and 2. how to wait for the GUI to show up before searching for the all the window titles or setting the window transparency, I'd appreciate it. I'm currently sleeping for 1 second which isn't a great way to do this. Also, is there a way to use the Win* commands using the process ID instead of the window title? That would help for # 2 above. I'll see what replies I get here before posting to the support forum. Thanks! ; runtranparent ; ; AutoIt Version: 3.1.1.0 ; ; Language: English ; ; Description: ; Launch applications and make them transparent after launching. ; This works on Windows 2000 amd XP. Change $validOS for future OS support. ; ; Parameters (Six are required): ; -r <application> | /r <application> for the application to run ; -t <transparency value> | /t <transparency value> for how transparent to make the window ; If there are not four parameters, then the help is displayed. An application with spaces ; in the path or with command line parameters should be enclosed in quotes. Transparency ; values are 0-255 with the higher the number the less transparent the window. ; CAUTION: a very low transparency number can make your window virtually invisable. ; ; Usage: ; runtransparent -r notepad.exe -t 130 ; ; Background: ; Windows 2000 and higher supports transparency although you can't access this feature through ; Windows itself that I know of. You can buy 3rd party desktop replacements for Windows that ; support transparency. ; OSX and Linux also support transparency. For example, if you run KDE or Gnome in Linux, you ; set the shell prompt to be transparent. ; In order to give a Windows user some of this functionality I wrote this simple program using ; the ever powerful AutoIt language, which can be found at http://www.autoitscript.com/autoit3. ; ; Version 1.0.0 - 03/30/2006 - JAH AutoItSetOption("TrayIconHide", 1) Dim $version = "1.0.0" ;Program version. Call("main") Func main() ; This function is called first by AutoIt when the programs runs. ; - Turn off AutoIt fatal errors. ; - Hide the AutoIt tray icon. ; - Set the valid Windows versions that support transparency. ; - Verify the running OS supports transparency. ; - Get the command line parameters the user passed and verify they are correct. ; - Run the user's program with transparency. ; - Exit. Local $options[2] ;Parameters used to launch the user's program. Local $validOS[2] ;Array to hold the valid OSes. $validOS[0] = "WIN_2000" $validOS[1] = "WIN_XP" verifyOS($validOS) $options = Call("getParms") launch($options) Call("end") EndFunc Func verifyOS($OS) ; Verify the running OS supports transparency. ; If not, notify the user and exit. ; $OS = the array of valid OSes. For $i = 0 to UBound($OS) -1 Step 1 If @OSVersion = $OS[$i] Then Return Next ; If you didn't return, then your running an unsupported version of Windows. MsgBox(16+4096, @ScriptName & " " & $version & " ERROR", _ "ERROR: Invalid OS - " & @OSVersion & "." & @CRLF & _ "You are running an version of Windows that does not support transparency." & @CRLF & _ "Upgrade Windows to and try again. Exiting now.") Call("end") EndFunc Func getParms() ; Get the command line parameters and return them in an array. ; If the user requests help, then show the help and exit. Local $clp[2] ;Command line parameters to return. Local $validR = 0 ;Verify the user passed the -r|/r parameters. Local $validT = 0 ;Verify the user passed the -t|/t parameters. If $CmdLine[0] <> 4 Then ;There can only be 6 parameters. Any more or less is an error. Call("showHelp") Else For $i = 1 to $CmdLine[0] Step 1 If $CmdLine[$i] = "-r" Or $CmdLine[$i] = "/r" Then $clp[0] = $CmdLine[$i+1] $validR = 1 ElseIf $CmdLine[$i] = "-t" Or $CmdLine[$i] = "/t" Then $clp[1] = $CmdLine[$i+1] $validT = 1 EndIf Next EndIf If Not $validR Or Not $validT Then Call("showHelp") Else Return($clp) EndIf EndFunc Func showHelp() ; Display the help if requested by the user or there were not any command line parameters MsgBox(64, @ScriptName & " " & $version & " Help", _ "This program will run a program with transparency set. NOTE: Some programs" & @CRLF & _ "may not support transparency or " & @ScriptName & " may not be able to set" & @CRLF & _ "the transparency of the program that was run." & @CRLF & @CRLF & _ "The following are command line parameters that must be used." & @CRLF & @CRLF & _ " -r <application> | /r <application> = The application to run with transparency." & @CRLF & _ " -title <window title> | /title <window title> = The exact title of the window that is run." & @CRLF & _ " -t <transparency value> | /t <transparency value> = Transparency value ." & @CRLF & _ " Transparency values range from 0-255, where a larger number is more transparent." & @CRLF & @CRLF & _ "Examples:" & @CRLF & @CRLF & _ " " & @ScriptName & " -r cmd.exe -title ""C:\WINDOWS\system32\cmd.exe"" -t 200 = Run cmd.exe with a transparency value of 200." & @CRLF & _ " " & @ScriptName & " /r ""C:\Program Files\AutoIt3\AU3Info.exe"" /title ""AutoIt v3 Active Window Info"" /t 150 = Run" & @CRLF & _ " ""C:\Program Files\AutoIt3\AU3Info.exe"" with a transparency value of 150." & @CRLF & @CRLF & _ "NOTE: You can create a shortcut to " & @ScriptName & " with the parameters already set" & @CRLF & _ "so you run a program with the same transparency value every time." & @CRLF & @CRLF & _ "CAUTION: a very low transparency number can make your window virtually invisable.") Call("end") EndFunc Func launch($opts) ; Verify the specified program exists. If not, exit. ; If so, run the program with the transparency the user specified. ; $opts[0] = the program to run. ; $opts[1] = the transparency value. $pid = Run($opts[0]) If Not $pid Then If Not FileExists($opts[0]) Then MsgBox(16+4096, @ScriptName & " " & $version & " ERROR", _ "ERROR: Unable to find " & $opts[0] & "." & @CRLF & _ "Verify the following:" & @CRLF & _ " 1. The path and program name are correct." & @CRLF & _ " 2. The program is in the path if a path was not given." & @CRLF & _ " 3. You have permissions/access to the program." & @CRLF & _ "Exiting now.") Call("end") Else MsgBox(16+4096, @ScriptName & " " & $version & " ERROR", _ "ERROR: Unable to launch " & $opts[0] & "." & @CRLF & _ "Verify the following:" & @CRLF & _ " 1. The program runs properly without using " & @ScriptName & "." & @CRLF & _ " 2. The program is installed properly." & @CRLF & _ " 3. The program does not require parameters that are missing." & @CRLF & _ "Exiting now.") Call("end") EndIf Else Sleep(1000) ;Give the window a second to open. $titles = WinList("") ;Get the titles of all the open windows. For $i = 0 To UBound($titles) -1 Step 1 If WinGetProcess($titles[$i][0]) = $pid Then WinSetTrans($titles[$i][0], "", $opts[1]) ;Make the $opts[0] window transparent. Return EndIf Next EndIf MsgBox(48+4096, @ScriptName & " " & $version & "ERROR", _ "ERROR: Unable to find the window with process ID " & $pid & " to make transparent." & @CRLF & _ "Possible causes:" & @CRLF & _ " 1. " & $opts[0] & " may not have a window/GUI." & @CRLF & _ " 2. The window took too long to open." & @CRLF & _ " 3. " & $opts[0] & " may launch another process that runs the GUI.") Return EndFunc Func end() ; Future cleanup steps needed before exiting can be put here. Exit EndFunc
-
DirCreate not creating a folder
JustMeAgain replied to JustMeAgain's topic in AutoIt General Help and Support
Thanks, JdeB! Very cool code. I looked back at the help for RunAsSet and sure enough, it states "(t)his function allows subsequent Run and RunWait functions to run as a different user...". DOH! I've successfully used RunAsSet with previous scripts. I guess I always just used it with Run and RunWait commands. Now that I've been educated, this would be another option, but perhaps not as clean as a script that calls itself. FileInstall("adminCmds.exe", @TempDir & "\adminCmds.exe") ; adminCmds.exe = commands to run as the administrator. RunAsSet($USERNAME, @ComputerName, $PASSWORD) RunWait(@TempDir & "\adminCmds.exe") RunAsSet() -
How to create a message box with ok cancel
JustMeAgain replied to efjay's topic in AutoIt General Help and Support
You'll want to do something like this: $prompt = msgbox(4129, "Continue?", "Click OK to auto run this CD or Cancel to exit now.") if $prompt = "2" exit <the rest of you code goes here> I find the AutoIt Help Index very useful and I usually keep it open beside SciTE while coding. Look up the options for "MsgBox" and all the other powerful commands in AutoIt. Or use the online manual. -
Specs: AutoIt ver: 3.1.1.0 OS: Windows XP SP2 What I'm trying to do: A normal Windows users will run the following compiled script and I use RunAsSet() to elevate their privligies to local admin to create a folder under @ProgramFilesDir. This will copy just the needed UltraVNC files for VNC server or VNC viewer (I have an installer for each and they both have the same problem) to the sub folder under @ProgramFilesDir. Then the user with the VNC server can create an encrypted tunel using reverse VNC. (I've written, but not really tested yet, a launcher for VNC server and VNC viewer in listen mode.) What problem is occuring: DirCreate will not create $path (@ProgramFilesDir & "\UltraVNC"). MsgBox(0, "", $path) shows the correct path (C:\Program Files\UltraVNC). I've added "RunWait(@ComSpec & " /k c:\util\whoami.exe")" right after the RunAsSet command, which shows "Administrator" (whoami.exe is a little DOS app that gives you the logged on user). I can use that same command prompt to create my sub folder under C:\program files. So I know this account has the rights to create the folder. My script, compiled and executed from the C: drive, errors out with my msgbox about being unable to create the folder. My question: Does anyone have any ideas on why this is failing? I'm sure it's probably a problem with my script and I'm too tired to see what's wrong. Searching the forums showed a lot of people using DirCreate, but I didn't see where people were having this problem. UltraVNC Server Install Code: Dim $version = "1.0.0" Call("main") Func main() Local $instPath = @ProgramFilesDir & "\UltraVNC" ;Folder for file extraction. Local $admin = "Administrator" Local $passwd = "******" $prompt = MsgBox(36, @ScriptName & " Version " & $version, _ "This will install the standalone UltraVNC server on your computer." & @CRLF & _ "Do you want to continue?") If $prompt = "7" Then Call("end") install($instPath, $admin, $passwd) ;Extract the embedded files. MsgBox(64, "Exiting " & @ScriptName & " Version " & $version, "Finished installing.") Call("end") ;Exit. EndFunc Func install($path, $adm, $pwd) ;Extract the embedded files. See the comments at the top for more information. ;$path = $instPath = Folder to extract (i.e. install) the files. ;$adm = $admin = User account with elevated privileges. ;$pwd = $passwd = User password to use with $adm. Local $winvnc = "winvnc.exe" Local $winvncicon = "winvnc.ico" Local $rc4 = "rc4.key" Local $MSRC4Plugin = "MSRC4Plugin_NoReg.dsm" Local $launchwinvnc = "LaunchWinVNC.exe" TrayTip(@ScriptName, "Installing files.", 30, 1) RunAsSet($adm, @ComputerName, $pwd) If FileExists($path) = "0" Then If DirCreate($path) = "0" Then MsgBox(4112, "ERROR: Unable to create folder", "Unable to create the following folder:" & @CRLF & _ " " & $path & @CRLF & _ "Create the folder manually and then run " & @ScriptName & " again." & @CRLF & _ "Click OK to exit.") Call("end") EndIf EndIf If FileInstall("winvnc.exe", $path & "\" & $winvnc, 1) = "0" Then MsgBox(16, "ERROR: Unable to extract file", "Unable to extract " & $winvnc & " to the destination directory." & @CRLF & _ "Exiting without finishing the install.") Call("end") EndIf If FileInstall("winvnc.ico", $path & "\" & $winvncicon, 1) = "0" Then MsgBox(16, "ERROR: Unable to extract file", "Unable to extract " & $winvncicon & " to the destination directory." & @CRLF & _ "Exiting without finishing the install.") Call("end") EndIf If FileInstall("rc4.key", $path & "\" & $rc4, 1) = "0" Then MsgBox(16, "ERROR: Unable to extract file", "Unable to extract " & $rc4 & " to the destination directory." & @CRLF & _ "Exiting without finishing the install.") Call("end") EndIf If FileInstall("MSRC4Plugin_NoReg.dsm", $path & "\" & $MSRC4Plugin, 1) = "0" Then MsgBox(16, "ERROR: Unable to extract file", "Unable to extract " & $MSRC4Plugin & " to the destination directory." & @CRLF & _ "Exiting without finishing the install.") Call("end") EndIf If FileInstall("LaunchWinVNC.exe", $path & "\" & $launchwinvnc, 1) = "0" Then MsgBox(16, "ERROR: Unable to extract file", "Unable to extract " & $launchwinvnc & " to the destination directory." & @CRLF & _ "Exiting without finishing the install.") Call("end") EndIf TrayTip(@ScriptName, "Creating the Desktop shortcut.", 30, 1) FileCreateShortcut($path & "\" & $launchwinvnc, @DesktopCommonDir & "\Launch UltraVNC Server.lnk", $path, "", "Launch UltraVNC server", $path & "\" & $winvncicon) RunAsSet() TrayTip("", "", 0) Return EndFunc Func end() Exit EndFunc Thanks for any help you can provide.
-
corvias, for those of that have to support our friend's and family's computers, this would be a nice thing for them to have. Then schedule a job to run this daily/weekly. It could be modified to launch the scanners (Adaware, Spybot S&D, anti-virus, etc) after they've been updated. You can even be sneaky and disable the keybaord and mouse while it runs so they can't stop it (BlockInput(flag)). Just remember to enable them when you're done. I see a lot of potential with this script. To increase the target market, it could update for a larger number of apps (e.g. add SpywareBlaster, Avast AV, McAfee, etc) and use an INI file to set which apps to download for or set it in the app or use both where the INI file overrides internal settings. E.g. #Start Update.ini [Anti-Virus] Symantec ;McAfee ;Avast [Anti-Spyware] SpybotS&D AdAware ;SpywareBlaster #End Update.ini Just a thought. Thanks for sharing. PS. I'm setting up a new XP PC for my folks this weekend and anything that I can't automate the update for in the app, I'll just AutoIt.
-
I'd like to try it out. If it's usable, then please post the code. I'm sure others would like to use, too.