Jump to content

Handling file already exists&concatenate dir+file frm commands


anandnz
 Share

Recommended Posts

Hi i am learning the notepad example further and thanks to the help here i could able to move one step.

When i creating the notepad with name from command, I want to know how to handle scenarios 1. File already exists, 2. File does not exist. The window info

returns "Notepad" which does not help me ..visible text is ( &Yes, &No, Canel, Cannot find Arnold.txt file, Do you want to create a new one)

1. How to compare dialog boxes and take action based on the visible text of the windo info .??

2. I want to save the notepad by taking directory string stored with the file name variable. i,e dir+filename

Any help is appreciated.

#include <File.au3>
; enable to save the notepad with name from command
; Handle save as, Already exists dialog boxes
; save the file in the directory given from the command
; concatenate above directory with file command to save the notepad.

Local $Cnt =0, $Li[2] = ["Arnold", "Carol"]
Global $Str = "C:\data\work\autolt\Logfile.txt"
Global $dir = "C:\data\work\programming\autolt"
For $Cnt = 0 To 1 Step 1
    ConsoleWrite("notepad = " & $Li[$Cnt] & @CRLF)  ; Check if it prints the variable
    Run("Notepad.exe " & $Li[$Cnt]) ; use space between & and variable
    sleep(2000)
    ; I want to see if i can pass a variable to the command ..
    _WinWaitActivate("" & $Li[$Cnt],"")
    if WinActive("Notepad") then send("!s")
    ; NEED HELP HERE TO HANDLE THE FILE DOES NOT EXSITS, FILE ALREADY EXISTS
    ; DIALOG BOXES
    send ("!f") ; to go to notepad "File" menu
    send("+a") ; to go to "Save As" menu
    ;send("" & $dir + & $Li[$Cnt])
; NEED HELP HERE TO CONCATENATE TWO STRINGS FROM USER COMMANDS
; DIRECTORY + FILE NAME ..

    _FileWriteLog( "" & $Str, "File is ="  & $Li[$Cnt])
    ;add your log message...date & time will automatically prepend your text
Next ;WinWaitActive(&$li[$cnt] - "Notepad")

FUNC _winwaitActivate($title, $text, $timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
Edited by anandnz
Link to comment
Share on other sites

Or AdlibRegister() in the new Version of AutoIt.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Yes :-)

I still use old 3.2.12.1 because I have got too many scripts in syntax for this version.

Hi Zedna,

Thank you very much.

I see that you have rightly suggested to use, please do you have any opinion on the my issue

here ..

It is requires me to pass two variables in the functions i am calling in AdlibRegister()

Thanks

--Anand

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...