Jump to content
Sign in to follow this  
nguyenbason

[Resolved] How to check startup param?

Recommended Posts

nguyenbason

I have following code:

#include <File.au3>
#Include <Array.au3>

Opt("GUIoneventmode",1)
HotKeySet("{ESC}","_exit")

;Check startup param for default action
If $CmdLine[$CmdLine[0]] <> "0" Then
    $GetEXT = StringSplit($CmdLine[$CmdLine[0]],"\")
    $Ext = StringSplit($GetEXT[$GetEXT[0]],".")
    If $Ext[$Ext[0]] = "txt"Then
        _Open($CmdLine[$CmdLine[0]])
    EndIf
EndIf

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test fuction", 153, 73, -1, -1)
$Button = GUICtrlCreateButton("Open File", 20, 24, 113, 25)
GUICtrlSetOnEvent(-1,"_Read")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1 
    Sleep(100)
WEnd

Func _Read()
    $File = FileOpenDialog("Open a file",@MyDocumentsDir,"Text file only (*.txt)")
    _Open($File)
EndFunc

Func _Open($FileName)
    Dim $aArray
     _FileReadToArray($FileName,$aArray)
    _ArrayDisplay($aArray)
EndFunc

Func _Exit()
    Exit
EndFunc

But if i click on a text file and choose "Open with" with my program then how can i set it default action is _Open()?

Thanks,

Edited by nguyenbason

UnderWorldVN- Just play the way you like it

Share this post


Link to post
Share on other sites
November

Code please


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
nguyenbason

Code please

Edited on the first post. Check it out please. Hope you are all understanding my question. Thanks


UnderWorldVN- Just play the way you like it

Share this post


Link to post
Share on other sites
nguyenbason

Resolved by adding following code at the nearly top of the code (Edited to first post) to check command line param:

If $CmdLine[$CmdLine[0]] <> "0" Then
    $GetEXT = StringSplit($CmdLine[$CmdLine[0]],"\")
    $Ext = StringSplit($GetEXT[$GetEXT[0]],".")
    If $Ext[$Ext[0]] = "txt"Then
        _Open($CmdLine[$CmdLine[0]])
    EndIf
EndIf

Thanks for your attention

Edited by nguyenbason

UnderWorldVN- Just play the way you like it

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.