Opening RDP File With AutoIT - autoit

I am new to AutoIT, looking for some help to open RDP file. RDP files are available in my downloads folder. Most of the time I don't know my RDP file. I want to open the most recently downloaded RDP file. Can someone help me with the code? For now, I just tried to open RDP file by hardcoding the filename and it worked PFB the code but I need to find the most recently downloaded RDP file and open the same instead of hardcoding it.
Run("explorer.exe " & "C:\Users\Balaji\Downloads")
Run(#Comspec & " /c start " & FileGetShortName('C:\Users\1451615\Downloads\TestRDP.rdp'))

Try this! This should look into your downloads-folder for all files *.rdp and then sort the array, so you get the latest modified file and then Run it.
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
;~ Global $downloadPath = 'C:\Users\Balaji\Downloads'
Global $downloadPath = #UserProfileDir & '\Downloads'
Global $rdpFiles = _FileListToArray($downloadPath, '*.rdp', $FLTA_FILES, True)
Global $ar[UBound($rdpFiles)][2]
For $i = 1 To UBound($rdpFiles) - 1
$ar[$i][0] = $rdpFiles[$i]
$ar[$i][1] = FileGetTime($rdpFiles[$i], $FT_MODIFIED, $FT_STRING )
Next
_ArraySort($ar, 1, Default, Default, 1)
; _ArrayDisplay($ar) ; If you want to have at look at the array
Run($ar[0], '', #SW_MAXIMIZE)

Related

regarding on opening a custom file in notepad++

This is my task which I am doing in AutoIT.
Basic Info :
I have a folder name "vk" and it has 5 subfolders named vk1 vk2 vk3 vk4 vk5.
Each Subfolder has a file ,basically a keil project.
Like
vk1 has first.uvproj
vk2 has sec.uvproj
vk3 has third.uvproj
and so on..
Now my requirement is to write a script where in the script has to go in vk1,vk2,vk3,vk4,vk5 folders
and
open first.uvproj in notepad++
Do some operation
Close it
Next it has to open sec.uvproj
Do some operation
Close it
Next it has to open
third.uvproj
Do some operation
Close it and so on..
Till now I have done this for one file using paths hardcoded.
How to make it happen for all other folders.
Can any one help ?
Thanks
The help file has your answer,
$sTextFile="first.uvproj"
Run ( "notepad.exe " & $sTextFile, #WindowsDir, #SW_MAXIMIZE )
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("[CLASS:Notepad]", "", 10)
WinClose("[CLASS:Notepad]")
$sTextFile="second.uvproj"
Run ( "notepad.exe " & $sTextFile, #WindowsDir, #SW_MAXIMIZE )
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
rinse and repeat

R - Check if File is Open/Closed and by which user

I have a document that is used by multiple people, and we have to continually check if the file is in use and by who.
I was wondering if there is anyway in R that I could obtain the status of an .xlsx file, if it is closed or open, and who has the file open.
I would then push this result to a HTML page which would refresh on a regular basis, this should then remove the need for the manual checking.
Here is a starting point you might consider. This option is using C code you can compile in with R Cmd and call from R.
In a file "islocked.c" paste this:
#include <stdio.h>
#include <share.h>
void testLock(int *locked, char **filename)
{
FILE *stream;
if( (stream = _fsopen( *filename, "wt", _SH_DENYWR )) != NULL ) {
fclose( stream );
*locked = 0;
} else {
*locked = 1;
}
}
Open a command prompt (windows | find | 'cmd')
Change into the folder you saved the file above
From your command prompt c:\ type the following
"Program File\R\R-3.1.2\bin\r" CMD SHLIB islocked.c
It shouldn't throw any errors or warnings and create a .o and .dll file as a result.
Now in R:
dyn.load('c:\pathtothe_c_file\islocked.dll')
result->.C('testLock', islocked=as.integer(0), filename="d:\tools\r\test.dll")
result$islocked
[1] 1
The dll is locked by R so this should return 1. Try the .o file and it should return 0. There is an API in Windows 7 and newer called IFileInUse which may return the process and possibly the user that has the file open that you might review if you need more information.
IsFileInUse API:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee330722%28v=vs.85%29.aspx
A utility from Microsoft that runs on a command line you can shell to from R that may produce what you need, if you are able to install tools on the server:
http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx

AutoIT How do I perform a recursive search?

In AutoIT I'm making a script that needs to be able to recursively search a certain area for all files. I've read up on it online and all of the scripts that I've tried use functions that I'm not able to use. Do any of you guys have a script that I could use to recursively search a directory and save all of the files it finds to an array? If you could do this I'd be incredibly happy, Anyways thanks in advance.
Try _FileListToArrayRec it is a new function from the UDFs. It should be very easy to use.
Notice:
As a example how to use the _FileListToArrayRec() function to save all found files in an array as mentioned. Please have a look in the help file for more details.
Code:
#include-once
#include <Array.au3>
#include <File.au3>
Global $sPathToSearch = #AppDataDir
Global $sFileExtension = 'txt' ; or '*' for all files or 'pdf' for just PDFs
Global $aFileList = _FileListToArrayRec( $sPathToSearch, '*.' & $sFileExtension, 1, 1, 0, 2 )
If IsArray( $aFileList ) Then _ArrayDisplay( $aFileList )

AutoIt - DllOpen ( "filename" ) failing i.e. It's returning -1

I've got AutoIt code as indicated here and I'm encountering issues with DLLOpen() on line 289 of the code i.e it is failing and returning -1.
I've read up here on what DllOpen() should be returning and I cannot figure out why it is failing.
I've also made sure my Dll file is in the same folder as my .exe file.
In addition I've also specified a specific file path to the Dll file.
Any ideas are greatly appreciated.
If it is working in Skype, it should work compiled.
Dont forget to
FileInstall ( "source", "dest" [, flag] )
Also dont forget about
FileChangeDir ( "path" ) ;Changes the current working directory.

Why does SQLite say it can't read SQL from a file?

I have a bunch of SQL in a file, which creates the tables and so forth. The problem is that the .read command simply returns "can't open xxx" when I try to execute it. I've set the permissions to everybody read/write, but that didn't help. I can cat the file from the command line and see it fine.
This is under Mac OS 10.6.3.
Anybody have any idea here? Thanks!
Here's the source code in shell.c, where the sqlite3 utility executes the .read and tries to read the .sql file:
if( c=='r' && strncmp(azArg[0], "read", n)==0 && nArg==2 ){
FILE *alt = fopen(azArg[1], "rb");
if( alt==0 ){
fprintf(stderr,"can't open \"%s\"\n", azArg[1]);
}else{
process_input(p, alt);
fclose(alt);
}
}else
You can see that the utility will print "can't open xxx" only when the call to fopen fails. Pity they don't print errno for you, but this info should really help you narrow down the problem as not specific to sqlite.
You're either specifying the path wrong (try quoting it), you don't have permission, or the file really doesn't exist (meaning that there's something different in how you're using cat and .read, like the current directory is different).
Watch out for the ; at the end. .read does not like ;'s.

Resources