SaeidN

Select or Switch or If ?

16 posts in this topic

#1 ·  Posted (edited)

Hi,

I want to tell pixelsearch to search for red color shades in for example 5 different x,y,h,w of the screen. If color red was not found in these 5 area, then do something.

I wrote this, but it's working only if the first case is not found. Is select a good choice? or it's better to use switch or if or something else?

ٍEdit: all "do something"s are same function. (search for red color untill in these 5 areas, it couldnot find red color, then if it couldn't find red color, perform that 1 function)

Thanks

Select
        Case 1
            $color1 = PixelSearch(67, 614, 77, 617, 0xE62121, 10)
            If @error Then
                 do something...
            EndIf
        Case 2
            $color2 = PixelSearch(165, 614, 175, 617, 0xE62121, 10)
            If @error Then
                do something...
            EndIf
        Case 3
            $color3 = PixelSearch(265, 614, 275, 617, 0xE62121, 10)
            If @error Then
                do something...
            EndIf
        Case 4
            $color4 = PixelSearch(365, 614, 375, 617, 0xE62121, 10)
            If @error Then
                do something...
            EndIf
        Case 5
            $color5 = PixelSearch(465, 614, 475, 617, 0xE62121, 10)
            If @error Then
                do something...
            EndIf
    EndSelect

 

Edited by SaeidN

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think ContinueCase does this...

....moves on to the next Case.

Never used it though.

 

Edit or Case Else:

from the Help File

Select
        Case $iValue = 1
            MsgBox($MB_SYSTEMMODAL, "", "The first expression was True.")
        Case $sBlank = "Test"
            MsgBox($MB_SYSTEMMODAL, "", "The second expression was True")
        Case Else ; If nothing matches then execute the following.
            MsgBox($MB_SYSTEMMODAL, "", "No preceding case was True.")  ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    EndSelect
EndFunc   ;==>Example

 

Edited by l3ill

Share this post


Link to post
Share on other sites

I'm not sure if this is the cleanest option, but I found confortable doing this trough 2 Switches.

Test it and let me know if it works well ^_^

 

Local $x,$var
Local $color = "0xE62121"

Func DoSomething()
   ConsoleWrite("Doing something..."&@crlf)
EndFunc

Func DoNothing()
   ConsoleWrite("Doing nothing..."&@crlf)
EndFunc

For $x=0 to 4
   Switch $x
   Case 0
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(67, 614, 77, 617,$color,10)
   Case 1
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(165, 614, 175, 617,$color,10)
   Case 2
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(265, 614, 275, 617,$color,10)
   Case 3
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(365, 614, 375, 617,$color,10)
   Case 4
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(465, 614, 475, 617,$color,10)
   EndSwitch

   Switch @error
      Case True
      DoNothing()
      Case False
      DoSomething()
   EndSwitch
Next

 

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

6 hours ago, l3ill said:

I think ContinueCase does this...

....moves on to the next Case.

Never used it though.

 

Edit or Case Else:

from the Help File

Select
        Case $iValue = 1
            MsgBox($MB_SYSTEMMODAL, "", "The first expression was True.")
        Case $sBlank = "Test"
            MsgBox($MB_SYSTEMMODAL, "", "The second expression was True")
        Case Else ; If nothing matches then execute the following.
            MsgBox($MB_SYSTEMMODAL, "", "No preceding case was True.")  ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    EndSelect
EndFunc   ;==>Example

 

My other problem is what should I have in front of Case? 1-2-3 ? or something else? I think pixelsearch returns 0 only (not sure)

If nothing matches the cases, I want to exit the Select. 

Edited by SaeidN

Share this post


Link to post
Share on other sites

Not in front...

see post 3 from r3dbullo88 this should give you some ideas..

and of course the Help file :P

For instance Pixel search returns:

Return Value

Success: a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y).
Failure: sets the @error flag to 1 if the color is not found.

Share this post


Link to post
Share on other sites
3 hours ago, r3dbullo88 said:

I'm not sure if this is the cleanest option, but I found confortable doing this trough 2 Switches.

Test it and let me know if it works well ^_^

 

Local $x,$var
Local $color = "0xE62121"

Func DoSomething()
   ConsoleWrite("Doing something..."&@crlf)
EndFunc

Func DoNothing()
   ConsoleWrite("Doing nothing..."&@crlf)
EndFunc

For $x=0 to 4
   Switch $x
   Case 0
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(67, 614, 77, 617,$color,10)
   Case 1
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(165, 614, 175, 617,$color,10)
   Case 2
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(265, 614, 275, 617,$color,10)
   Case 3
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(365, 614, 375, 617,$color,10)
   Case 4
      ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf)
      $var = PixelSearch(465, 614, 475, 617,$color,10)
   EndSwitch

   Switch @error
      Case True
      DoNothing()
      Case False
      DoSomething()
   EndSwitch
Next

 

For this part:

 Switch @error
      Case True
      DoNothing()
      Case False
      DoSomething()

in case of True, I don't want it to do anything, So is it better to remove "Case True" part? or I can use exitloop or something similar?

All of these codes (that you wrote) are in a function.

Share this post


Link to post
Share on other sites

You can just remove Case True

1 person likes this

Share this post


Link to post
Share on other sites
24 minutes ago, r3dbullo88 said:

You can just remove Case True

It's working perfect, thanks.

Whole this function is in a loop. How can I tell the program that if you see "Case true (doing something)" then don't call that function again?

Thank you for the help 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

27 minutes ago, r3dbullo88 said:

You should add ExitLoop

While 1 
 ...
 ...
 ...
 
 Switch @error
      Case False
      DoSomething()
      ExitLoop
 EndSwitch

 

Because whole this codes are in a function, so it exits this function, but how can I do it in parent function, I want it to exit the parent funtion, How can I call this in parent funtion? something like: If thisfunc is done once, Then don't do it again.

Thanks again

Edited by SaeidN

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

The simplest method would be setting some sort of Variable to handle it.

Example:

Global $var = FALSE ;(Can be anything)

Func CrazyThings()
    $var = TRUE; We set $var to TRUE the first time the Func is called, then it will not be called anymore.
    ConsoleWrite("Crazy things happens once only.")
EndFunc

while 1
    If $var = FALSE Then ; Only call function if $var is FALSE
        CrazyThings()
    Else
        Sleep(1000)
        ConsoleWrite("Nothing happens."&@crlf)
    EndIf
wend

 

 

 

Edited by r3dbullo88

Share this post


Link to post
Share on other sites

Like this?

$FuncRun = 0
Example()
Example()
Example()

Func Example()
    If $FuncRun = 0 Then
        ; Run your Actual Function code here
        MsgBox(0,"1AndDone", "I'm Done")
    EndIf
    $FuncRun = 1
EndFunc

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

7 minutes ago, MuffinMan said:

Like this?

$FuncRun = 0
Example()
Example()
Example()

Func Example()
    If $FuncRun = 0 Then
        ; Run your Actual Function code here
        MsgBox(0,"1AndDone", "I'm Done")
    EndIf
    $FuncRun = 1
EndFunc

 

I've set a flag=0 in parent func, and in "case true" I changed the flag to 1. Then after calling this func, I wrote: if flag=1 then exitloop.

before this it was calling in loop, but with this flag it's calling 1 more time after the flag sets to 1. I don't know why.

 

Edit: I found it why, because I added "if flag=1 then exitloop" is in another loop in the parent func. So I don't know what to do with this. I wish there was a exitfunc.

Edited by SaeidN

Share this post


Link to post
Share on other sites

Post your code here, it's easier.

Share this post


Link to post
Share on other sites
2 minutes ago, r3dbullo88 said:

Post your code here, it's easier.

Func parentfunc()
    $flag = 0
    some codes...
    
    Do
        some codes...
        
        thisfunc()
        If $flag = 1 Then ExitLoop
        
        some codes...
    Until $result = 1
EndFunc

Func thisfunc()
    Local $x,$var
    Local $color = "0xE62121"

    For $x=0 to 4
       Switch $x
           Case 0
              $var = PixelSearch(67, 614, 77, 617,$color,10)
           Case 1
              $var = PixelSearch(165, 614, 175, 617,$color,10)
           Case 2
              $var = PixelSearch(265, 614, 275, 617,$color,10)
           Case 3
              $var = PixelSearch(365, 614, 375, 617,$color,10)
           Case 4
              $var = PixelSearch(465, 614, 475, 617,$color,10)
           EndSwitch

       Switch @error
           Case True
               some codes...
               $flag= 1
       EndSwitch
    Next
EndFunc

I want to run thisfunc() only once. When the flag = 1 then exit parentfunc().

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

This code will allow the parent function to run multiple times, but the child function will only run once

$flag = 0
$result = 0
parentfunc() ; Running the function 3 times to test
parentfunc()
parentfunc()

Func parentfunc()
    MsgBox(0,"Parent Func", "Parent Fumction is Running") ; Just for testing
    ;some codes...

    Do
        ;some codes...

        thisfunc()
        If $flag = 1 Then ExitLoop

        ;some codes...
        MsgBox(0,"Debug", "You should never see this text")
    Until $result = 1
EndFunc

Func thisfunc()
    Local $x,$var
    Local $color = "0xE62121"
    If $flag <> 1 Then
        MsgBox(0,"Child Function", "Child Function Will Only Run Once") ; Just for testing

        For $x=0 to 4
           Switch $x
               Case 0
                  $var = PixelSearch(67, 614, 77, 617,$color,10)
               Case 1
                  $var = PixelSearch(165, 614, 175, 617,$color,10)
               Case 2
                  $var = PixelSearch(265, 614, 275, 617,$color,10)
               Case 3
                  $var = PixelSearch(365, 614, 375, 617,$color,10)
               Case 4
                  $var = PixelSearch(465, 614, 475, 617,$color,10)
               EndSwitch

           Switch @error
               Case True
                   ;some codes...

           EndSwitch
        Next
    EndIf
    $flag= 1
EndFunc

 

Edited by MuffinMan

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

  • Similar Content

    • hcI
      By hcI
      Hello
      Today I'm working on listbox but there might be something that I'm missing...
      I made a little script that allow the user to swap 2 items for the listbox. So the user select for example the 3rd item, press the button "Up" and it switch with the 2nd one, same with the "Down" button that switch with the 4th one.
      But when I select the 3rd item and switch it the item become unselected and I would like to select it again after the manipulation :
      As you can see in the comment of the script, _GUICtrlListBox_SetSel don't highlight/select them once the swap process is done..
      What am I missing ?
    • Eli_jahbot
      By Eli_jahbot
      my esteemed autoits,
      i need your help once again. The bold and italics below are what i will be referring to. I need a message box to exit the script if Cancel is pressed and to continue the script if OK is pressed. I have tried multiple ways to do this to no avail. Can someone please breakdown how i go about this via Message box, and or Input box as I'm sure they will follow the same logic. I appreciate your time and assistance.
       
      Example:
      global $url, $username, $password, $sspassword
      $url = "https://securegateway.fairview.org"
      $username = "XXX"
      $password = "YYY"
      $sspassword = "ZZZ"
      #include <Constants.au3>
      #include <msgboxconstants.au3>
      ShellExecute ($url)
      WinWaitActive("window")
      send($username)
      send("{tab}")
      send($password)
      send("{enter}")
      msgbox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script")
      if($idok)
      send("+{tab 8}")
      send("{enter}")
      if ($idcancel) then Exit
      EndIf
    • Rimoun
      By Rimoun
      Hello everyone
      I would like to have some help regarding my issue.
      I am trying to extract some information from excel sheet, I use _Excel_RangeFind then I get the array for the value then I check the array. In case the array is true the next will be to get some information based on the extracted array if no array because the value is not found it gives a messages box that the value is not found.
      My problem that the button works for one time only if i tried any value which exist in the sheet it gives me that value not found.
      I suspect that there is a problem regarding While loop.
      here is my code
      #include <GUIConstantsEx.au3> #include <WinAPI.au3> #Include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> #include <ExcelConstants.au3> if FileExists ("result.txt") Then Sleep (100) Else readxl() EndIf Global $oExcel = _Excel_Open(False,False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\info.xlsx",False,False) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel Error", "Error opening workbook '" & $oWorkbook & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf Local $lab1 = _Excel_RangeRead($oWorkbook, Default,"B1") Local $lab2 = _Excel_RangeRead($oWorkbook, Default,"C1") Local $lab3 = _Excel_RangeRead($oWorkbook, Default,"D1") Local $lab4 = _Excel_RangeRead($oWorkbook, Default,"E1") Global $sResult1,$sResult2,$sResult3,$sResult4,$sResult5,$sResult6 Global $asKeyWords = stringsplit (FileRead (@ScriptDir & "\result.txt"),@CRLF) Global Const $xlUp = -4162 ;~ _Main() Local $hGUI, $hList, $hInput, $aSelected, $sChosen, $hUP, $hDOWN, $hENTER, $hESC Local $sCurrInput = "", $aCurrSelected[2] = [-1, -1], $iCurrIndex = -1, $hListGUI = -1 $hGUI = GUICreate("Rimo System", 253, 270, 192, 124) Global $hInput = GUICtrlCreateInput("", 24, 48, 169, 21) Global $Label1 = GUICtrlCreateLabel("Rimo System", 80, 16, 150, 25) GUICtrlSetFont(-1, 14, 800, 0, "MS Serif") Global $Input2 = GUICtrlCreateInput("", 72, 144, 161, 21) Global $Input3 = GUICtrlCreateInput("", 72, 176, 161, 21) Global $Input4 = GUICtrlCreateInput("", 72, 208, 161, 21) Global $Input5 = GUICtrlCreateInput("", 72, 240, 161, 21) $Input6 = GUICtrlCreateInput("", 72, 272, 161, 21) $Input7 = GUICtrlCreateInput("", 72, 304, 161, 21) $Button1 = GUICtrlCreateButton("Get Info", 72, 88, 89, 33) $Label2 = GUICtrlCreateLabel("Label2", 16, 144, 36, 17) GUICtrlSetData( -1,$lab1) $Label3 = GUICtrlCreateLabel("Label3", 16, 176, 36, 17) GUICtrlSetData( -1,$lab2) $Label4 = GUICtrlCreateLabel("Label4", 16, 208, 36, 17) GUICtrlSetData( -1,$lab3) $Label5 = GUICtrlCreateLabel("Label5", 16, 240, 36, 17) GUICtrlSetData( -1,$lab4) $Label6 = GUICtrlCreateLabel("", 16, 272, 36, 17) $Label7 = GUICtrlCreateLabel("", 16, 304, 36, 17) $Button2 = GUICtrlCreateButton("Cancel", 112, 416, 121, 25) GUISetState(@SW_SHOW, $hGUI) Global $sSearch = guictrlread ($hInput) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() $hESC = GUICtrlCreateDummy() Dim $AccelKeys[4][2] = [["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER], ["{ESC}", $hESC]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button2 Exit Case $Button1 Global $aResult = _Excel_RangeFind($oWorkbook, guictrlread($hInput) ,"A2:A2000") Global $aExtract = _ArrayExtract($aResult, 0, 0, 2, 2) if _elementExists($aExtract,0) Then getdata() Else MsgBox(0,"","Value Does Not Exist") EndIf Case $hESC If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 Else ExitLoop EndIf Case $hUP If $hListGUI <> -1 Then ; List is visible. $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $hListGUI <> -1 Then ; List is visible. $iCurrIndex += 1 If $iCurrIndex > _GUICtrlListBox_GetCount($hList) - 1 Then $iCurrIndex = _GUICtrlListBox_GetCount($hList) - 1 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $hListGUI <> -1 And $iCurrIndex <> -1 Then ; List is visible and a item is selected. $sChosen = _GUICtrlListBox_GetText($hList, $iCurrIndex) EndIf Case $hList $sChosen = GUICtrlRead($hList) EndSwitch Sleep(10) $aSelected = _GetSelectionPointers($hInput) If GUICtrlRead($hInput) <> $sCurrInput Or $aSelected[1] <> $aCurrSelected[1] Then ; Input content or pointer are changed. $sCurrInput = GUICtrlRead($hInput) $aCurrSelected = $aSelected ; Get pointers of the string to replace. $iCurrIndex = -1 If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 EndIf $hList = _PopupSelector($hGUI, $hListGUI, _CheckInputText($sCurrInput, $aCurrSelected)) ; ByRef $hListGUI, $aCurrSelected. EndIf If $sChosen <> "" Then GUICtrlSendMsg($hInput, 0x00B1, $aCurrSelected[0], $aCurrSelected[1]) ; $EM_SETSEL. _InsertText($hInput, $sChosen) $sCurrInput = GUICtrlRead($hInput) GUIDelete($hListGUI) $hListGUI = -1 $sChosen = "" EndIf WEnd GUIDelete($hGUI) Func _CheckInputText($sCurrInput, ByRef $aSelected) Local $sPartialData = "" If (IsArray($aSelected)) And ($aSelected[0] <= $aSelected[1]) Then Local $aSplit = StringSplit(StringLeft($sCurrInput, $aSelected[0]), " ") $aSelected[0] -= StringLen($aSplit[$aSplit[0]]) If $aSplit[$aSplit[0]] <> "" Then For $A = 1 To $asKeyWords[0] If StringLeft($asKeyWords[$A], StringLen($aSplit[$aSplit[0]])) = $aSplit[$aSplit[0]] And $asKeyWords[$A] <> $aSplit[$aSplit[0]] Then $sPartialData &= $asKeyWords[$A] & "|" EndIf Next EndIf EndIf Return $sPartialData EndFunc ;==>_CheckInputText Func _PopupSelector($hMainGUI, ByRef $hListGUI, $sCurr_List) Local $hList = -1 If $sCurr_List = "" Then Return $hList EndIf $hListGUI = GUICreate("", 280, 160, 23, 62, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hMainGUI) $hList = GUICtrlCreateList("", 0, 0, 170, 150, BitOR(0x00100000, 0x00200000)) GUICtrlSetData($hList, $sCurr_List) GUISetControlsVisible($hListGUI) ; To Make Control Visible And Window Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hListGUI) Return $hList EndFunc ;==>_PopupSelector Func _InsertText(ByRef $hEdit, $sString) #cs Description: Insert A Text In A Control. Returns: Nothing #ce Local $aSelected = _GetSelectionPointers($hEdit) GUICtrlSetData($hEdit, StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString & StringTrimLeft(GUICtrlRead($hEdit), $aSelected[1])) Local $iCursorPlace = StringLen(StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString) GUICtrlSendMsg($hEdit, 0x00B1, $iCursorPlace, $iCursorPlace) ; $EM_SETSEL. EndFunc ;==>_InsertText Func _GetSelectionPointers($hEdit) Local $aReturn[2] = [0, 0] Local $aSelected = GUICtrlRecvMsg($hEdit, 0x00B0) ; $EM_GETSEL. If IsArray($aSelected) Then $aReturn[0] = $aSelected[0] $aReturn[1] = $aSelected[1] EndIf Return $aReturn EndFunc ;==>_GetSelectionPointers Func GUISetControlsVisible($hWnd) ; By Melba23. Local $aControlGetPos = 0, $hCreateRect = 0, $hRectRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $iLastControlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle(-1)) For $i = 3 To $iLastControlID $aControlGetPos = ControlGetPos($hWnd, '', $i) If IsArray($aControlGetPos) = 0 Then ContinueLoop $hCreateRect = _WinAPI_CreateRectRgn($aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[0] + $aControlGetPos[2], $aControlGetPos[1] + $aControlGetPos[3]) _WinAPI_CombineRgn($hRectRgn, $hCreateRect, $hRectRgn, 2) _WinAPI_DeleteObject($hCreateRect) Next _WinAPI_SetWindowRgn($hWnd, $hRectRgn, True) _WinAPI_DeleteObject($hRectRgn) EndFunc Func _elementExists($array, $element) If $element > UBound($array)-1 Then Return False ; element is out of the array bounds Return True ; element is in array bounds EndFunc Func getdata() ;~ Local $sResult1 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","B")) ;~ Local $sResult2 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","C")) ;~ Local $sResult3 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","D")) ;~ Local $sResult4 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","E")) ;~ Local $sResult5 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","F")) ;~ Local $sResult6 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","G")) guictrlsetdata($Input2,$sResult1) guictrlsetdata($Input3,$sResult2) guictrlsetdata($Input4,$sResult3) guictrlsetdata($Input5,$sResult4) guictrlsetdata($Input6,$sResult5) guictrlsetdata($Input7,$sResult6) _Excel_Close($oExcel,Default,True) EndFunc Func readxl() Global $oExcel = _Excel_Open(False,False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\info.xlsx",False,False) LOcal Const $xlUp = -4162 With $oWorkbook.ActiveSheet ; process active sheet $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) ; get a Range that contains the last used cells $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count ; get the the row count for the range starting in row/column 1 and ending at the last used row/column $iLastCell = .Cells($iRowCount + 1, "B").End($xlUp).Row ProgressOn("Copying Cells", "Copying Cells progress", "0%") For $i = 2 to $iLastCell Local $total = Int(($i/$iLastCell)*100) Local $sResult3 = _Excel_RangeRead($oWorkbook, Default, "A" & $i) FileWriteLine("result.txt",$sResult3) ProgressSet(($i/$iLastCell)*100, $total & "%") Next ;~ FileWrite("result.txt",$sResult3) ProgressSet(100, "Done", "Complete") Sleep (1500) ProgressOff() _Excel_Close($oExcel,Default,True) EndWith EndFunc  
    • kawliga751
      By kawliga751
      I'm new to Auotit but I have built a simple script that "runs" a different "batch" file based on certain days of the workweek. The script works now, but I was wanting to eliminate the need for a manual date entry. For example "First Batch' needs to run every Tuesday thru Thursday however "Second Batch" needs to run only on Friday and "Third Batch" needs to run only on Monday. In addition the 1st batch file runs on Tuesday, say 06/06 (the "FW" section) but then needs to actually report (the F4 date) the next weekday so this Batch actually needs 2 dates verified. 
      What I'm trying to do is when the script is initiated it gets the date, verifies if and which weekday it is and in turn goes to and runs the appropriate "Batch' file.  
      I've found ways to verify weekdays but can't find anything to do all of the above.
      Any help is MUCH appreciated.
       
      ;P10
      ShellExecute("C:\Program Files (x86)\Ericom Software\PowerTerm Enterprise\Sessions\mir00p10.PTS")

      WinWait('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite')
      WinActivate('(A) Soutwest P10 : PowerTerm Pro Enterprise Suite')
      Send('$Login)
      Sleep(3000)
      Send('{Enter}')
      Sleep(3000)
      Send($Password)
      Send('{Enter}')
      Sleep(3000)
      ; ****First Batch file run
      Send('Batch')
      Sleep(3000)
      Send('{Enter}')
      Send('FW')
      Send('{Enter}')
      Send('{DOWN}')
      Send($Date)
      Send('{Enter}')
      Send('{Enter}')
      Send($Date)
      Send('{F9}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send('{F4}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send($Date)
      Send('{Enter}')
      Send('0620')
      Send('{Enter}')
      SEND('{!}SW0410PM.FWR')
      Send('{Enter}')
      Sleep(3000)
      Send('Y')
      Send('{Enter}')
      Sleep(3000)
      Send('{F9}')
      Sleep(3000)
      ; ****Second Batch file run
      Send('Batch')
      Sleep(3000)
      Send('{Enter}')
      Send('FW')
      Send('{Enter}')
      Send('{DOWN}')
      Send($Date)
      Send('{Enter}')
      Send('{Enter}')
      Send($Date)
      Send('{F9}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send('{F4}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send($Date)
      Send('{Enter}')
      Send('0620')
      Send('{Enter}')
      SEND('{!}SO0411AM.FWR')
      Send('{Enter}')
      Sleep(3000)
      Send('Y')
      Send('{Enter}')
      Sleep(3000)
      Send('{F9}')
      Sleep(3000)
      ; ****Third Batch file run
      Send('Batch')
      Sleep(3000)
      Send('{Enter}')
      Send('FW')
      Send('{Enter}')
      Send('{DOWN}')
      Send($Date)
      Send('{Enter}')
      Send('{Enter}')
      Send($Date)
      Send('{F9}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send('{F4}')
      Send('Y')
      Sleep(3000)
      Send('{Enter}')
      Send($Date)
      Send('{Enter}')
      Send('0620')
      Send('{Enter}')
      SEND('{!}SW0411AM.LOA')
      Send('{Enter}')
      Sleep(3000)
      Send('Y')
      Send('{Enter}')
      Sleep(3000)
      Send('{F9}')
      Sleep(3000)
      Send('EXIT')
       
       
    • chacoya121
      By chacoya121
      can anyone help me plz
      how can you put mouseclick in if statement or is it possible
      example:
      if Mouseclick = "left" then Tooltip(" you click left mouse") thank you