Sign in to follow this  
Followers 0
Jcreator

this script keeps having contradicting loop

17 posts in this topic

i used this code to take names for a text file called data and put the info of the image and it location from the data file into the gui interface but it only detect the lines with the info and it do not show the images . here is the code 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
#include <GuiComboBox.au3>
#include <GuiTab.au3>
#include <file.au3>
#include <array.au3>




_Main()


Func _Main()


Local $idTab1

$Form1 = GUICreate("Form1", 500, 334, 240, 182)
$Group1 = GUICtrlCreateGroup("Group1", 20, 12, 249, 314)
$idButton6 = GUICtrlCreateButton("Info", 50, 270, 185, 49)

GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

Global $fileMPA = "C:\T-in\MPA\data.txt"

FileOpen($fileMPA, 0)

   Global $line1 = FileReadLine($fileMPA , 1)

$imp = 0


$idTab1 = GUICtrlCreateTab(300, -3, 180, 330)
GUICtrlCreateTabItem("imglist1")
GUICtrlSetTip(-1, '#Region TAB1')
GUICtrlSetTip(-1, '#Region LIST')
Local $imglist1 = GUICtrlCreateList("", 307, 26, 164, 304)


$cline =_FileCountLines($fileMPA)

 While  $imp < $cline


$line2 = FileReadLine($fileMPA , $imp + 2)
 $imp = $imp + 7

if $line2 = ""  then

    ExitLoop

   else

 GUICtrlSetData(-1, ""& $line2 &"", "")

 endif

WEnd

GUICtrlCreateTabItem("imagelist2")
GUICtrlSetTip(-1, '#Region TAB2')
GUICtrlCreateTabItem("imagelist3")
GUICtrlSetTip(-1, '#Region TAB3')

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            Exit
            Global $whatnow = GUICtrlRead($imglist1)
Case $Msg = $idButton6

            $imp2 = 0
             While  $imp2 < 30


$line2 = FileReadLine($fileMPA ,$imp2 + 2)
$line3 = FileReadLine($fileMPA , $imp2 + 3)
$line7 = FileReadLine($fileMPA , 7)

 $imp2 = $imp2 + 7

if $line2 = ""  then  ExitLoop
            If GUICtrlRead($imglist1) = ""& $line2 &""  Then MsgBox($MB_SYSTEMMODAL, "img info" , $line3)
               WEnd
            EndSelect
$imp2 = 0
             While  $imp2 < 30


$line2 = FileReadLine($fileMPA ,$imp2 + 2)
$line3 = FileReadLine($fileMPA , $imp2 + 3)
$line7 = FileReadLine($fileMPA , 7)

 $imp2 = $imp2 + 7

    Select
Case GUICtrlRead($imglist1) = ""& $line2 &""
if $line2 = "" then ExitLoop
    $Pic1 = GUICtrlCreatePic(""& $line7 &"", 185, 28, 233, 230)

If GUICtrlRead($imglist1) then  ExitLoop
EndSelect
WEnd

    WEnd

 EndFunc   ;==>_Main

the data.txt file content is 

Hibiscus
Hibiscus is a hardy perennial which grows in variety of colors, sizes and fragrances. Actually they are tropical flowers which require ample sunlight and moisture to grow well. These flowers start blooming in late spring and continuously bloom through July and August.



C:\T-in\IMG\2.jpg

Lilies
There are different types of lily flowers which bloom in August including water lilies, tiger lilies and gold band lilies. Tiger lilies generate orange flowers having black spots. This lily blooms in delayed July and beginning of August. Gold band lily produce exotic white blooms. All varieties of lilies need enough space to grow and protection from summer sun.



C:\T-in\IMG\1.jpg

Turtlehead
Growing in humid areas, turtleheads are small flowers which bloom from July to September. They mostly produce flowers of white and pink color.



C:\T-in\IMG\3.jpg

Hydrangea
These are ever green bushes which produce flowers in different colors including white, purple, blue and pink. They are easy to grow bushes and can grow 3 to 10 feet tall. They require morning sun to grow but they should be protected from noon and afternoon sun.



C:\T-in\IMG\4.jpg

Dahlias
August proves to be the peak blooming season for dahlias. Dahlias come in colors like white, orange, yellow, red and purple. They can tolerate all types of soil and require full sun to grow.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I suggest using a 2 dimension Array holding the data from the textfile. Creeating array can be done also with regex, the rest of script is just a demo for easy solving with array:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <StaticConstants.au3>

$sFile = FileRead('flowers.txt')    ;change to your path
$aFlowers = StringSplit($sFile, '.jpg', 1)
If IsArray($aFlowers) Then
    For $j = $aFlowers[0] To 1 Step -1
        If StringStripWS($aFlowers[$j], 8) = '' Then
            _ArrayDelete($aFlowers, $j)
            $aFlowers[0] -= 1
        EndIf
    Next
    _ArrayColInsert($aFlowers, 1)
    _ArrayColInsert($aFlowers, 1)
    ;_ArrayDisplay($aFlowers)
    For $i = 1 To $aFlowers[0][0]
        $aSplit = StringSplit($aFlowers[$i][0], @CRLF, 1)
        For $j = $aSplit[0] To 1 Step -1
            If $aSplit[$j] = '' Then
                _ArrayDelete($aSplit, $j)
                $aSplit[0] -= 1
            EndIf
        Next
        ;_ArrayDisplay($aSplit, 'Split')
        If $aSplit[0] = 0 Then ExitLoop
        $aFlowers[$i][0] = $aSplit[1]
        #cs
            $sDescription = ''
            For $j = $aSplit[2] To $aSplit[0]; - 1
            if $aSplit[$j]<>'' Then $sDescription &= $aSplit[$j] & @CRLF
            Next
        #ce
        $aFlowers[$i][0] = $aSplit[1]
        $aFlowers[$i][1] = $aSplit[2]
        $aFlowers[$i][2] = $aSplit[$aSplit[0]] & '.jpg'
    Next
EndIf
;_ArrayDisplay($aFlowers)

Global $idPic =-999
$hMainGui=GUICreate('JPG-Viewer',640,480)
$idList=GUICtrlCreateList('',490,5,135,470)
For $i=1 to $aFlowers[0][0]
    GUICtrlSetData($idList,$aFlowers[$i][0])
Next
$idLblDescription=GUICtrlCreateLabel('Test',5,405,470,70);,$SS_LEFT)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idList
            $sVal = GUICtrlRead($idList)
            $iNo= _ArraySearch($aFlowers,$sVal)
            ConsoleWrite($iNo & ' '&$sVal & ': '& $aFlowers[$iNo][1]&@CRLF)
            GUICtrlSetData($idLblDescription,$aFlowers[$iNo][1])
            If $idPic <>-999 Then GUICtrlDelete($idPic)
            $idPic=GUICtrlCreatePic($aFlowers[$iNo][2],5,5,200,200)
    EndSwitch
WEnd

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

am still not good with the autoit yet so your script will take me some time to understand especially

StringStripW

but i will give it my time to understand it .am sooo thankful . you are a life saver ,and the way you write scripts is so clean . i hope someday i could help you with something.

for now i will give this script some time to see how can i edit it

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

May be @mikell or some one else of the StringRegExp experts, show a shorter way to get the 2 dimension array. Btw. there is a typo in your quote the func name is

Quote

StringStripWS

Strips the white space in a string.

, i use it to detect empty lines.

the pic's are visible in the testscript, i couldn't test it? And found typos in this line:

$idPic=GUICtrlCreatePic($aFlowers[$iNo][2],5,5,200,200)

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You could try something like the code below, so you get a 1D array
You can then use it in a For loop with step 3, or build a 2D array with 3 cols, etc

This code implies that the description is a one-liner string and that the data.txt is formatted exactly like the text in post #1 ... regular expression requirements   :)

#Include <Array.au3>

$txt = FileRead("C:\T-in\MPA\data.txt")

$res = StringRegExp($txt, '(?is)(c:\N+jpg)\s*(\N+)\R(\N+)', 3)
 _ArrayDisplay($res)
 
 #cs
Local $u = UBound($res), $flowers[$u/3][3]
For $i = 0 to $u-1 step 3
   $flowers[$i/3][0] = $res[$i+1]
   $flowers[$i/3][1] = $res[$i]
   $flowers[$i/3][2] = $res[$i+2]
Next
 _ArrayDisplay($flowers)
#ce

 

Edited by mikell

Share this post


Link to post
Share on other sites

@Jcreator But why format the text file like that? Why not line by line and separated by some character (comma would make sense except there is free text so pipes or tabs are often better)

Quote

c:\x\y.jpg|my title|This, some text, is the rest of the explanation.

... then use StringSplit or StringRegexp to split it in much the same way, but with easier regexps? :) 

Added benefit: file is easy to maintain in a spreadsheet software like excel.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@SadBunny: i think the textfile is generated from https://orchidflowers.wordpress.com/2012/12/13/list-of-perennials-which-bloom-all-year/

@Jcreator: now the script is shortened:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <StaticConstants.au3>
#include <GuiListBox.au3>

$sFile = FileRead('flowers.txt') ;change to your path
$aRes = StringRegExp($sFile, '(?is)(c:\N+jpg)\s*(\N+)\R(\N+)', 3)
Global $aFlowers[UBound($aRes) / 3 + 1][3], $j
For $i = 0 To UBound($aRes) - 1 Step 3
    $j += 1
    $aFlowers[$j][0] = $aRes[$i + 1]
    $aFlowers[$j][1] = $aRes[$i + 2]
    $aFlowers[$j][2] = $aRes[$i]
Next
$aFlowers[0][0] = $j
;_ArrayDisplay($aFlowers)

Global $idPic = -999
$hMainGui = GUICreate('JPG-Viewer', 640, 480)
$idList = GUICtrlCreateList('', 490, 5, 135, 470)
For $i = 1 To $aFlowers[0][0]
    GUICtrlSetData($idList, $aFlowers[$i][0])
Next
$idLblHeader = GUICtrlCreateLabel('Header', 5, 5, 470, 40);,$SS_LEFT)
GUICtrlSetFont(-1, 14, 800)
$idLblBody = GUICtrlCreateLabel('Body', 5, 395, 470, 70);,$SS_LEFT)
GUICtrlSetFont(-1, 10, 400)
$sFlower=_GUICtrlListBox_GetText($idList, 0)
_FindFlowerByName($sFlower)
_GUICtrlListBox_SelectString($idList, $sFlower)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idList
            $sVal = GUICtrlRead($idList)
            _FindFlowerByName($sVal)
    EndSwitch
WEnd

Func _FindFlowerByName($sFlower)
    Local $iNo = _ArraySearch($aFlowers, $sFlower)
    _FindFlowerByID($iNo)
EndFunc   ;==>_FindFlowerByName

Func _FindFlowerByID($iNo)
    ;ConsoleWrite($iNo & ': '& $aFlowers[$iNo][1]&@CRLF)
    GUICtrlSetData($idLblHeader, $aFlowers[$iNo][0])
    GUICtrlSetData($idLblBody, $aFlowers[$iNo][1])
    If $idPic <> -999 Then GUICtrlDelete($idPic)
    $idPic = GUICtrlCreatePic($aFlowers[$iNo][2], 5, 55, 200, 200)
EndFunc   ;==>_FindFlowerByID

@mikell: i hoped with StringRegExp a one liner is possible for creating and assigning a 2 dimension array, but seems not possible.

Edited by AutoBert

Share this post


Link to post
Share on other sites

Alas, yes indeed using StringRegExp the only arrays you can get are 1D arrays  :(
It's the user's task afterwards to manage it and build their own 2D array with n colummns

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I found a way to get small (not so  small as StringR egExp), easy readable script using stringreplace to get a working file   for the use of _FileReadToArray:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <GuiListBox.au3>

$sPath = 'flowers.txt' ;change to your path
$sFile = FileRead($sPath)
$sFile = Stringreplace($sFile,'.jpg'&@CRLF,chr(255)); row seperator placeholder
Do
    $sFile = Stringreplace($sFile,@CRLF&@CRLF,@CRLF)
Until not @extended
$sFile =Stringreplace($sFile,@CRLF,'|')             ;col seperator
$sFile =Stringreplace($sFile,Chr(255), '.jpg'&@CRLF);row seperator restored
$hFile=FileOpen($sPath&'.work',2)
$sFile='|'&$sFile                                   ;all other rows have this also
FileWrite($hFile,$sFile)
FileClose($hFile)
Global $aFlowers
_FileReadToArray($sPath&'.work',$aFlowers,$FRTA_COUNT,'|')
$aFlowers[0][2]=$aFlowers[0][1] ;saving colcount
$aFlowers[0][1]=$aFlowers[0][0] ;saving rowcount
_ArrayColDelete($aFlowers,0) ;col 0 has no data so deleting
;_ArrayDisplay($aFlowers)

Global $idPic = -999
$hMainGui = GUICreate('JPG-Viewer', 640, 480)
$idList = GUICtrlCreateList('', 490, 5, 135, 470)
For $i = 1 To $aFlowers[0][0]
    GUICtrlSetData($idList, $aFlowers[$i][0])
Next
$idLblHeader = GUICtrlCreateLabel('Header', 5, 5, 470, 40);,$SS_LEFT)
GUICtrlSetFont(-1, 14, 800)
$idLblBody = GUICtrlCreateLabel('Body', 5, 395, 470, 70);,$SS_LEFT)
GUICtrlSetFont(-1, 10, 400)
$sFlower=_GUICtrlListBox_GetText($idList, 0)
_FindFlowerByName($sFlower)
_GUICtrlListBox_SelectString($idList, $sFlower)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idList
            $sVal = GUICtrlRead($idList)
            _FindFlowerByName($sVal)
    EndSwitch
WEnd

Func _FindFlowerByName($sFlower)
    Local $iNo = _ArraySearch($aFlowers, $sFlower)
    _FindFlowerByID($iNo)
EndFunc   ;==>_FindFlowerByName

Func _FindFlowerByID($iNo)
    ;ConsoleWrite($iNo & ': '& $aFlowers[$iNo][1]&@CRLF)
    GUICtrlSetData($idLblHeader, $aFlowers[$iNo][0])
    GUICtrlSetData($idLblBody, $aFlowers[$iNo][1])
    If $idPic <> -999 Then GUICtrlDelete($idPic)
    $idPic = GUICtrlCreatePic($aFlowers[$iNo][2], 5, 55, 200, 200)
EndFunc   ;==>_FindFlowerByID

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

this last one did more then what i had in mind ^^ thank you so much i had to do some changes  the line For $i = 1 To $cline

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <GuiListBox.au3>

$sPath = 'flowers.txt' ;change to your path
$sFile = FileRead($sPath)
$sFile = Stringreplace($sFile,'.jpg'&@CRLF,chr(255)); row seperator placeholder
Do
    $sFile = Stringreplace($sFile,@CRLF&@CRLF,@CRLF)
Until not @extended
$sFile =Stringreplace($sFile,@CRLF,'|')             ;col seperator
$sFile =Stringreplace($sFile,Chr(255), '.jpg'&@CRLF);row seperator restored
$hFile=FileOpen($sPath&'.work',2)
$sFile='|'&$sFile                                   ;all other rows have this also
FileWrite($hFile,$sFile)
FileClose($hFile)
Global $aFlowers
_FileReadToArray($sPath&'.work',$aFlowers,$FRTA_COUNT,'|')
_ArrayColDelete($aFlowers,0) ;row 0 has no data so deleting
_ArrayDisplay($aFlowers)

Global $idPic = -999
$hMainGui = GUICreate('JPG-Viewer', 640, 480)
$idList = GUICtrlCreateList('', 490, 5, 135, 470)
$cline =_FileCountLines($sPath&'.work') ; i had to add this to make it work for me
For $i = 1 To $cline
    GUICtrlSetData($idList, $aFlowers[$i][0])
Next
$idLblHeader = GUICtrlCreateLabel('Header', 5, 5, 470, 40);,$SS_LEFT)
GUICtrlSetFont(-1, 14, 800)
$idLblBody = GUICtrlCreateLabel('Body', 5, 395, 470, 70);,$SS_LEFT)
GUICtrlSetFont(-1, 10, 400)
$sFlower=_GUICtrlListBox_GetText($idList, 0)
_FindFlowerByName($sFlower)
_GUICtrlListBox_SelectString($idList, $sFlower)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idList
            $sVal = GUICtrlRead($idList)
            _FindFlowerByName($sVal)
    EndSwitch
WEnd

Func _FindFlowerByName($sFlower)
    Local $iNo = _ArraySearch($aFlowers, $sFlower)
    _FindFlowerByID($iNo)
EndFunc   ;==>_FindFlowerByName

Func _FindFlowerByID($iNo)
    ;ConsoleWrite($iNo & ': '& $aFlowers[$iNo][1]&@CRLF)
    GUICtrlSetData($idLblHeader, $aFlowers[$iNo][0])
    GUICtrlSetData($idLblBody, $aFlowers[$iNo][1])
    If $idPic <> -999 Then GUICtrlDelete($idPic)
    $idPic = GUICtrlCreatePic($aFlowers[$iNo][2], 5, 55, 200, 200)
EndFunc   ;==>_FindFlowerByID

 

Share this post


Link to post
Share on other sites

am really thankful for all your help guys and am sorry for being slow at understanding the answer -.- still trying to learn this 

by the way the 

_FileReadToArray

was really useful and i tried to use it in another part of the script where it will show the flowers information and picture by typing the name of the flower 

script

#include <Misc.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
#include <GuiComboBox.au3>
#include <GuiTab.au3>
#include <file.au3>
#include <array.au3>

Global $sfPath = 'flowers.txt'
Global $aFlowers
_FileReadToArray($sfPath,$aFlowers,$FRTA_NOCOUNT,'|')
_ArrayColDelete($aFlowers,0) ;row 0 has no data so deleting

$Form1 = GUICreate("Search Flower Name",320, 480)
$input = GUICtrlCreateInput("", 60, 360, 209, 25)
$idss = GUICtrlCreateButton("Search", 130, 400, 73, 65)

GUISetState(@SW_SHOW)




Func Searchf()



Global $Fname = GUICtrlRead($input)


        For $iNo = 0 To UBound($aFlowers[0][0]) - 1 ;

           if $Fname = $aFlowers[$iNo][0] then

MsgBox($MB_SYSTEMMODAL, "","Flower nfo", ""& $aFlowers[$iNo][1] &"")

pic()

EndIf
        Next

EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE

            Exit
         Case $nMsg = $idss

        Searchf()

    EndSwitch
 WEnd

func pic()
   For $iNo = 0 To UBound($aFlowers[0][0]) - 1
   GUICtrlCreatePic($aFlowers[$iNo][2], 20, 30, 280, 280)
    Next
   EndFunc

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

@AutoBert i hope that you dont mind me using your code in a different script

and thanks to @mikell for trying to help too

 

Edited by Jcreator

Share this post


Link to post
Share on other sites

Just a quick off-topic friendly word of advice: use the Tidy tool (Tools -> Tidy AutoIt Source or Ctrl+T). It will format your code to make it much more readable, and while doing that it will also very clearly indicate potential syntax problems. This will assist you in writing proper code and catching problems early. I press it, like, every five seconds (it also saves your code, so for me it's pretty much a Ctrl+S replacement :)).

Also, "tidy"-ing your code before posting here on the forum will also go a long way to make it much easier to read for others.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

^^ @SadBunny thx for the  advice  but i cant seem to find this  Tools -> Tidy AutoIt if it exist 

Share this post


Link to post
Share on other sites

Are you using the full version of the Scite editor? If not, I suggest getting it, it is quite useful :dance:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

16 hours ago, Jcreator said:

i had to do some changes  the line For $i = 1 To $cline

ups, there was an error the last flower wasn't read. So i had just corrected an edited last post. Here only the snipet to see changes:

_FileReadToArray($sPath&'.work',$aFlowers,$FRTA_COUNT,'|')
$aFlowers[0][2]=$aFlowers[0][1] ;inserted=>saving colcount      
$aFlowers[0][1]=$aFlowers[0][0] ;inserted=>saving rowcount
_ArrayColDelete($aFlowers,0) ;col 0 has no data so deleting

in your func Searchf you are using ubound wrong, must be 

For $iNo = 0 To UBound($aFlowers) - 1 ;

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

@AutoBert thank you so much this was really helpful ^^

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

  • Similar Content

    • 0Ethan0
      By 0Ethan0
      Ahoy Autoit Community!
      After many trials and errors I am unable to solve a problem I am facing and would appreciate any kind of input or better yet a solution 
      The Premise: An embeded slideshow viewer that runs after double-clicking an item in a ListView (each item will generate a different slideshow images).
      The Setup: GUI with a ListView Control and a simple exit button.
      The Issue: Once double clicked the slide plays however the GUI "locks"/non responsive until the slide is over. Same thing if I click on the "Test" button.
      The Culprit: I believe since it's in the images loop it can't accept any other commands until that loop is over.
      The Wish: I want to be able to use the GUI functions (selecting other items, clicking on button etc.) while the slideshow plays.
      The Code (stripped and simplified as much as I could):
      #include <GuiListView.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{Esc}", "_Exit") Global $c=0 Global $ssGDI[3], $ssGraphic[2], $ssImage Global Const $bg_color = "000000" Global Const $ssW = 480, $ssH = 320 Global $aFiles = _FileListToArrayRec("d:\testStage\", "*.jpg;*.png;*.bmp;*.gif;*.JPG;*.PNG;*.BMP;*.GIF", $FLTAR_FILES, $FLTAR_NORECUR ,$FLTAR_SORT ,$FLTAR_FULLPATH ) $guiW = 1200 $guiH = 726 $mainWindow = GUICreate("Slideshow Viewer", $guiW, $guiH, -1, -1, $WS_POPUP) $Button1 = GUICtrlCreateButton("Exit", 0, 0, 50, 50) GUICtrlSetOnEvent($Button1, "_Exit") $Button1 = GUICtrlCreateButton("Test", 60, 0, 50, 50) GUICtrlSetOnEvent($Button1, "Test") Global $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280) _GUICtrlListView_SetColumnWidth ($ListView, 0, 100) _GUICtrlListView_SetColumnWidth ($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) screenshotWidgetInit($ssW,$ssH, 690, 100) GUISetState(@SW_SHOW, $mainWindow) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd Func Test() For $k = 1 To UBound($aFiles) - 1 screenshotWidgetTransition($aFiles[$k]) Next EndFunc Func ListView_Click() ConsoleWrite("Left Click") EndFunc Func ListView_DoubleClick() ConsoleWrite("Double Left Click") Test() EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ListView_Click () Case $event = $NM_DBLCLK ListView_DoubleClick () EndSelect EndSelect Return $GUI_RUNDEFMSG EndFunc Func screenshotWidgetTransition($image, $delay = 0, $speed = 1, $sleep = 2000) Local $a, $d = $c, $iX, $iY $ssImage = _GDIPlus_ImageLoadFromFile($image) $iX = _GDIPlus_ImageGetWidth($ssImage) $iY = _GDIPlus_ImageGetHeight($ssImage) $FDesktop=$ssH/$ssW $Fact =1 If $iX > $ssW And $FDesktop > ($iY/$iX) Then $Fact=$ssW/$iX ElseIf $iY > $ssH Then $Fact=$ssH/$iY EndIf $H1 = Round(($Fact * $iY),0) $W1 = Round(($Fact * $iX),0) _GDIPlus_GraphicsDrawImageRect($ssGraphic[$d], $ssImage,($ssW - $W1)/2, ($ssH - $H1) / 2,$W1,$H1) WinSetTrans($ssGDI[$d], "", 0) WinSetOnTop($ssGDI[$d], "", 1) For $a = 0 To 254 Step $speed WinSetTrans($ssGDI[$d], "", $a) Sleep($delay) Next WinSetTrans($ssGDI[$d], "", 254) WinSetOnTop($ssGDI[Not ($d)], "", 0) WinSetTrans($ssGDI[Not ($d)], "", 0) _GDIPlus_GraphicsClear($ssGraphic[Not ($d)]) $c = 1 - $d _GDIPlus_ImageDispose ($ssImage) ; very important to realease the pics Sleep($sleep) EndFunc ;==>screenshotWidgetTransition Func screenshotWidgetInit($ssW,$ssH,$ssX,$ssY) $ssGDI[2] = GUICreate("", $ssW, $ssH, $ssX, $ssY, $WS_POPUP, $WS_EX_MDICHILD, $mainWindow) $ssGDI[0] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) $ssGDI[1] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) ; GUISetBkColor("0x" & $bg_color, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[0]) GUISetState(@SW_SHOW, $ssGDI[1]) WinSetTrans($ssGDI[0], "", 0) WinSetTrans($ssGDI[1], "", 0) _GDIPlus_Startup() $ssGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[0]) $ssGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[1]) _GDIPlus_GraphicsClear($ssGraphic[0], "0xFF" & $bg_color) _GDIPlus_GraphicsClear($ssGraphic[1], "0xFF" & $bg_color) EndFunc ;==>screenshotWidgetInit Func _Exit() _GDIPlus_ImageDispose($ssImage) _GDIPlus_GraphicsDispose($ssGraphic[0]) _GDIPlus_GraphicsDispose($ssGraphic[1]) GUIDelete($ssGDI[0]) GUIDelete($ssGDI[1]) GUIDelete($ssGDI[2]) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit I hope someone can shed light on this; perhaps a different approach is needed?
      Thank you in advance!
      P.S.
      The script is patched from different scripts of different users in the forum - thank you again users!
    • rudi
      By rudi
      Hello.
      I'm too stupid to see my mistake:
      To investigate the internal "dictionary" of TIFF files I'd like to read in the files in binary mode and to check, if there are more than one pages "in" this TIFF.
      Notepad++, "View as Hex" is presenting the first bytes as "49 49 2a 20 08 20 20 20 12" for the TIF attached to this posting
      The "TIFF Header Format" is easy:
      Offset 00h, 2 Byte = Byte Order, "II"=intel, "MM"=motorola. (I = 0x49)
      --> II
      Offset 02h, 2 Byte = Version Nr.
      Offset 04h, 4 Byte = pointer to first IFD entry
      Description of TIFF header: https://www.awaresystems.be/imaging/tiff/faq.html#q3
       

      Howto read and analyse the binary content correctly? This is my messy, not operational code:
       
      $sampleTiff="H:\daten\tif\11\11\111111.TIF" $h=FileOpen($sampleTiff,16) $content=FileRead($h) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console FileClose($h) $type=VarGetType($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $type = ' & $type & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $ToString=BinaryToString($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ToString = ' & $ToString & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & @CRLF) $content=StringTrimLeft($content,2) ; cut off the leading "0x" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console for $i = 1 to 8 step 8 $next=StringMid($content,$i,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $next = ' & $next & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Chr=BinaryToString($next) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Chr = ' & $Chr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & "---" & @CRLF) Next Regards, Rudi.
      111111.TIF
    • Patryk
      By Patryk
      Dear Colleagues,
      I have no idea how to refer to style.display in my loop. There is a button like: 
      <input name="ctl00$bodyPlaceholder$btnFecharProcessamento" class="button" id="bodyPlaceholder_btnFecharProcessamento" style="display: none;" onclick="FecharJanelaProcessamento();return false;" type="submit" value="Fechar"> I want it to be clicked as soon as button's style change from style="display: none;" to  style= ="display: inline-block;" 
      This is what I got, but it's not working...
      Func GetButtons() $oButtons = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento",-1) $i = 0 While $i <> 1 For $oBtn In $oButtons If _IEFormElementGetValue($oBtn) = "Fechar" And $oBtn.document.style.display = "display: inline-block;" Then $i = 1 _IEAction($oBtn, "focus") _IEAction($oBtn, "click") ExitLoop EndIf Next WEnd EndFunc  
      I will really appreciate if you could help me with these loop!
    • usmiv4o
      By usmiv4o
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.3 Author: usmiv4o Script Function: AutoIt script to check if files in directory are changed. It is usefull for security contra-inteligense measures. Function Name: LoadTripwireDB() Description: Loads database (text file tripwire.txt) and compare files in /test folder for changes. compares Hash (MD5) checksums. If they are not the same starts Initial() Function Name: Initial() Description: Checks directory and makes index of files and their MD5 checksums in text file (tripwire.txt) Function Name: Hush() Description: Checks file and returns its MD5 checksum. Requirement(s): Windows XP Return Value(s): On Success - Returns true. Files are the same as before. On Failure - return false. Example: LoadTripwireDB() #ce ---------------------------------------------------------------------------- #include <Crypt.au3> #include <File.au3> #include <Array.au3> $sDir = @ScriptDir & "\Test" $sFilePath = @ScriptDir & "\tripwire.txt" Func Hush(ByRef $sFile) $sRead = FileOpen( $sFile) $dHash = _Crypt_HashData($sRead, $CALG_MD5) ; Create a hash of the text entered. ConsoleWrite("Hash of file " & $sFile & " is " & $dHash & @CRLF) EndFunc ;ConsoleWrite("Files in Dir are " & $aScriptDir[0] & @CRLF) ;$sFilePath = @ScriptDir & "\Examples.txt" ;_FileWriteFromArray($sFilePath, $aScriptDir, 1) ;_ArrayDisplay($aScriptDir, "1D display") Func Initial() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 $dHash = _Crypt_HashData($i, $CALG_MD5) ;ConsoleWrite("File " & $aScriptDir[$i] & " is " & $dHash & @CRLF) ConsoleWrite($aScriptDir[$i] & ":" & $dHash & @CRLF) ;Hush($aScriptDir[$i]) ;FileWrite $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") EndIf FileWrite($hFileOpen, $aScriptDir[$i] & ":" & $dHash & @CRLF) Next EndFunc Func Monitor() $aScriptDir = _FileListToArray($sDir) for $i = 1 To UBound($aScriptDir) - 1 Next EndFunc Func LoadTripwireDB() $comparison_ok = false $dArray = _FileListToArray($sDir) ;directory $dArray0 = UBound($dArray) - 1 $fArray = FileReadToArray($sFilePath) ;file $fArray0 = UBound($fArray) ;_ArrayDisplay($dArray, "files array") if $dArray0 = $fArray0 Then ; are file same as recorded in txt file? ;ConsoleWrite("files in monitoring dir: " & $dArray[0] & " = file recorded: " & $fArray0 & @CRLF & $fArray[0]& @CRLF) for $i = 1 To UBound($dArray) - 1 ;ConsoleWrite("i = " & $i & @CRLF) $dHash = _Crypt_HashData($i, $CALG_MD5) ;binary ;$dHash = BinaryToString($dHash) $ffhash = StringSplit( $fArray[$i-1],":") $fhash = $ffhash[2] ;ConsoleWrite("IsBinary $dHash " & IsBinary($dHash) & @CRLF) if $dHash = $fhash Then ;if compared hashes are equal ;ConsoleWrite($fhash & ":" & $dHash & " equal" & @CRLF) ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: yes " & @CRLF) Else ;if compared hashes are not equal ;ConsoleWrite("File: " & $fhash & @CRLF & "Directory: " & $dHash & @CRLF & "equal: not " & @CRLF) ;MsgBox(0,"hash md5",$fhash & ":" & $dHash & " not equal") EndIf Next ;ConsoleWrite("hashes are equal" & @CRLF) $comparison_ok = true Else ConsoleWrite("number of files in monitoring dir are not same as recorded" & @CRLF) ConsoleWrite("directory: " & $dArray[0] &":"& "files: " & UBound($fArray) - 1 & @CRLF) EndIf Return $comparison_ok EndFunc #main if LoadTripwireDB() = true Then ConsoleWrite(" hashes are equal " & @CRLF) ElseIf LoadTripwireDB() <> true Then ConsoleWrite(" hashes are not equal " & @CRLF) ConsoleWrite(" hashes are not equal " & @CRLF) Initial() EndIf  
      tripwire.au3
      tripwire.txt
    • Nareshm
      By Nareshm
      How to repeat my script when my control class does not match ?
       
      My Script : winActivate ( " PS :: Version - 2.2.0.0  - [PS Bill]")                   ControlClick ( "PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]")                   ControlSend(" PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")                   WinActive ("Verification Number Entry ::")                   ControlClick("Next >", "","[NAME:btnNext]") ;if   >>>> Control <<<<  does not match repeat my script, ;if match exit script  

      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468