Jump to content

Why won't this script word?


PantZ4
 Share

Recommended Posts

I have a script there should look and see about it has been installed

Like:

While 1
   $msg = GUIGetMsg()

   Select
   
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $passwordexit
         GUIDelete()
         Exit
     Case $msg = $passwordenter
         If GUICtrlRead($passwordtext) = $password Then
            if IniRead($installpath & "\test.ini", "test", "Installed ", " 0") Then
;               Do something
                IniWrite($installpath & "\test.ini", "test", "Installed ", " 1")
            Else
                $iMsgBoxAnswer = MsgBox(8240,"Is Installed","test is installed on this computer.",3)
            EndIf
         Else
             If GUICtrlRead($passwordtext) = $removepassword then
                 if IniRead($installpath & "\test.ini", "test", "Installed ", " 1") Then
                     IniDelete($installpath & "\test.ini", "test", "Installed ")
                     IniWrite($installpath & "\test.ini", "test", "Installed ", " 0")
                Else
                    $iMsgBoxAnswer = MsgBox(8240,"Not Installed","test is not installed on this computer.",3)
                EndIf               
             Else
             Endif
        EndIf
    
EndSelect

WEnd

Oh and $installpath is @DesktopCommonDir

But I can't see why it won't work... :P

Any ideas? :nuke:

Thank you :)

Edit: Oops title is worng (word = work) :D

~Mr. Zero

Edited by Mr. Zero
Link to comment
Share on other sites

Hi,

where is the rest of the script?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

where is the rest of the script?

So long,

Mega

The rest? There is only $ and exit in the "rest"...

Here is a hole copy.

#include <GuiConstants.au3>

Global $passwordwindow
Global $password = "1"
Global $removepassword = "2"
Global $msg
Global $passwordenter
Global $passwordexit
Global $passwordtryies = 0
Dim $iMsgBoxAnswer
Global $installpath = @DesktopCommonDir

$passwordwindow = GUICreate("Test",190,120,(@DesktopWidth-190)/2, (@DesktopHeight-105)/2)
$passwordtext = GUICtrlCreateInput("",20,30,150,20,$es_password)
$passwordenter = GUICtrlCreateButton("Enter",15,70,75,20,$BS_DEFPUSHBUTTON)
$passwordexit = GUICtrlCreateButton("Exit",100,70,75,20)
GuiSetState()

While 1
   $msg = GUIGetMsg()

   Select
   
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $passwordexit
         GUIDelete()
         Exit
     Case $msg = $passwordenter
         If GUICtrlRead($passwordtext) = $password Then
            if IniRead($installpath & "\test.ini", "test", "Installed ", " 0") Then
                GUIDelete($passwordwindow)
                IniWrite($installpath & "\test.ini", "test", "Installed ", " 1")
                Exit
            Else
                $iMsgBoxAnswer = MsgBox(8240,"Is Installed","test is installed on this computer.",3)
            EndIf
         Else
             If GUICtrlRead($passwordtext) = $removepassword then
                if IniRead($installpath & "\test.ini", "test", "Installed ", " 1") Then
                    IniDelete($installpath & "\test.ini", "test", "Installed ")
                    IniWrite($installpath & "\test.ini", "test", "Installed ", " 0")
                    Exit
                Else
                    $iMsgBoxAnswer = MsgBox(8240,"Not Installed","test is not installed on this computer.",3)
                EndIf               
             Else
                 $passwordtryies = $passwordtryies + 1
                 if $passwordtryies = 3 Then
                     GUIDelete()
                     MsgBox(16,"Password Protection","Worng password three times. Closeing...",5)
                     Exit
                 Else
                     $iMsgBoxAnswer = MsgBox(8240,"Wrong password","You have typed a worng password.",3)
             EndIf
             
             EndIf
        EndIf
    
EndSelect

WEnd
Edited by Mr. Zero
Link to comment
Share on other sites

Hi,

okay now we've got the code, but where is the problem?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

Hi,

okay now we've got the code, but where is the problem?

So long,

Mega

I was thinking the same thing... It works as expected to me... But I do have a question... why are you putting a space in the IniRead()/Write()... " 0"/" 1"?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hi,

okay now we've got the code, but where is the problem?

So long,

Mega

Well if you try the script you will see you can type 1 first time and selcet the button "Enter", so the script will "install" the .ini.

After that you can run the program aging and type 1 aging and aging it will "install".

But it is not that i want, I want the script tells me: "test is installed on this computer"

so.... :P

@SmOke N

I did't like the way it was set up in the ini file

Like:

[test]

Installed=(Number)

I like with space... lol :nuke:

Edited by Mr. Zero
Link to comment
Share on other sites

  • Moderators

Well if you try the script you will see you can type 1 first time and selcet the button "Enter", so the script will "install" the .ini.

After that you can run the program aging and type 1 aging and aging it will "install".

But it is not that i want, I want the script tells me: "test is installed on this computer"

so.... :P

@SmOke N

I did't like the way it was set up in the ini file

Like:

[test]

Installed=(Number)

I like with space... lol :nuke:

Look at your logic... You Delete the GUI on the first go around, then you want it to GUICtrlRead() the 2nd time a GUI that isn't there anymore... Change up your logic to something different and it will work.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Look at your logic... You Delete the GUI on the first go around, then you want it to GUICtrlRead() the 2nd time a GUI that isn't there anymore... Change up your logic to something different and it will work.

I mean

Run the script then type 1 and press the enter button.

When the script will "install" a ini file on your desktop and the program close it self.

When run the script aging and type 1 and press the enter button.

(And this is the part there is not working)

It will "install" the ini file... Aging, and that is not what I want.

Insted of "install" it aging, it should show a msgbox there says "Test is allready installed on this computer"

and close the program...

And you can do this to with the "remove" function. Even without have "installed" it, which should show a msgbox there say "Test is not installed on this computer"

I'm sorry for being unclear in my first post... :P:nuke:

Link to comment
Share on other sites

try to replace:

if IniRead($installpath & "\test.ini", "test", "Installed ", " 0") ThenoÝ÷ Ú)ß»-q«Ýý²)©'"µê®ö¥z{m¡«­¢+Ù¥%¹¥I ÀÌØí¥¹Íѱ±ÁÑ µÀìÅÕ½ÐìÀäÈíÑÍй¥¹¤ÅÕ½Ðì°ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ±ÅÕ½Ðì°ÅÕ½ÐìÀÅÕ½Ð줱ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡

which is not what you want, is it?

Edited by Zedna
Link to comment
Share on other sites

1.

if IniRead($installpath & "\test.ini", "test", "Installed ", " 0") = " 0" ThenoÝ÷ Ù8b²ÞÉè·
+;§î¶+ZÊËÊÈ­Ê®¢Ø§²Ö¥çjºvjëh×6if IniRead($installpath & "\test.ini", "test", "Installed ", " 0") <> " 0" Then

This one is not working too. aging dunno, this is the old problem aging...

Maybe I'm a :). and can't this to work :P . But thank you for helping. Maybe you got it to work? If please show how you did it :nuke: ... Cause i'm a :D .

Edited by Mr. Zero
Link to comment
Share on other sites

Maybe I'm a :). and can't this to work :P . But thank you for helping. Maybe you got it to work? If please show how you did it :nuke: ... Cause i'm a :D .

But i'm still the :lol: of the world.

I didn't tested anything, only gave you corrected bad syntax & logic of your script.

My advice is: Look into AutoIt HelpFile for details about IniRead (and search forum for examples) and try some debugging - what values it gives you...

Bye

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