Sign in to follow this  
Followers 0
PantZ4

Why won't this script word?

14 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



There's a missing EndIf after your last Else.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

There's a missing EndIf after your last Else.

A typo... :P Oops :">

Edit: It still don't work... :nuke:

Edited by Mr. Zero

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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"?

[center]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.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I got it to work :nuke: , but all I have done is put into a variable. Like:

$installed = IniRead($installpath & "\test.ini", "test", "Installed ", " 0")
                if $installed = 0 Then

So now it works... and I leved happily... :)

And I have leaned some new things :P .

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