Jump to content

TrayCreateItem questions


 Share

Go to solution Solved by TrickyDeath,

Recommended Posts

Hello everyone,

i do have a simple question what i do not realy understand what hapend and why.

I did made a small program, what is converting Valuta prices to other type, cause i got tired of use all the time google for it. After that i "convert" it into an exe file. All the Valute prices are in INI file, and work perfect.

I did made another small script (Tray menu) and then when i click on the proper TrayItem it should run the Valute exchanger exe file, but something is wrong. The exe is running, but when i calculate with it, it give me only 0 resoults. If i run the exe manualy it is work properly. How does it come, from Tray menu item wont work, and from manualy run it work hot it have to work?

Case $iValutaCalculator
            Run("C:\Users\asd\Desktop\EU_USD.exe")

Best Regards,

Tricky

Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Link to comment
Share on other sites

You must realize that you haven't given us nearly enough information to answer this question? You need to post your code, or at least a reproducer script that demonstrates what you're doing and that shows the same problem. One run command isn't going to do it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

TrickyDeath,

Without sight of the 2 scripts it is difficult to say much. But do you display the result within the EU_USD file - or are you expecting the calling script to do this? If the latter, how are you passing the necessary data between the two processes? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Solution

Sorry, both of you have right. At work i take a look on the source code, cause i could saw the calculator can not see the INI file somehow.

Problem solved after i insert @ScriptDir infront of the ini file in IniRead.

Source Codes TrayMenu:

#include <MsgBoxConstants.au3>
#NoTrayIcon

Opt("TrayMenuMode", 3)

TraySetState(1)
TraySetToolTip("Programs")

Local $iAddons = TrayCreateMenu("Addons")
Local $iValutaCalculator = TrayCreateItem("Valuta Calculator", $iAddons)
Local $iCalculator = TrayCreateItem("Calculator", $iAddons)
Local $iNotepad = TrayCreateItem("Notepad", $iAddons)
Local $iExcel = TrayCreateItem("Excel", $iAddons)
TrayCreateItem("")
Local $iAbout = TrayCreateItem("About")
TrayCreateItem("")
Local $iExit = TrayCreateItem("Exit")

TraySetState(1)

While 1
    Switch TrayGetMsg()
Case $iValutaCalculator
            Run(@DesktopDir & "\EU_USD.exe")

        Case $iCalculator
            Run(@SystemDir & "\calc.exe")

        Case $iNotepad
            Run(@SystemDir & "\notepad.exe")

        Case $iExcel ;@ProgramFilesDir
            Run("c:\Program Files (x86)\Microsoft Office\Office\EXCEL.EXE")
                Case $iExit
            Exit
    EndSwitch
WEnd

Source of calculator:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>

$myForm = GUICreate("Change EU - USD - GBP", 610, 125)

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$EUROtoEURO = IniRead(@ScriptDir & "\ValutaPrices.ini", "EURO", "EURO", "0")
$EUROtoUSD = IniRead(@ScriptDir & "\ValutaPrices.ini", "EURO", "USD", "0")
$EUROtoGBP = IniRead(@ScriptDir & "\ValutaPrices.ini", "EURO", "GBP", "0")

$USDtoEURO = IniRead(@ScriptDir & "\ValutaPrices.ini", "USD", "Euro", "0")
$USDtoUSD = IniRead(@ScriptDir & "\ValutaPrices.ini", "USD", "USD", "0")
$USDtoGBP = IniRead(@ScriptDir & "\ValutaPrices.ini", "USD", "GBP", "0")

$GBPtoEURO = IniRead(@ScriptDir & "\ValutaPrices.ini", "GBP", "EURO", "0")
$GBPtoUSD = IniRead(@ScriptDir & "\ValutaPrices.ini", "GBP", "USD", "0")
$GBPtoGBP = IniRead(@ScriptDir & "\ValutaPrices.ini", "GBP", "GBP", "0")

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$LabelFrom = GUICtrlCreateLabel("From :", 10, 30)
$LabelAmount = GUICtrlCreateLabel("Amount :", 130, 30)
$LabelValuta = GUICtrlCreateLabel("To :", 250, 30)
$LabelPrice = GUICtrlCreateLabel("Price :", 370, 30)

$SelectValuta_From = GUICtrlCreateCombo("", 10, 55, 115, 40)
$Amount = GUICtrlCreateInput("0", 130, 55, 115, 40)
$SelectValuta = GUICtrlCreateCombo("", 250, 55, 115, 40)
$Price = GUICtrlCreateInput("", 370, 55, 100, 40, $ES_READONLY)

$Btn_Calculate = GUICtrlCreateButton("Calculate", 480, 55, 120, 40)

GUICtrlSetFont($SelectValuta, 16)
GUICtrlSetFont($SelectValuta_From, 16)
GUICtrlSetFont($Amount, 16)
GUICtrlSetFont($Price, 16)
GUICtrlSetFont($Btn_Calculate, 16)

GUICtrlSetData($SelectValuta_From, "EURO|USD|GBP", "EURO")
GUICtrlSetData($SelectValuta, "EURO|USD|GBP", "EURO")
GUICtrlSetBkColor($Price, 0xFFFFFF)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit

    Switch $msg
        Case $Btn_Calculate
            $ReadAmount = GUICtrlRead($Amount)
            $ReadValuta_From = GUICtrlRead($SelectValuta_From, 1)
            $ReadValuta = GUICtrlRead($SelectValuta, 1)

            If $ReadValuta_From = "EURO" And $ReadValuta = "EURO" Then
                GUICtrlSetData($Price, $ReadAmount * $EUROtoEURO)
            EndIf

            If $ReadValuta_From = "EURO" And $ReadValuta = "USD" Then
                GUICtrlSetData($Price, $ReadAmount * $EUROtoUSD)
            EndIf

            If $ReadValuta_From = "EURO" And $ReadValuta = "GBP" Then
                GUICtrlSetData($Price, $ReadAmount * $EUROtoGBP)
            EndIf

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

            If $ReadValuta_From = "USD" And $ReadValuta = "EURO" Then
                GUICtrlSetData($Price, $ReadAmount * $USDtoEURO)
            EndIf

            If $ReadValuta_From = "USD" And $ReadValuta = "USD" Then
                GUICtrlSetData($Price, $ReadAmount * $USDtoUSD)
            EndIf

            If $ReadValuta_From = "USD" And $ReadValuta = "GBP" Then
                GUICtrlSetData($Price, $ReadAmount * $USDtoGBP)
            EndIf

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

            If $ReadValuta_From = "GBP" And $ReadValuta = "EURO" Then
                GUICtrlSetData($Price, $ReadAmount * $GBPtoEURO)
            EndIf

            If $ReadValuta_From = "GBP" And $ReadValuta = "USD" Then
                GUICtrlSetData($Price, $ReadAmount * $GBPtoUSD)
            EndIf

            If $ReadValuta_From = "GBP" And $ReadValuta = "GBP" Then
                GUICtrlSetData($Price, $ReadAmount * $GBPtoGBP)
            EndIf
    EndSwitch
WEnd

Maybe the way, how i made it, is kinda prehistoric, but work fine. >_<

I could put them in an array... :/

Edit:

It was just like this:

$EUROtoEURO = IniRead("ValutaPrices.ini", "EURO", "EURO", "0")

Cause the exe and the INI was next to each others, but still do not understand why did not work, if i run it from that TrayMenu and why did it work if i just run the calculator itself. Somehow loesing the dir path or something?

I am just guessing, cause i am still just a newbie in programing / scripting.

Edited by TrickyDeath

Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Link to comment
Share on other sites

Does it posible to somehow set the traymenu "slide/open" side? Cause it is seams ugly, when it is open to left side, then submenu open to right side, and cover the main menu. Just ugly. :)

Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Link to comment
Share on other sites

another way to solve this would have been the set the WorkingDir parameter in Run in your traymenu code

Ohh BTW the problem was not that the run order not run the calculator, the problem was, after it run, the calculator wont see anymore the INI file, where are the prices stored. :/

Still do not know why it is that.

Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Link to comment
Share on other sites

Ohh BTW the problem was not that the run order not run the calculator, the problem was, after it run, the calculator wont see anymore the INI file, where are the prices stored. :/

Still do not know why it is that.

 

When you don't specify a full path the working directory will be used, and it was obviously not where you needed it to be. So in this case you fixed it by giving the full path, but setting the right working directory as jguinch said would have also worked.

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

×
×
  • Create New...