pieeater Posted May 17, 2011 Share Posted May 17, 2011 can you make it so that you run a script from a flashdrive and when the flashdrive is unplugged it automatically closes? [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
dufran3 Posted May 17, 2011 Share Posted May 17, 2011 you would have to copy the script locally, because you can't run a script if the source is unplugged Link to comment Share on other sites More sharing options...
pieeater Posted May 17, 2011 Author Share Posted May 17, 2011 but if i have the script on the flashdrive and then start it, how would i check to see if it is unplugged and make it exit? [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
KaFu Posted May 17, 2011 Share Posted May 17, 2011 There's code floating around the forum to check whether an USB drive as been connected or disconnected... but this should do it too ... AdlibRegister("_Check_Script_Existence", 1000) Func _Check_Script_Existence() if not FileExists(@ScriptFullPath) Then Exit endif EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
pieeater Posted May 17, 2011 Author Share Posted May 17, 2011 thanks thats exactly what i needed [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
wakillon Posted May 18, 2011 Share Posted May 18, 2011 There's code floating around the forum to check whether an USB drive as been connected or disconnected... but this should do it too ... AdlibRegister("_Check_Script_Existence", 1000) Func _Check_Script_Existence() if not FileExists(@ScriptFullPath) Then Exit endif EndFunc Did you try it ? Seems odd that a script can realize that it doesn't exists... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
dufran3 Posted May 18, 2011 Share Posted May 18, 2011 My thoughts exactly Link to comment Share on other sites More sharing options...
kaotkbliss Posted May 18, 2011 Share Posted May 18, 2011 Seems logical to me. If the @ScriptFullPath is on a flash drive, then if it's unplugged, the full path no longer exists. However, I'm not sure if the script will be able to continue to run if the drive is unplugged as mentioned. You may have to FileInstall a secondary script to a temp dir on the pc that checks the path or something. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
wakillon Posted May 18, 2011 Share Posted May 18, 2011 (edited) Seems logical to me. If the @ScriptFullPath is on a flash drive, then if it's unplugged, the full path no longer exists. However, I'm not sure if the script will be able to continue to run if the drive is unplugged as mentioned.You may have to FileInstall a secondary script to a temp dir on the pc that checks the path or something.How can it be logical to you ?If not plugged, it can't be executed and "know" if it exists...A second script seems more reliable. Edited May 18, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
dufran3 Posted May 18, 2011 Share Posted May 18, 2011 hmmm...sounds like the 2nd post in the thread makes some sense... Link to comment Share on other sites More sharing options...
kaotkbliss Posted May 18, 2011 Share Posted May 18, 2011 (edited) I was assuming the script was started while the drive was plugged in. *edit* I guess I also assumed that script was loaded into Memory before running, but maybe not. Wasn't sure as I always run all my scripts locally. Edited May 18, 2011 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
guinness Posted May 18, 2011 Share Posted May 18, 2011 Or what about using /AutoIt3ExecuteScript with @AutoItExe? 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...
BrewManNH Posted May 18, 2011 Share Posted May 18, 2011 I just tested this scenario with one of my scripts, I ran SciTe from the hard drive, opened a script on a USB drive, and then ran it from SciTe. After it started running, I pulled the USB drive from the computer, it kept running without a problem. It appears to be running the script in memory. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
pieeater Posted May 18, 2011 Author Share Posted May 18, 2011 it works for me, the thing about this is it checks to see if the path exists, so where ever the script comes from(USB drive) if it is deleted(or unplugged) the script will no longer exist on the computer, and then you can make it exit using an if...then. however if the script is not on a flash drive, the only way to close the script(unless you have another closing option) is to delete the script. [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
BrewManNH Posted May 18, 2011 Share Posted May 18, 2011 Have the script write a temporary file to the USB drive you're accessing, if that file doesn't exist then exit the script. This way it won't matter where the script is being run from, it only matters that the USB drive has a file you're looking for on it. Or just look for the drive letter itself if you don't have the script running from the USB drive. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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