How to make a file (.jkl extension for example) that when you open it, your custom program will pop-up.
For example:
I have a test.jkl file
If i double-click it, my program will be the one to read it.
Just like a .jpg file extension, when double-clicking the file, paint will pop-up and shows the image.
My code when changing the file ext is just simple
File.Copy(origFile, origFile.Replace("txt", "jkl")
File.Delete(origFile)
So now i have a .jkl file, now what I need to do is when the user double clicks the .jkl file, this program will automatically open, ask where to save it, and change it back to .txt to the path where the user wants to.
How can I do this?
Put it the form load event. it will write again and again. It won't destroy your PC. If you want to more carefully. Read registry check if it is exist then skip write again.
Code:
My.Computer.Registry.ClassesRoot.CreateSubKey(".jkl").SetValue_
("", "jkl", Microsoft.Win32.RegistryValueKind.String)
My.Computer.Registry.ClassesRoot.CreateSubKey_
("jkl\shell\open\command").SetValue("", Application.ExecutablePath & _
" ""%l"" ", Microsoft.Win32.RegistryValueKind.String)
link for demo project: http://www.codeproject.com/Articles/18594/File-Association-in-VB-NET
I don't think code is required. Once the file is saved as .jkl, right click the file and select the option "open with" -> "Choose default program" -> then browse to the exe you have written to save the file as .txt file.
If open with option is not available double click the file and select the option to select default program. Now browse to your exe.
The command line parameter args[0] is the file full name.
I have tried with C# code same can be done with VB code.
static void Main(string[] args)
{
Console.WriteLine("0: " + args[0]);
//Code to rename the file
Console.WriteLine("Done. Press enter");
Console.ReadKey();
}
VB Code using online converter
Private Shared Sub Main(args As String())
Console.WriteLine("0: " + args(0))
'Code to rename the file
Console.WriteLine("Done. Press enter")
Console.ReadKey()
End Sub
Related
Is there an API to show a dialog that allows the user to browse/create folders and either pick an already existing file or enter the name for a new one in order to save some metadata.
Something like the "Save As" dialog in Photoshop but without actually saving anything, but just retrieve the path and filename entered by the user.
Not sure about a specific API, but is this the sort of thing you're looking for?
var inFolder = Folder.selectDialog("Please select folder to process");
if (inFolder != null)
{
var fileList = inFolder.getFiles(/\.(png)$/i);
}
or
var filterFiles = 'CSV:*.csv'; // I am windows
theFile = File.openDialog ("Choose the CSV file to load from" , filterFiles);
Whereas you can reference theFile or fileList to get the file or path you're after.
I am trying to access the file upload element from a webpage and handle it to upload a file and click on submit for processing. Please tell me how to handle the file upload dialog boxes? Also when using the code, it got struck-ed in the find element module itself. What can i do for that?
driver.findElement(By.id("SWFUpload_0")).click();
Robot r = new Robot();
r.keyPress(KeyEvent.VK_C); // C
r.keyRelease(KeyEvent.VK_C);
r.keyPress(KeyEvent.VK_COLON); // : (colon)
r.keyRelease(KeyEvent.VK_COLON);
r.keyPress(KeyEvent.VK_SLASH); // / (slash)
r.keyRelease(KeyEvent.VK_SLASH);
// etc. for the whole file path
r.keyPress(KeyEvent.VK_ENTER); // confirm by pressing Enter in the end
r.keyRelease(KeyEvent.VK_ENTER);
I am trying to use AutoIt for Windows file upload. I am clicking a browse button which will open file upload popup. I want AutoIt to type the location of the file and click open.
I need to use FF, Chrome, and IE for testing. I am able to get this to work if I use the Title, but the problem is that each browser has a different title. I would like to use class, as it is #32700 for all browsers. I've tried using class instead of the title, but its not working.
When I use title, everything works fine. Below is an example for Firefox. In this script, the file name is entered and open is clicked.
ControlFocus("File Upload","","Edit1")
ControlSetText("File Upload", "", "Edit1", "SomeFile.txt")
ControlClick("File Upload", "","Button1");
When I try to use class, text is not being entered and the open button is not getting clicked. There are no errors in the AutoIt script editor, so I'm not sure why this isn't working.
ControlFocus("[CLASS:#32770]","","Edit1")
ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")
ControlClick("[CLASS:#32770]", "","Button1");
I've also tried to add all three browser titles to 1 AutoIt script. The below script is working for Firefox and IE, but doesn't do anything in Chrome.
Local $OrgFile = "SomeFile.csv"
Local $ControlIDText = "Edit1"
Local $ControlIDButton = "Button1"
Local $Title_FF = "File Upload"
Local $Title_Chrome = "Open"
Local $Title_IE = "Choose File to Upload"
;Firefox Import
ControlFocus($Title_FF,"",$ControlIDText)
ControlSetText($Title_FF, "", $ControlIDText, $OrgFile)
ControlClick($Title_FF, "",$ControlIDButton);
;Chrome Import
ControlFocus($Title_Chrome,"",$ControlIDText)
ControlSetText($Title_Chrome, "", $ControlIDText, $OrgFile)
ControlClick($Title_Chrome, "",$ControlIDButton);
;IE Import
ControlFocus($Title_IE,"",$ControlIDText)
ControlSetText($Title_IE, "", $ControlIDText, $OrgFile)
ControlClick($Title_IE, "",$ControlIDButton);
You need to set WinTitleMatchMode option to 4 if you want to use advanced title matching (eg. CLASS).
#RequireAdmin ;Will give your script a permission elevation (sometimes its needed)
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
ControlFocus("[CLASS:#32770]","","Edit1")
ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")
ControlClick("[CLASS:#32770]", "","Button1");
I have an application, wherein I get a "Save As" dialog-box. At times, if a file exists with the same name, then another dialog box comes in, with the same name "Save As". The following is the code, which I wrote but it doesn't work as expected.
Global $sTitle = "Save As"
WinWait($sTitle)
WinWaitActive($sTitle)
ControlClick($sTitle, "Save", "[CLASS:Button; TEXT:&Save; INSTANCE:2]")
ControlSetText($sTitle, "", "CLASS:Button; INSTANCE:2]", $file_name)
SendKeepActive($sTitle)
Send("{ENTER}")
Sleep(4000)
WinWaitActive($sTitle,"",3)
If WinExists($sTitle, "No") Then Send("{ENTER}")
If WinExists("Exit OmniPeek") Then
Send("{ENTER}")
Else
Sleep(2000)
WinClose($closing_file)
EndIf
The idea is to check if the second "Save As" dialog box comes and if does come in, then over-write the existing file. This however, doesn't seem to be working with the autoit script that I wrote.
Can someone help me with this script? You can re-create the issue by using Notepad as well. Just have a file with a name abc.txt and try to save a file with the same name
You will get another dialog box with the name "Save As".
Try this:
Example()
Func Example()
; Run Notepad
Run("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
; Keep the Notepad window active when using the Send function.
SendKeepActive("[CLASS:Notepad]")
; Simulate entering a string of text. If you try to change to a different window other than Notepad, then the Notepad window will
; be brought to focus again.
For $i = 1 To 10
Sleep(5)
Send("notepad - ")
Next
; Disable the Notepad window being active when using the Send function.
SendKeepActive("")
; Close the Notepad window using the handle returned by WinWait.
WinClose($hWnd)
Send("{ENTER}") ; <<< SAVE
; Now a screen will pop up and ask to save the changes, the classname of the window is called
; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
WinWaitActive("[CLASS:#32770]", '', 2)
Sleep(50)
Send('newName.txt')
Sleep(1000)
Send("{TAB}{ENTER}")
EndFunc ;==>Example
I am creating a directory using Phonegap. I am getting success while using code. But I need to check where my folder is created. I found link they told these link.
/Users/UserName/Library/Application Support/iPhone Simulator/4.3.2/Applications
/Users/loginname/Library/Application Support/iPhone Simulator/6.1/Applications/YOUR_APP/Documents
But I don't have any iPhone simulator folder in application support? Where I will search?
I have Xcode 4.5 version
How to find android directory using the same code .i am able to in Ios
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail);
}
function onFileSystemSuccess(fileSystem) {
console.log(fileSystem.name);
var directoryEntry = fileSystem.root;
directoryEntry.getDirectory("newDir", {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail)
}
function onDirectorySuccess(parent) {
//alert("onSuccess")
console.log(parent);
// alert(parent+"Directory");
}
function onDirectoryFail(error) {
alert("Unable to create new directory: " + error.code);
}
function onFileSystemFail(evt) {
console.log(evt.target.error.code);
alert(evt.target.error.code);
}
The simplest solution is just copy the url
Go to the finder and press command + shift + G and paste your url and press Go
You don't need to enable hidden file.
make sure you're not searching for it because you will get the wrong application folder, you have to go to your "user name" folder and make it show hidden files and that will show the hidden library file so you can start navigating your way to that address... try that and anymore issues with it ill try and help further.
if you dont know how to open terminal go to search magnifying glass top right corner, click it and in the finder search bar type in terminal and press enter. a terminal window will pop up and after you copy this line " defaults write com.apple.Finder AppleShowAllFiles TRUE " copy that without the " " part. now right click "if you have a two buttton mouse " on that terminal window and click paste from the menu that pops up, now press enter. now last thing is to close all finder windows so copy this " killall Finder " without quotes and paste that in terminal and press enter...now your hidden folders will come up in your finder windows and the new faded hidden librarry folder will be under mac/users/"whatever ur username is "/