Jump to content

Comparing string to item in array


Go to solution Solved by Werty,

Recommended Posts

Posted

I remade my post because my first post was formatted wrong and it was stupid. This should be easier. (why does the website not allow deleting posts?!)

I'm trying to find out why this returns Restart when the input is anything except shutdown. it can be Google or Chrome or Google Chrome or even something random but still returns Restart. If the input is shutdown it runs shutdown normally.

#include <Constants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>


Local $a, $b, $c, $d
Local $aFileList = _FileListToArray("C:\Users\333el\Dropbox\IFTTT", Default, Default, True)

aLoop()
Func aLoop()
Local $aFileList = _FileListToArray("C:\Users\333el\Dropbox\IFTTT", Default, Default, True)
    While @error = 4
        Sleep(3000)
        $aFileList = _FileListToArray("C:\Users\333el\Dropbox\IFTTT", Default, Default, True)
    WEnd
    arun()
EndFunc




Func arun()
    $aFileList = _FileListToArray("C:\Users\333el\Dropbox\IFTTT", Default, Default, True)
    _PathSplit($aFileList[1], $a, $b, $c, $d)
    MsgBox($MB_SYSTEMMODAL, "Test", "Found: " & $c)
    If $c == "shutdown" Then
        FileDelete($aFileList[1])
        MsgBox($MB_SYSTEMMODAL, "Test", "Shutdown")
        ;Shutdown(1)
        Exit
    ElseIf $c == "reboot" or "restart" Then
        FileDelete($aFileList[1])
        MsgBox($MB_SYSTEMMODAL, "Test", "Restart")
        ;Shutdown(2)
        Exit
    ElseIf $c == "Google" or "Chrome" or "Google Chrome" then
        FileDelete($aFileList[1])
        ShellExecute("chrome.exe", "http://URL1 --new-window --start-fullscreen")       
    Else
        FileDelete($aFileList[1])
        aLoop()
    EndIf
EndFunc

 

  • Solution
Posted
ElseIf $c == "reboot" or "restart" Then

That doesnt look right, should be something like...

ElseIf $c = "reboot" or $c = "restart" Then

So all in all, untested obviously...

Func arun()
    $aFileList = _FileListToArray("C:\Users\333el\Dropbox\IFTTT", Default, Default, True)
    _PathSplit($aFileList[1], $a, $b, $c, $d)
    MsgBox($MB_SYSTEMMODAL, "Test", "Found: " & $c)
    If $c = "shutdown" Then
        FileDelete($aFileList[1])
        MsgBox($MB_SYSTEMMODAL, "Test", "Shutdown")
        ;Shutdown(1)
        Exit
    ElseIf $c = "reboot" or $c = "restart" Then
        FileDelete($aFileList[1])
        MsgBox($MB_SYSTEMMODAL, "Test", "Restart")
        ;Shutdown(2)
        Exit
    ElseIf $c = "Google" or $c = "Chrome" or $c = "Google Chrome" then
        FileDelete($aFileList[1])
        ShellExecute("chrome.exe", "http://URL1 --new-window --start-fullscreen")       
    Else
        FileDelete($aFileList[1])
        aLoop()
    EndIf
EndFunc

== is for case sensitivity. use single =

Some guy's script + some other guy's script = my script!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...