Sign in to follow this  
Followers 0
Tukata

Shortcut problem

5 posts in this topic

#1 ·  Posted (edited)

Hi,

I created a shortcut to autoit app in:

C:\Documents and Settings\All Users\Start Menu\Programs\Startup

The app is a simple Listbox which upload items from a text file located in the same folder. When I run the shortcut I get a message that "Unable to open the txt file" and app exits. The app itself run with no problem when run the exe.

Any idea ?

Thank you

Tuk

Edited by Tukata

Share this post


Link to post
Share on other sites



Please post your source code. I am having difficulty understanding what the program is doing.


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Here is my full script. It works fine if run but after creating the shortcut, if run from the shortcut, it can not find the "Data.txt" file (which is just a file with few lines).

Thank you

Tuk

#include <GUIConstants.au3>
#Include <GuiList.au3>
#include <IE.au3>
#NoTrayIcon
Opt("TrayMenuMode", 1)

$Shortcut=@StartupCommonDir & "\APP.lnk"
If FileExists($Shortcut) Then
Else
FileCreateShortcut(@ScriptDir & "\APP.exe",@StartupCommonDir & "\APP.lnk")
EndIf

GUICreate("APP", 300, 110)
$_List =GUICtrlCreateList ("", 0,0,300,94,$WS_BORDER + $WS_VSCROLL)
$Button = GUICtrlCreateButton ( "Send to Tray",  5, 86, 120, 22)
$ButtonURL = GUICtrlCreateButton ( "Web Site",  175, 86, 120, 22)

$Show= TrayCreateItem("Show")
TrayCreateItem("")
$Hide= TrayCreateItem("Hide")
TrayCreateItem("")
$about = TrayCreateItem("About")
TrayCreateItem("")
$exit = TrayCreateItem("Exit")
TrayCreateItem("")

TraySetState()

$file = FileOpen("Data.txt", 0)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open Data txt file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
  ;MsgBox(0, "Line read:", $line)
GUICtrlSetData($_List,$line,"NO_DEFUALT")
Wend

FileClose($file)

GUISetState ()

While 1
    $xmsg = GUIGetMsg()
    if $xmsg = $_List then
       $h=GUICtrlRead($_List)
       ClipPut ($h)
   endif

    $msg = TrayGetMsg()
    Select
        Case $xmsg = $Button
            WinSetState("APP", "", @SW_HIDE)
        Case $xmsg = $ButtonURL
         $oIE = _IECreate ("http://www.xxx.com/")
        Case $xmsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Hide
            WinSetState("APP", "", @SW_HIDE)
        Case $msg = $Show
            WinSetState("APP", "", @SW_SHOW)
        Case $msg = $about
            Msgbox(64,"APP","Text")
        Case $msg = $exit
            ExitLoop
    EndSelect
WEnd

Exit
Edited by Tukata

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#Include <GuiList.au3>
#include <IE.au3>
#NoTrayIcon
Opt("TrayMenuMode", 1)

$Shortcut=@StartupCommonDir & "\APP.lnk"
If FileExists($Shortcut) Then
Else
FileCreateShortcut(@ScriptDir & "\APP.exe",@StartupCommonDir & "\APP.lnk")
EndIf

GUICreate("APP", 300, 110)
$_List =GUICtrlCreateList ("", 0,0,300,94,$WS_BORDER + $WS_VSCROLL)
$Button = GUICtrlCreateButton ( "Send to Tray",  5, 86, 120, 22)
$ButtonURL = GUICtrlCreateButton ( "Web Site",  175, 86, 120, 22)

$Show= TrayCreateItem("Show")
TrayCreateItem("")
$Hide= TrayCreateItem("Hide")
TrayCreateItem("")
$about = TrayCreateItem("About")
TrayCreateItem("")
$exit = TrayCreateItem("Exit")
TrayCreateItem("")

TraySetState()

$file = FileOpen( @ScriptDir & "Data.txt", 0); Try that

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open Data txt file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
  ;MsgBox(0, "Line read:", $line)
GUICtrlSetData($_List,$line,"NO_DEFUALT")
Wend

FileClose($file)

GUISetState ()

While 1
    $xmsg = GUIGetMsg()
    if $xmsg = $_List then
       $h=GUICtrlRead($_List)
       ClipPut ($h)
   endif

    $msg = TrayGetMsg()
    Select
        Case $xmsg = $Button
            WinSetState("APP", "", @SW_HIDE)
        Case $xmsg = $ButtonURL
         $oIE = _IECreate ("http://www.xxx.com/")
        Case $xmsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Hide
            WinSetState("APP", "", @SW_HIDE)
        Case $msg = $Show
            WinSetState("APP", "", @SW_SHOW)
        Case $msg = $about
            Msgbox(64,"APP","Text")
        Case $msg = $exit
            ExitLoop
    EndSelect
WEnd

Exit

http://www.xxx.com/ - Makes me wonder

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Chip

Thank you. Almost but I made it run. It should be:

$file = FileOpen(@ScriptDir & "\Data.txt", 0)

As for xxx.com.. well.... sorry for that,

just wrote xxx without knowing there is a real web site behind it. :whistle:

Tuk

Edited by Tukata

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  
Followers 0