regarding on opening a custom file in notepad++ - autoit

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

Related

Opening RDP File With 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)

Check if window has focus with AutoIt

I wonder if it is possible to check to see if a window has focus in AutoIt. I have checked and not found much. I have tried using WinSetOnTop but this didn't seem to do anything so then I considered using WinActivate but this didn't seem to do what I need.
The reason I want to do this is because I have this application I am writing as a prank and I do not want the co-worker on whom I'm playing the prank to just ignore the window when it starts automatically. I am wanting to put a shortcut to it in the startup folder and we have several applications that run on startup and so I want mine to either always be on top or audibly shout rude words at the user if they try and ignore the application.
Is this possible and, if so, can you help me out because I am out of ideas.
Regardless of your motives, you may try WinWaitActive.
Syntax:
WinWaitActive ( "title" [, "text" [, timeout = 0]] )
Example that may be useful to try it out:
Func Example()
; Run Notepad
Run("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
WinWaitActive("[CLASS:Notepad]", "", 10)
; Wait for 2 seconds to display the Notepad window.
Sleep(2000)
; Close the Notepad window using the classname of Notepad.
WinClose("[CLASS:Notepad]")
EndFunc ;==>Example
Reference:
https://www.autoitscript.com/autoit3/docs/functions/WinWaitActive.htm

applescript - quicktime 7 audio (wav) export

I'm working on a script to help my workflow. My work involves sound design, and I often have to take videos and extract the audio. Regardless of the source/compression, I like it in .wav format - best quality, accepted by all audio editing software, and least overhead for playback in a live environment.
Currently, I use Quicktime Pro 7's Export feature for this task - the current Quicktime X doesn't export to .wav. Built into the OS, so instead of using a separate tool, I'm using QT.
I am using Automator to write a service - select the file, open it in QT, export as wav and save it in the same location as the original, then quit. Here is what I have so far, and I keep getting an error. "The action “Run AppleScript” encountered an error." It compiles properly, but nothing comes out. Late last night I got it to spit out .mov files for some reason (despite trying to tell it wave) and now I can't even get back there.
Any help is appreciated. As you can see from the commented parts, I was trying to specify anywhere, since trying to make it the same location as the original was escaping me. Currently I'm just having it prompt me on where to save, so I can just tackle one problem at a time. Cheers!
tell application "QuickTime Player 7"
--set saveFile to POSIX path of (((path to desktop) as Wave) & "test.wav")
set outfile to choose file name with prompt "Save altered file here:"
set error_states to {load state unknown, load error}
set successful_states to {loaded, complete}
repeat until load state of first document is in (error_states & successful_states)
delay 0.1
end repeat
tell document to save in outfile
if (load state of first document is in successful_states) then
if (can export first document as wave) then
export first document to outfile as wave
else
error "Cannot export " & (source_file as string) & " in .wav (Wave) format."
end if
else
error "File is not in a successful load state: " & (load state of first document as string)
end if
end tell
The file output should have '.wav" extension. To do so, I changed a bit your script and I remove the "tell document to save in outfile".
if you really want to delete your initial file after export, you need to add that at end of the script (I prefer to check the export is successful before deletion !).
Also, you must change the first line to replace the choose file (for my tests) to the read input variable from Automator service script :
set InFile to choose file "select video file for test only" -- to be replace by the input of your Automator Service
-- conversion of selected file with proper folder and new '.wav" extension
tell application "Finder"
set FFolder to (container of InFile) as string
set FName to name of InFile
set FExt to name extension of InFile
end tell
set Pos to offset of FExt in FName
if Pos > 0 then --change extension from current to 'wav'
set OutFile to FFolder & (text 1 thru (Pos - 1) of FName) & "wav"
else
set OutFile to FFolder & FName & ".wav"
end if
tell application "QuickTime Player 7"
activate
open InFile
set error_states to {load state unknown, load error}
set successful_states to {loaded, complete}
repeat until load state of first document is in (error_states & successful_states)
delay 0.1
end repeat
if (load state of first document is in successful_states) then
if (can export first document as wave) then
export first document to OutFile as wave
else
error "Cannot export " & (source_file as string) & " in .wav (Wave) format."
end if
else
error "File is not in a successful load state: " & (load state of first document as string)
end if
end tell

autoencode in notepad ++

Very often i need to encode text file from UCS-2 Little Endian to ANSI and save it with the same name. Is it possible to automate this process ? For example to run Notepade ++ with the parameters , or use special script ?
I have done this on 5000+ files. I used AutoHotKey to send keystrokes
in file list window, press enter on filename so it gets open in Notepad++
after Notepad++ gets activated and ready, trigger the conversion
close document in Notepad++
switch back to file list window
send down arrow to proceed to next line
I have temporarily disabled syntax coloring (I had Visual Basic files) to get files open faster.
My macro (WinKey+F5) using file list in Total Commander (instead of Windows Explorer) was:
SendMode Input
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
#F5::
KeyWait,AppsKey
Loop, 10 {
MouseGetPos, xpos, ypos
If (xpos == 0)
Break
Send {F4}
WaitNPP:
Sleep, 20
IfWinNotActive, .*Notepad
;MsgBox nax
Goto, WaitNPP
Send !c
WaitDialog:
Sleep, 50
IfWinNotActive, .*Column
Goto, WaitDialog
Send {Esc}
Sleep, 50
Send ^+{F8}^s^w
;!+F8 was created as custom shortcut in N++
Sleep, 100
Send #1
WaitTC:
Sleep, 20
IfWinNotActive, .*Commander
Goto, WaitTC
Send {Down}
;Run C:\Tools\notifu.exe /p "Conversion to UTF-8" /m "1 of 10" /d 500
;Sleep, 500
}
Return
The loop is set to process 10 files.
Inside Notepad++ I triggered conversion by pressing Ctrl+Alt+Shift+F8 which I defined inside the Notepad++ in settings.

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