Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/22/2012 in all areas

  1. rasim

    7Zip

    Hi everyone! Ok, after searching for any solution about works with 7Zip archives I found this interesting topic with several examples. And within several days I have written this UDF Main features: Over 27 functions! 7z, zip, gzip, bzip2, tar archive types support. Archive encrypt/decrypt support. Archive include/exclude support. Files include/exclude support. SFX archives support. Multivolume archives support. Archive checking support. Compressing method 0-9. 3 recursion method. Deleting files from archive. Updating archives files. Searching in the archive. DLL Call-back function (for using the 7-zip32.dll with your GUI) Retrieve the archive files date/time. Retrieve the archive files compressed/uncompressed size. Retrieve archives compressing ratio. Retrieve archives CRC. Retrieve the archive file count. And more... 7zip_udf.zip
    1 point
  2. The solve can be a dummy control. I made some comments where I added something in your code. This should work without frezees. ;========================================================================================== ;Includes ;Includes #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> #include <Array.au3> #include <String.au3> #include <Date.au3> #include <IE.au3> #include <GuiStatusBar.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GuiTab.au3> ;========================================================================================== ;========================================================================================== ;Constant variables Global $WinMainTitle = "King's Empire Alliance Manager" Global $ProgVersion = "v1.00" Global $LastUpdate = "2012/05/02" Global $IsConnect = "Searching..." Global $IsUpToDate = "Searching..." ;Directory paths Global $ResDir = @ScriptDir & "Resources" ;File names Global $SavedBoardtxt = "SavedBoard.txt" Global $MsgBoardtxt = "MsgBoard.html" Global $PrevMemDatatxt = "PrevMemData.txt" Global $MemDatatxt = "MemData.txt" Global $Indextxt = "Index.txt" Global $AllyLogojpg = "logo.jpg" ;Global varliables Global $totstr = "0" Global $totscore = "0" Global $prevtotscore = "0" Global $prevtotstr = "0" ;Initial allaince to load $f = FileOpen($ResDir & $Indextxt) Global $allypointer = FileReadLine($f, 1) FileClose($f) ;Tab globals Global $tabcur Global $tabprev = "0" ;========================================================================================== ;Declare onexit function OnAutoItExitRegister( "_OnExit") $WinMain = GUICreate($WinMainTitle, 750, 675) ;##################################################################### Global $Dummy = GUICtrlCreateDummy() ;# ADDED A DUMMY CONTROL ;##################################################################### ;Tabs $TabMain = _GUICtrlTab_Create($WinMain, 16, 95, 721, 20) ;Status bar Local $vPartEdge[2] = [500, 600] Local $vPartText[2] = [@Tab & _NowDate(), @TAB & $IsConnect] $StatusBarMain = _GUICtrlStatusBar_Create($WinMain, $vPartEdge, $vPartText) Global $AllyPic = GUICtrlCreatePic($ResDir & "" & $allypointer & $AllyLogojpg, 16, 15, 400, 100) $LabelMainLastUpdate = GUICtrlCreateLabel("Last Updated:", 428, 25, 70, 17) $LabLastUpdate = GUICtrlCreateLabel($LastUpdate, 503, 25, 80, 17) $LabIsUpToDate = GUICtrlCreateLabel($IsUpToDate, 473, 45, 80, 17) $LabMainProgVersion = GUICtrlCreateLabel($ProgVersion, 712, 5, 31, 17) $ButtonMainConnect = GUICtrlCreateButton("Connect", 430, 85, 147, 17) $ButtonMainSync = GUICtrlCreateButton("Sync", 592, 24, 147, 17) $ButtonMainWiki = GUICtrlCreateButton("WiKi", 592, 48, 147, 17) $ButtonMainMaps = GUICtrlCreateButton("Maps", 592, 72, 147, 17) $ButtonMainChat = GUICtrlCreateButton("Chat", 592, 96, 147, 17) ;Group alliance $GroupMainAlly = GUICtrlCreateGroup("Alliance:-", 16, 120, 721, 115) $LabMainAllyStr = GUICtrlCreateLabel("Total Strength:", 120, 183, 74, 17) $LabMainAllyScore = GUICtrlCreateLabel("Total Score:", 120, 208, 62, 17) $AllyStr = GUICtrlCreateLabel("-", 200, 183, 75, 17) $AllyScore = GUICtrlCreateLabel("-", 200, 208, 75, 17) $ProgressMainAllyStr = GUICtrlCreateProgress(120, 150, 475, 25) GUICtrlSetData(-1, 73) $LabMainStrAllyGainD = GUICtrlCreateLabel("/day", 315, 183, 75, 17) $LabMainStrAllyGainW = GUICtrlCreateLabel("/week", 415, 183, 75, 17) $LabMainStrAllyGainM = GUICtrlCreateLabel("/month", 520, 183, 90, 17) $LabMainScoreAllyGainD = GUICtrlCreateLabel("/day", 315, 208, 75, 17) $LabMainScoreAllyGainW = GUICtrlCreateLabel("/week", 415, 208, 75, 17) $LabMainScoreAllyGainM = GUICtrlCreateLabel("/month", 520, 208, 90, 17) $LabMainAllyHealth = GUICtrlCreateLabel("Health:", 330, 132, 40, 17) ;Group members $GroupMainMembers = GUICtrlCreateGroup("Members:-", 16, 240, 721, 241) $ListViewMainMembers = _GUICtrlListView_Create($WinMain, "", 32, 264, 690, 200, BitOR($LVS_SINGLESEL, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($ListViewMainMembers, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_TWOCLICKACTIVATE, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_AddColumn($ListViewMainMembers, "Member", 100) _GUICtrlListView_AddColumn($ListViewMainMembers, "Troops", 145) _GUICtrlListView_AddColumn($ListViewMainMembers, "Score", 145) _GUICtrlListView_AddColumn($ListViewMainMembers, "Co-ordinates", 300) Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListViewMainMembers)] ;Group message board $GroupMainMsgBoard = GUICtrlCreateGroup("Message Board:-", 16, 488, 721, 153) $oMainIE = _IECreateEmbedded() $MainIEControl = GUICtrlCreateObj($oMainIE, 27, 505, 700, 125) GUISetState(@SW_SHOW, $WinMain) ;Register interactions with the tab GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _StartUpOperations() ;############################################################### _GUICtrlListView_InsertItem($ListViewMainMembers,"Test") ; THIS LINE IS JUST FOR TEST; TO ADD AN ITEM TO LISTVIEW ;############################################################### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;################################################## Case $Dummy ; # CHECK FOR DUMMY CONTROL _EditMember(GUICtrlRead($Dummy)) ; # CALL THE _EditMember function outside of callback ;################################################## EndSwitch WEnd Func _StartUpOperations() _ReadMemData() _CalcAllyTotals() _CalcAllyRates() _StartMessageBoard() _StartTabs() EndFunc Func _OnExit() ;Destroy controls to free memory _GUICtrlListView_Destroy($ListViewMainMembers) _GUICtrlStatusBar_Destroy($StatusBarMain) _GUICtrlTab_Destroy($TabMain) EndFunc Func _ReadMemData() ;============================================ ; Update members list ;============================================ Local $f, $lc, $line, $i, $memdat ;Delete any previous items _GUICtrlListView_DeleteAllItems($ListViewMainMembers) $f = FileOpen($ResDir & "" & $allypointer & $MemDatatxt) $lc = _FileCountLines($ResDir & "" & $allypointer & $MemDatatxt) ;Loop through and parse data from file For $i = 1 To $lc $line = FileReadLine($f, $i) If $line = "~" Then ExitLoop EndIf $memdat = StringSplit($line, "|") ;Add data to listview _GUICtrlListView_AddItem($ListViewMainMembers, $memdat[1]) _GUICtrlListView_AddSubItem($ListViewMainMembers, ($i - 1), $memdat[2], 1) _GUICtrlListView_AddSubItem($ListViewMainMembers, ($i - 1), $memdat[3], 2) _GUICtrlListView_AddSubItem($ListViewMainMembers, ($i - 1), $memdat[4], 3) Next FileClose($f) EndFunc ;==>_ReadMemData Func _CalcAllyTotals() ;============================================ ; Calculate alliance totals ;============================================ Local $ic, $i, $tcval ;Delete any previous totals $totstr = "0" $totscore = "0" $ic = _GUICtrlListView_GetItemCount($ListViewMainMembers) ;Loop through and gather data from listview For $i = 1 To $ic $tcval = _GUICtrlListView_GetItemText($ListViewMainMembers, ($i - 1), 1) $tcval = StringReplace($tcval, ",", "") $sval = _GUICtrlListView_GetItemText($ListViewMainMembers, ($i - 1), 2) $sval = StringReplace($sval, ",", "") $totstr = $totstr + $tcval $totscore = $totscore + $sval Next ;Display data GUICtrlSetData($AllyStr, $totstr) GUICtrlSetData($AllyScore, Int(($totscore/1000))) EndFunc ;==>_CalcAllyTotals Func _CalcAllyRates() ;============================================ ; Calculate gains per day/week/month ;============================================ Local $f, $lc, $line, $memdat, $tcval, $sval, $scorepd, $strpd ;Delete any previous totals $prevtotstr = "0" $prevtotscore = "0" $f = FileOpen($ResDir & "" & $allypointer & $PrevMemDatatxt) $lc = _FileCountLines($ResDir & "" & $allypointer & $PrevMemDatatxt) ;Loop through and parse data from file For $i = 1 To $lc $line = FileReadLine($f, $i) If $line = "~" Then ExitLoop EndIf $memdat = StringSplit($line, "|") $tcval = $memdat[2] $tcval = StringReplace($tcval, ",", "") $sval = $memdat[3] $sval = StringReplace($sval, ",", "") $prevtotstr = $prevtotstr + $tcval $prevtotscore = $prevtotscore + $sval Next ;Convert data $scorepd = (($totscore - $prevtotscore) / _DateDiff("D", $LastUpdate, _NowCalcDate())) $strpd = (($totstr - $prevtotstr) / _DateDiff("D", $LastUpdate, _NowCalcDate())) ;Display data GUICtrlSetData($LabMainScoreAllyGainD, Int($scorepd/1000) & "/Day") GUICtrlSetData($LabMainScoreAllyGainW, (Int($scorepd*7/1000)) & "/Week") GUICtrlSetData($LabMainScoreAllyGainM, (Int($scorepd*30/1000)) & "/Month") GUICtrlSetData($LabMainStrAllyGainD, Int($strpd) & "/Day") GUICtrlSetData($LabMainStrAllyGainW, (Int($strpd*7)) & "/Week") GUICtrlSetData($LabMainStrAllyGainM, (Int($strpd*30)) & "/Month") FileClose($f) EndFunc ;==>_CalcAllyRates Func _StartMessageBoard() Local $body, $f, $lc, $line, $i, $crisscross ;Navigate to messageboard page _IENavigate($oMainIE, $ResDir & $MsgBoardtxt) $body = _IETagNameGetCollection($oMainIE, "body", 0) ;Loop through saved boards.txt and collect entries $f = FileOpen($ResDir & $SavedBoardtxt) $lc = _FileCountLines($ResDir & $SavedBoardtxt) For $i = 1 to $lc ;Check if even or odd number for table color If Mod($i, 2) = 0 Then $crisscross = "b0b0b0" Else $crisscross = "d0d0d0" EndIf $line = FileReadLine($f, $i) $line = StringSplit($line, "|") ;Display entries _IEDocInsertHTML($body, ' [i]' & $line[1] & "[/i] [b]" & $line[2] & ":[/b] " & $line[3] & ' ', "afterbegin") Next FileClose($f) EndFunc Func _StartTabs() Local $f, $lc, $line, $i ;Open file and count how many alliances $f = FileOpen($ResDir & $Indextxt) $lc = _FileCountLines($ResDir & $Indextxt) ;For every allaince loop through and create a tab For $i = 1 to $lc $line = FileReadLine($f, $i) _GUICtrlTab_InsertItem($TabMain, ($i-1) , $line) Next FileClose($f) EndFunc ;===================================================================== ; Need to tidy this code in here! ;===================================================================== #region Native function from UDF Tabs Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $hWndListView, $tInfo ;Declare which UDF controls to monitor $hWndTab = $TabMain If Not IsHWnd($TabMain) Then $hWndTab = GUICtrlGetHandle($TabMain) $hWndListView = $ListViewMainMembers If Not IsHWnd($ListViewMainMembers) Then $hWndTab = GUICtrlGetHandle($ListViewMainMembers) ;Native DLL stuff $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") ;Begin events check Switch $hWndFrom ;Events for tabmain Case $hWndTab Switch $iCode Case $NM_CLICK ;User clicks on tab control ;Check if a new tab has been selected $tabcur = _GUICtrlTab_GetCurSel($TabMain) If $tabcur <> $tabprev Then ;Tab has changed so load new tab data _TabChange() ;Set the previous tab to current tab $tabprev = $tabcur EndIf EndSwitch ;Events for listviewmain Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ;A column is clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ;Sort items _GUICtrlListView_SimpleSort($ListViewMainMembers, $B_DESCENDING, DllStructGetData($tInfo, "SubItem")) Case $LVN_ITEMACTIVATE ;An item is double clicked ;Get member name and pass to editmember func $itemcur = _GUICtrlListView_GetSelectedIndices($ListViewMainMembers) $itemcur = _GUICtrlListView_GetItem($ListViewMainMembers, $itemcur) ;################################################## GUICtrlSendToDummy($Dummy,$itemcur[3]) ; # INSTEAD OF CALLING _EditMember function here in this callback we send ;################################################## a message to our dummy control, that will be processed in main loop EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc #endregion Func _TabChange() Local $f $f = FileOpen($ResDir & $Indextxt) ;Get alliance tab change points to $allypointer = FileReadLine($f, ($tabcur+1)) ;Update controls with new allaince data _ReadMemData() _CalcAllyTotals() _CalcAllyRates() ;Update allaince logo GUICtrlDelete($AllyPic) $AllyPic = GUICtrlCreatePic($ResDir & "" & $allypointer & $AllyLogojpg, 16, 15, 400, 100) FileClose($f) EndFunc Func _EditMember($mem) Local $f, $lc, $i, $line ;Create Edit Member Window $WinEditMem = GUICreate($mem, 595, 227, 384, 145, Default, Default, $WinMain) $LabEditMemName = GUICtrlCreateLabel($mem, 112, 32, 32, 17) $LabEditMemScore = GUICtrlCreateLabel("Score:", 16, 80, 35, 17) $LabEditMemTc = GUICtrlCreateLabel("Troop Count:", 16, 112, 66, 17) $LabEditMemCoord = GUICtrlCreateLabel("Coords", 16, 144, 37, 17) $InputEditMemScore = GUICtrlCreateInput("-", 88, 80, 201, 21) $InputEditMemTc = GUICtrlCreateInput("-", 88, 112, 201, 21) $InputEditMemCoord = GUICtrlCreateInput("-", 88, 144, 201, 21) $EditEditMemNote = GUICtrlCreateEdit("Notes...", 296, 8, 289, 161) $ButtonEditMemSave = GUICtrlCreateButton("Save", 200, 184, 83, 25) $ButtonEditMemCancel = GUICtrlCreateButton("Cancel", 296, 184, 83, 25) GUISetState(@SW_SHOW, $WinEditMem) ;Get member data and display $f = FileOpen($ResDir & "" & $allypointer & $MemDatatxt) $lc = _FileCountLines($ResDir & "" & $allypointer & $MemDatatxt) ;Cycle through memdat.txt For $i = 1 to $lc $line = FileReadLine($f, $i) $line = StringSplit($line, "|") If $line[1] = $mem Then ;If the name of the member = name passed to function ;Update controls with member data GUICtrlSetData($InputEditMemTc, $line[2]) GUICtrlSetData($InputEditMemScore, $line[3]) GUICtrlSetData($InputEditMemCoord, $line[4]) ;GUICtrlSetData($InputEditMemCoord, NOTES placeholder) ExitLoop EndIf Next MsgBox(0, "", "1") ;Window events While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox(0, "", "3") ExitLoop Case $ButtonEditMemCancel MsgBox(0, "", "4") ExitLoop EndSwitch WEnd ;Delete window on way out of function MsgBox(0, "", "7") FileClose($f) GUIDelete($WinEditMem) EndFunc
    1 point
  3. sounds like an integrity question. Maybe using MD5sum could be useful to you? this would ensure that a renamed binary of the same name would not be able to run unless the checksum matched that of the original, which isn't impossible, but it's less probable.
    1 point
  4. use FileInstall() so that noone can rename until run. use FileGet*Size() or something similar to identify file.
    1 point
×
×
  • Create New...