Jump to content

[Resolved] How to check startup param?


Recommended Posts

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
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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
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...