Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/10/2016 in all areas

  1. Version build 2016-05-07

    1,023 downloads

    Some Graphical Examples using GDI+ Vol. II (33 examples) This is the continuation of "Some Graphical Examples using GDI+ Vol. I". Have fun.
    2 points
  2. it all goes back to the need to maintain a single DOS session. if you do not want to alter existing batch file, then create a "parent" batch file that will call the existing bat and the utility, like this (not tested!): Global $sCallerScript = @ScriptDir & '\mybat.bat' FileWriteLine($sCallerScript, 'call \\server\share\path\filename.bat') FileWriteLine($sCallerScript, 'c:\some\path\folder\utility.exe utility -opt=1 -opt=2 -opt=3') $DOS = Run($sCallerScript, "", @SW_MAXIMIZE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS, True)
    2 points
  3. Added six more examples: 3D Object Rotation v1.1.6.au3 -> text 3D rotation around a semi transparent sphere 3D Object Rotation v1.1.7.au3 -> 3D scroller around an opaque sphere 3D Object Rotation v1.2.6.au3 -> 3D world map rotation using pathes (slow because of high polygon count!) Particles - Repulsive Force Sim. v1.0.au3 -> press lmb to play with red ellipse Smoke Sim v2.au3 -> smoking pipe Wavy Chars v1.1.au3 -> some "nervous" chars
    2 points
  4. Here some photos: Guess who is who!
    2 points
  5. So after many weekends of battling with this I finally figured it; then I automated it. This script includes icon sushi (which is used to remove the 256 x 256 elements from each .ico) and RDG (to compile the icons into dll). I had to idiot proof this for when I inevitably forget how to do it. First GUI will ask you to choose a name (among other things) for your .dll file. Next GUI is a drag-and-drop box. Drag-and-drop your .ico files into the box and click Go. Error checking is minimal; it works fine for me but YRMV. I'm no master programmer at all but if this script can help you as much as it helped me then cool. Download: ico2dll.Exe Known issues: .ico's containing any layers larger than 256 x 256 px will be ignored by icon sushi ico2dll only registers one drag-and-drop event so put all your required icons into one folder; then drag-and-drop them into ico2dll Extra info: Basically, the RC.exe that is included with Visual Studio doesn't seem to support 256 x 256 or larger icons when creating a resource-only .dll file. This script uses icon sushi to remove all 256 x 256 elements from your .ico files (if your icon file contains any layers larger than 256 x 256 then you will have to remove those manually through a program like gimp) before compiling them into the .dll. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\ICONS\Capital18-Ethereal-2-Mimetypes-dll.ico #AutoIt3Wrapper_Outfile=ico2dll.Exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiEdit.au3> #include <File.au3> #include <Misc.au3> #include <Array.au3> Opt("trayicondebug", 1) $tmp = "C:\ico2dlltemp\" $tmprmv = "C:\ico2dlltemp\rmv\" If FileExists($tmp) Then DirRemove($tmp, 1) Sleep(100) DirCreate($tmprmv) Global $FileName, $ListViewIndexSel = -1, $PathAllExist, $RCFile, $vpath Global $szDrive, $szDir, $szFName, $szExt, $dBox, $iData, $vdata2, $lang, $iData2 Global $TmpDir = @TempDir & "\ResDllGen" Global $TmpDirplusSlash = @TempDir & "\ResDllGen\" Global $Res_List, $Res_Name, $Res_Type, $Res_Path, $StrLenPath, $Bloc, $LangHex If FileExists($TmpDir) Then DirRemove($TmpDir, 1) If FileExists($TmpDirplusSlash) Then DirRemove($TmpDirplusSlash, 1) Sleep(100) DirCreate($TmpDirplusSlash) $rnd = Random(999, 99999, 1) DirCreate(@ScriptDir & "\tools\") DirCreate(@ScriptDir & "\Languages\") FileInstall("aicon.exe", @ScriptDir & "\aicon.exe") FileInstall("aicon.ini", @ScriptDir & "\aicon.ini") FileInstall("brushes", @ScriptDir & "\brushes") FileInstall("Languages\English.lng", @ScriptDir & "\Languages\English.lng") FileInstall("Languages\“ú–{Œê.lng", @ScriptDir & "\Languages\“ú–{Œê.lng") FileInstall("Languages\Default.lng", @ScriptDir & "\Languages\Default.lng") ;FileInstall("G:\autoo\resdll\generator\RDG.exe", @ScriptDir & "\RDG.exe") FileInstall("tools\cvtres.exe", @ScriptDir & "\tools\cvtres.exe") FileInstall("tools\DLLSZ.ico", @ScriptDir & "\tools\DLLSZ.ico") FileInstall("tools\link.exe", @ScriptDir & "\tools\link.exe") FileInstall("tools\mspdb50.dll", @ScriptDir & "\tools\mspdb50.dll") FileInstall("tools\rc.exe", @ScriptDir & "\tools\rc.exe") FileInstall("tools\RCdll.dll", @ScriptDir & "\tools\RCdll.dll") Const $SP = "#~#" Dim $Lang _SelectLanguage() $Res_Gui_2 = GUICreate($lang[22], 390, 470, -1, -1, -1) ; DLL Info $FileVersion_Title = GUICtrlCreateLabel($lang[23] & " :", 110, 8, 171, 28) ; DLL Informations GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlCreateLabel($lang[24], 15, 60, 125, 20) ; Dll Filename GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_File_Name = GUICtrlCreateInput($lang[25], 175, 60, 140, 21) ; MyDll GUICtrlCreateLabel(".Dll", 318, 63, 30, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlCreateLabel($lang[26], 16, 92, 130, 20) ; File Version GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_Ver1 = GUICtrlCreateInput("01", 175, 92, 35, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $UpD1 = GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 99, 01) $Dll_Ver2 = GUICtrlCreateInput("00", 220, 92, 35, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $UpD2 = GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 99) $Dll_Ver3 = GUICtrlCreateInput("0000", 265, 92, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $UpD3 = GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 9999) $Dll_Ver4 = GUICtrlCreateInput("0000", 325, 92, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER)) $UpD4 = GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 9999) GUICtrlCreateLabel($lang[27], 16, 127, 150, 20) ; Product Version GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_PVer1 = GUICtrlCreateLabel("01,00,0000,0000", 175, 130, 90, 20) $Dll_PVer2 = GUICtrlCreateInput("", 265, 127, 110, 21) GUICtrlCreateLabel($lang[28], 16, 165, 150, 20) ; Product Name GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_Prod_Name = GUICtrlCreateInput($lang[29], 175, 165, 200, 21) ; Name_Of_Your_Product GUICtrlCreateLabel($lang[30], 16, 200, 150, 20) ; Compagny Name GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_Compagny = GUICtrlCreateInput($lang[31], 175, 200, 200, 21) ; Type_Your_Company GUICtrlCreateLabel($lang[32], 16, 235, 150, 20) ; Legal Copyright GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_Copyright = GUICtrlCreateInput($lang[33], 175, 235, 200, 21) ; Copyright_(C)_2007-2008 GUICtrlCreateLabel($lang[34], 16, 270, 150, 20) ; File Description GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_File_Desc = GUICtrlCreateInput($lang[35], 175, 270, 200, 21) ; Type_Your_Description GUICtrlCreateLabel($lang[36], 16, 305, 150, 20) ; Language GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_Lang = GUICtrlCreateCombo("", 175, 305, 90, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $lang[37], $lang[38]) ; English|French ; English ; See http://msdn.microsoft.com/en-us/library/aa381058%28VS.85%29.aspx for value. GUICtrlCreateLabel($lang[39], 16, 340, 150, 20) ; File OS GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_OS = GUICtrlCreateCombo("", 175, 340, 90, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $lang[40], $lang[41]) ; 0x40004 ; 0x40004 GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel($lang[42], 16, 375, 150, 20) ; File Type GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Dll_File_Type = GUICtrlCreateCombo("", 175, 375, 90, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, $lang[43], $lang[44]) ; 0x2 ; 0x2 GUICtrlSetState(-1, $GUI_DISABLE) $Btn_OK2 = GUICtrlCreateButton($lang[45], 160, 432, 75, 25) ; OK GUISetState(@SW_SHOW, $Res_Gui_2) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Btn_OK2 If GUICtrlRead($Dll_File_Name) = $lang[25] Then ; MyDll MsgBox(32 + 8192, $lang[53], $lang[54] & @TAB) ; Dll File Name ; Please, Enter The Name Of Your Dll GUICtrlSetState($Dll_File_Name, $GUI_FOCUS) Else GUICtrlSetData($Dll_File_Name, StringReplace(GUICtrlRead($Dll_File_Name), " ", "_")) SetDllData() GUIDelete($Res_Gui_2) AddIcons() EndIf Case $UpD1, $UpD2, $UpD3, $UpD4 _UpdateVerNum() Case $GUI_EVENT_PRIMARYDOWN _UpdateVerNum() Case $GUI_EVENT_CLOSE TraySetState(2) Exit EndSwitch WEnd Func AddIcons() Global $__aGUIDropFiles = 0, $aDrop_List = 0 Global $txtInput = "Drag and drop your .ico files here" $mGUI = GUICreate("ico2dll", 900, 400, -1, -1, "", $WS_EX_ACCEPTFILES) $dBox = GUICtrlCreateEdit($txtInput, 10, 10, 874, 300) GUICtrlSetState($dBox, $GUI_DROPACCEPTED) $gBut = GUICtrlCreateButton("Go", 10, 320, 75, 25) $eBut = GUICtrlCreateButton("Exit", 810, 320, 75, 25) GUISetState() GUIRegisterMsg($WM_DROPFILES, 'On_WM_DROPFILES') While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE TraySetState(2) DirRemove($tmp, 1) Exit Case $eBut TraySetState(2) DirRemove($tmp, 1) Exit Case $GUI_EVENT_DROPPED GUICtrlSetData($dBox, "") For $i = 1 To $aDrop_List[0] $old = GUICtrlRead($dBox) $new = $old & $aDrop_List[$i] & @CRLF GUICtrlSetData($dBox, $new) Next Case $gBut $check = GUICtrlRead($dBox) If $check = $txtInput Then MsgBox(0, "Error", "You must drag-and-drop some .ico files into the box") ContinueLoop Else $iData = StringSplit($check, @LF) EndIf GUIDelete($mGUI) _MouseTrap(0, 0, 1, 1) CopyTemp() Rmv256() GenDll() _MouseTrap() EndSwitch WEnd EndFunc ;==>AddIcons Func Rmv256() DirCreate($tmprmv) IniWrite(@ScriptDir & "\aicon.ini", "Option", "ListViewMode", "0") IniWrite(@ScriptDir & "\aicon.ini", "Option", "InitialDir", "C:\ico2dlltemp") Global $PID2 = "" $last = "placeholder" $Amow = 100 $hWnd2 = "" $aPID = Run(@ScriptDir & "\aicon.exe") WinWaitActive("@icon sushi", "", 10) $theWinlist = WinList() Do For $i = 1 To $theWinlist[0][0] If $theWinlist[$i][0] <> "" Then $iPID2 = WinGetProcess($theWinlist[$i][1]) If $iPID2 = $aPID Then $hWnd2 = $theWinlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd2 <> 0 Sleep(1000) Send("{ALT}FO") WinWaitActive("Open Source File(s)", "", 10) Sleep(200) ControlClick("Open Source File(s)", "", 1) Sleep(200) Send("^a{ENTER}") Sleep(200) Do Sleep(200) If WinExists("@icon sushi", "is not a supported file") Then Sleep(200) Send("{ENTER}") EndIf $treeCtrl = ControlGetHandle($hWnd2, "", "[CLASS:TListView; INSTANCE:1]") ControlClick($hWnd2, "", $treeCtrl, "", "", 34, 29) $textCtrl = ControlGetHandle($hWnd2, "", "[CLASS:TPanel; INSTANCE:3]") Until ControlGetText($hWnd2, "", $textCtrl) <> "" Sleep(200) While 1 $textSrch = ControlGetText($hWnd2, "", $textCtrl) If $textSrch = $last Then ExitLoop If StringInStr($textSrch, "256 x 256") Then Send("{ALT}L") Sleep(30) Send("D") Sleep(30) Send("D{ENTER}") Else Send("{DOWN}") EndIf $last = $textSrch WEnd Sleep(200) Send("{ALT}LA") Sleep(200) Send("{ALT}TG") WinWaitActive("Browse for Folder", "", 10) $hnd = WinGetHandle("Browse for Folder") ControlClick($hnd, "", 14145) Sleep(100) Send("ico2dlltemp") Sleep(100) Send("{RIGHT}") Sleep(100) Send("{RIGHT}") Sleep(100) Send("{ENTER}") WinClose($hWnd2) WinWaitClose($hWnd2) EndFunc ;==>Rmv256 Func GenDll() If _GenerateRC() Then $SName = $Dll_File_Name FileInstall("./Tools/cvtres.exe", $TmpDir & "\", 1) FileInstall("./Tools/link.exe", $TmpDir & "\", 1) FileInstall("./Tools/mspdb50.dll", $TmpDir & "\", 1) FileInstall("./Tools/RC.exe", $TmpDir & "\", 1) FileInstall("./Tools/RCdll.dll", $TmpDir & "\", 1) $i = 1 $IdxCount = $vdata2[0] - 2 For $i = 0 To $IdxCount $RC_Res_FilePath = $vdata2[$i + 1] FileCopy($RC_Res_FilePath, $TmpDir & "\", 9) Next RunWait(@ComSpec & ' /c ' & 'rc /r ' & $SName & '.rc', $TmpDir, @SW_HIDE) RunWait(@ComSpec & ' /c ' & 'link /nodefaultlib /dll /machine:ix86 /noentry /out:' & _ $SName & '.dll ' & $SName & '.res', $TmpDir, @SW_HIDE) If FileExists($TmpDir & "\" & $SName & ".dll") Then FileCopy($TmpDir & "\" & $SName & ".dll", "C:\" & $SName & "-" & $rnd & ".dll", 1) MsgBox(0, "Success", "File created successfuly at:" & @CRLF & "C:\" & $SName & "-" & $rnd & ".dll") DirRemove($tmp) DirRemove($TmpDir) Exit Else MsgBox(16 + 8192, $lang[51], $lang[52] & @TAB) ; Error ; Error Creating Dll File Exit EndIf ;ShellExecute($TmpDir) EndIf EndFunc ;==>GenDll Func CopyTemp() $i = 1 For $i = 1 To $iData[0] - 1 $iData2 = StringReplace($iData[$i], @CR, "") FileCopy($iData2, $tmp & $i & ".ico", 9) If @error Then MsgBox(0, "Failed", "Unknown error. Sorry.") Exit EndIf Next EndFunc ;==>CopyTemp Func _CleanInput() _GUICtrlListView_SetItemSelected($Res_List, $ListViewIndexSel, False) $ListViewIndexSel = "" GUICtrlSetData($Res_Name, "") GUICtrlSetData($Res_Type, "ICON") GUICtrlSetData($Res_Path, "") EndFunc ;==>_CleanInput Func _PathLen($PathIn) If StringLen($PathIn) > $StrLenPath Then $StrLenPath = StringLen($PathIn) + 10 GUICtrlSendMsg($Res_List, $LVM_SETCOLUMNWIDTH, 2, $StrLenPath * 5) EndIf EndFunc ;==>_PathLen Func _UpdateVerNum() GUICtrlSetData($Dll_Ver1, StringFormat("%002s", GUICtrlRead($Dll_Ver1))) GUICtrlSetData($Dll_Ver2, StringFormat("%002s", GUICtrlRead($Dll_Ver2))) GUICtrlSetData($Dll_Ver3, StringFormat("%004s", GUICtrlRead($Dll_Ver3))) GUICtrlSetData($Dll_Ver4, StringFormat("%004s", GUICtrlRead($Dll_Ver4))) GUICtrlSetData($Dll_PVer1, StringFormat("%002s", GUICtrlRead($Dll_Ver1)) & "," & _ StringFormat("%002s", GUICtrlRead($Dll_Ver2)) & "," & _ StringFormat("%004s", GUICtrlRead($Dll_Ver3)) & "," & _ StringFormat("%004s", GUICtrlRead($Dll_Ver4))) EndFunc ;==>_UpdateVerNum Func _GenerateRC() $vdata2 = _FileListToArray($tmprmv) $i = 1 For $i = 1 To $vdata2[0] FileCopy($tmprmv & $vdata2[$i], $TmpDir & "\" & $i & ".ico", 9) Next $vdata2 = _FileListToArray($tmprmv) $IdxCount = $vdata2[0] $i = 1 If $IdxCount > 0 Then $RCFile = $TmpDir & "\" & $Dll_File_Name & ".rc" $hRCOut = FileOpen($RCFile, 1) If $hRCOut = -1 Then Return 0 $RC_Res_Type = "ICON" For $i = 1 To $IdxCount FileCopy($tmprmv & $vdata2[$i], $TmpDir & "\" & $i & ".ico", 9) $RC_Res_Name = $i $RC_Res_FilePath = $TmpDir & "\" & $i & ".ico" _PathSplit($RC_Res_FilePath, $szDrive, $szDir, $szFName, $szExt) $RC_Res_File = $szFName & $szExt FileWriteLine($RCFile, $RC_Res_Name & @TAB & $RC_Res_Type & @TAB & '"' & $RC_Res_File & '"') Next FileWriteLine($RCFile, @CRLF & '1 VERSIONINFO' & @CRLF & _ 'FILEVERSION ' & $Dll_PVer1 & @CRLF & _ 'PRODUCTVERSION ' & $Dll_PVer1 & @CRLF & _ 'FILEOS ' & $Dll_OS & @CRLF & _ 'FILETYPE ' & $Dll_File_Type & @CRLF & _ '{' & @CRLF & 'BLOCK "StringFileInfo"' & @CRLF & '{' & @CRLF & _ @TAB & 'BLOCK "' & $Bloc & '"' & @CRLF & @TAB & '{' & @CRLF & _ @TAB & @TAB & 'VALUE "CompanyName", "' & $Dll_Compagny & '"' & @CRLF & _ @TAB & @TAB & 'VALUE "FileDescription", "' & $Dll_File_Desc & '"' & @CRLF & _ @TAB & @TAB & 'VALUE "FileVersion", "' & $Dll_PVer1 & '"' & @CRLF & _ @TAB & @TAB & 'VALUE "InternalName", "' & $Dll_File_Name & '.dll"' & @CRLF & _ @TAB & @TAB & 'VALUE "LegalCopyright", "' & $Dll_Copyright & '"' & @CRLF & _ @TAB & @TAB & 'VALUE "OriginalFilename", "' & $Dll_File_Name & '.dll"' & @CRLF & _ @TAB & @TAB & 'VALUE "ProductName", "' & $Dll_Prod_Name & '"' & @CRLF & _ @TAB & @TAB & 'VALUE "ProductVersion", "' & $Dll_PVer1 & " " & $Dll_PVer2 & '"' & @CRLF & _ @TAB & @TAB & 'VALUE "Comments", ""' & @CRLF & _ @TAB & '}' & @CRLF & '}' & @CRLF & @CRLF & 'BLOCK "VarFileInfo"' & @CRLF & '{' & @CRLF & _ @TAB & 'VALUE "Translation", ' & $LangHex & @CRLF & '}' & @CRLF & '}') FileClose($hRCOut) Return 1 Else Return 0 EndIf EndFunc ;==>_GenerateRC Func On_WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) ; Credit to ProgAndy for DLL calls #forceref $hWnd, $iMsg, $lParam Local $iSize, $pFileName ; Get number of files dropped Local $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 0) ; Reset array to correct size Global $aDrop_List[$aRet[0] + 1] = [$aRet[0]] ; And add item names For $i = 0 To $aRet[0] - 1 $aRet = DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $iSize = $aRet[0] + 1 $pFileName = DllStructCreate("wchar[" & $iSize & "]") DllCall("shell32.dll", "int", "DragQueryFileW", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $iSize) $aDrop_List[$i + 1] = DllStructGetData($pFileName, 1) $pFileName = 0 Next ; Send the count to trigger the drop function in the main loop GUICtrlSendToDummy($dBox, $aDrop_List[0]) EndFunc ;==>On_WM_DROPFILES Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ;#forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $Res_List If Not IsHWnd($Res_List) Then $hWndListView = GUICtrlGetHandle($Res_List) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $ListViewIndexSel = DllStructGetData($tInfo, "Index") GUICtrlSetData($Res_Name, _GUICtrlListView_GetItemText($hWndListView, $ListViewIndexSel, 0)) GUICtrlSetData($Res_Type, _GUICtrlListView_GetItemText($hWndListView, $ListViewIndexSel, 1)) GUICtrlSetData($Res_Path, _GUICtrlListView_GetItemText($hWndListView, $ListViewIndexSel, 2)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func SetDllData() Switch GUICtrlRead($Dll_Lang) Case 'French' Or 'Francais' $Bloc = '040C04B0' $LangHex = '0x040C 0x04B0' Case Else ; 'English' Or 'Anglais' $Bloc = '040904B0' $LangHex = '0x0409 0x04B0' EndSwitch $Dll_File_Name = StringReplace(GUICtrlRead($Dll_File_Name), " ", "_") $Dll_PVer1 = GUICtrlRead($Dll_PVer1) $Dll_PVer2 = GUICtrlRead($Dll_PVer2) $Dll_OS = GUICtrlRead($Dll_OS) $Dll_File_Type = GUICtrlRead($Dll_File_Type) $Dll_Compagny = GUICtrlRead($Dll_Compagny) $Dll_File_Desc = GUICtrlRead($Dll_File_Desc) $Dll_Copyright = GUICtrlRead($Dll_Copyright) $Dll_Prod_Name = GUICtrlRead($Dll_Prod_Name) EndFunc ;==>SetDllData ; Function to select language. Func _SelectLanguage() If StringInStr("040c,080c,0c0c,100c,140c,180c", @OSLang) Then RDG_FR() ; French Language Else RDG_EN() ; English Language EndIf $Lang = StringSplit($Lang, $SP, 1) EndFunc ; English Language. Func RDG_EN() $Lang = "Resource DLL Generator" & $SP $Lang &= "Resource Name" & $SP $Lang &= "Type Name Without Space (Max len 10)" & $SP $Lang &= "Resource Type" & $SP $Lang &= "Choose Resource Type" & $SP $Lang &= "Resource Path" & $SP $Lang &= "Select File First" & $SP $Lang &= "Path Of The Resource File" & $SP $Lang &= "Select Path Of The Resource File First" & $SP $Lang &= "Delete Resource" & $SP $Lang &= "Delete Selected Resource" & $SP $Lang &= "Add Resource" & $SP $Lang &= "Add or Update Resource" & $SP $Lang &= " Name | Type | Path " & $SP $Lang &= "Clic Twice To Edit An Item" & $SP $Lang &= "Exit" & $SP $Lang &= "Exit Program" & $SP $Lang &= "Dll Informations" & $SP $Lang &= "Chose Dll Informations" & $SP $Lang &= "Generate Dll" & $SP $Lang &= "Generate The Dll" & $SP $Lang &= "DLL Info" & $SP $Lang &= "DLL Informations" & $SP $Lang &= "Dll Filename" & $SP $Lang &= "MyDll" & $SP $Lang &= "File Version" & $SP $Lang &= "Product Version" & $SP $Lang &= "Product Name" & $SP $Lang &= "Name_Of_Your_Product" & $SP $Lang &= "Compagny Name" & $SP $Lang &= "Type_Your_Compagny" & $SP $Lang &= "Legal Copyright" & $SP $Lang &= "Copyright_(C)_2007-2008" & $SP $Lang &= "File Description" & $SP $Lang &= "Type_Your_Description" & $SP $Lang &= "Language" & $SP $Lang &= "English|French" & $SP $Lang &= "English" & $SP $Lang &= "File OS" & $SP $Lang &= "0x40004" & $SP $Lang &= "0x40004" & $SP $Lang &= "File Type" & $SP $Lang &= "0x2" & $SP $Lang &= "0x2" & $SP $Lang &= "OK" & $SP $Lang &= "Select file to add In DLL" & $SP $Lang &= "All" & $SP $Lang &= "Select The Destination Of Dll File" & $SP $Lang &= "Succes" & $SP $Lang &= "Dll successfully saved on" & $SP $Lang &= "Error" & $SP $Lang &= "Error Creating Dll File" & $SP $Lang &= "Dll File Name" & $SP $Lang &= "Please, Enter The Name Of Your Dll" EndFunc ; French Language. Func RDG_FR() $Lang = "Ressource DLL Generator" & $SP $Lang &= "Nom de la ressource" & $SP $Lang &= "Tapez le nom sans espace (Max 10 caractères)" & $SP $Lang &= "Type de la ressource" & $SP $Lang &= "Choisissez un type de ressource" & $SP $Lang &= "Chemin de la ressource" & $SP $Lang &= "Choisir d'abord le fichier de ressource" & $SP $Lang &= "Chemin du fichier de ressource" & $SP $Lang &= "Sélectionnez le fichier de ressource" & $SP $Lang &= "Supprime ressource" & $SP $Lang &= "Supprime la ressource sélectionnée." & $SP $Lang &= "Ajoute ressource" & $SP $Lang &= "Ajoute ou met à jour la ressource." & $SP $Lang &= " Nom | Type | Chemin " & $SP $Lang &= "Cliquez deux fois pour éditer une ressource." & $SP $Lang &= "Sortie" & $SP $Lang &= "Sortie du programme." & $SP $Lang &= "Informations Dll" & $SP $Lang &= "Règlez les information de la Dll." & $SP $Lang &= "Générer la Dll" & $SP $Lang &= "Générez la Dll" & $SP $Lang &= "Info DLL" & $SP $Lang &= "Informations DLL" & $SP $Lang &= "Nom de la Dll" & $SP $Lang &= "MaDll" & $SP $Lang &= "Version du fichier" & $SP $Lang &= "Version du produit" & $SP $Lang &= "Nom du produit" & $SP $Lang &= "Nom_de_votre_produit" & $SP $Lang &= "Nom de la société" & $SP $Lang &= "Nom_de_votre_société" & $SP $Lang &= "Copyright légale" & $SP $Lang &= "Copyright_(C)_2007-2008" & $SP $Lang &= "Description du fichier" & $SP $Lang &= "Entrez_votre_description" & $SP $Lang &= "Langue" & $SP $Lang &= "Anglais|Français" & $SP $Lang &= "Français" & $SP $Lang &= "Système de fichiers" & $SP $Lang &= "0x40004" & $SP $Lang &= "0x40004" & $SP $Lang &= "Type de fichiers" & $SP $Lang &= "0x2" & $SP $Lang &= "0x2" & $SP $Lang &= "OK" & $SP $Lang &= "Sélectionnez le fichier à ajouter à la DLL" & $SP $Lang &= "Tout Fichier" & $SP $Lang &= "Sélectionnez la destination de la Dll" & $SP $Lang &= "Succés" & $SP $Lang &= "Dll sauvegardée avec succés sur" & $SP $Lang &= "Erreur" & $SP $Lang &= "Erreur lors de la création de la Dll" & $SP $Lang &= "Nom du fichier Dll" & $SP $Lang &= "Veuillez entrer le nom de la Dll" EndFunc ico2dll.Exe
    1 point
  6. The triggering of_WM_NOTIFY is not permanentely: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <GuiListView.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $tagNMCUSTOMDRAW = "struct;" & $tagNMHDR & ";dword dwDrawStage;handle hdc;" & $tagRECT & _ ";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" ; Title TextCol BkCol - colours in BGR Global $aHdrData[][] = [["Tom", 0x000000, 0x00FFFF], _ ["Dick", 0x00FFFF, 0x0000FF], _ ["Harry", 0xFF0000, 0xFFCCCC]] $hGUI = GUICreate("Set Listview Header Colour ", 500, 300) $cListView = GUICtrlCreateListView(" | | ", 10, 10, 480, 280) _GUICtrlListView_SetExtendedListViewStyle($cListView, $LVS_EX_FULLROWSELECT) ; BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ;Get header handle Global $hHeader = _GUICtrlListView_GetHeader($cListView) ; Get the font of the Header control (credit KaFu) Local $hDC = _WinAPI_GetDC($hHeader) Local $hFont = _SendMessage($hHeader, $WM_GETFONT) Local $hObject = _WinAPI_SelectObject($hDC, $hFont) Local $tLogFont = DllStructCreate($tagLOGFONT) _WinAPI_GetObject($hFont, DllStructGetSize($tLogFont), DllStructGetPtr($tLogFont)) _WinAPI_SelectObject($hDC, $hObject) _WinAPI_ReleaseDC($hHeader, $hDC) Local $iWeight = DllStructGetData( $tLogFont, "Weight" ) ; Bold DllStructSetData( $tLogFont, "Weight", BitOR( $iWeight, $FW_BOLD ) ) $hHdrFont = _WinAPI_CreateFontIndirect( $tLogFont ) For $i = 1 To 15 _GUICtrlListView_AddItem($cListView, "Item" & $i) _GUICtrlListView_AddSubItem($cListView, $i - 1, "SubItem" & $i, 1) _GUICtrlListView_AddSubItem($cListView, $i - 1, "SubItem" & $i, 2) Next _GUICtrlListView_SetColumnWidth($cListView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($cListView, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($cListView, 2, $LVSCW_AUTOSIZE_USEHEADER) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return If DllStructGetData($tStruct, 1) = $hHeader Then Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) Switch $iCode Case $NM_CUSTOMDRAW Local $tNMCustomDraw = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMCustomDraw, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify parent window of any item related drawing operations Case $CDDS_ITEMPREPAINT ; Before an item is drawn: Default painting (frames and background) Return $CDRF_NOTIFYPOSTPAINT ; Notify parent window of any post item related drawing operations Case $CDDS_ITEMPOSTPAINT ; After an item is drawn: Custom painting (item texts) Local $tRECT = DllStructCreate($tagRECT) Local $iIndex = DllStructGetData($tNMCustomDraw, "dwItemSpec") ; Item index Local $hDC = DllStructGetData($tNMCustomDraw, "hdc") ; Device context _WinAPI_SelectObject($hDC, $hHdrFont) ; Set text font _WinAPI_SetBkMode($hDC, $TRANSPARENT) ; Transparent background _WinAPI_SetTextColor( $hDC, $aHdrData[$iIndex][1]) ; Set text colour ; Get header section size DllStructSetData($tRECT, 1, DllStructGetData($tNMCustomDraw, 6) + 1) DllStructSetData($tRECT, 2, DllStructGetData($tNMCustomDraw, 7) + 1) DllStructSetData($tRECT, 3, DllStructGetData($tNMCustomDraw, 8) - 2) DllStructSetData($tRECT, 4, DllStructGetData($tNMCustomDraw, 9) - 2) ; Set and draw back colour ;~ Local $hBrush = _WinAPI_CreateSolidBrush($aHdrData[$iIndex][2]) ;~ _WinAPI_FillRect($hDC, $tRECT, $hBrush) Switch $iIndex Case 2 Anim($hDC, $tRECT) Case Else Local Const $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) Local Const $hBrush = _GDIPlus_LineBrushCreate($tRECT.Left, $tRECT.Top, $tRECT.Right, $tRECT.Bottom, 0xFF000000 + $aHdrData[$iIndex][1], 0xFFFFFFFF, 1) _GDIPlus_GraphicsFillRect($hGfx, $tRECT.Left, $tRECT.Top, $tRECT.Right, $tRECT.Bottom, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) EndSwitch ; Write text If $iIndex < _GUICtrlListView_GetColumnCount($cListView) Then _WinAPI_DrawText ( $hDC, $aHdrData[$iIndex][0], $tRECT, $DT_CENTER + $DT_VCENTER ) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndIf EndFunc ;==>_WM_NOTIFY Func Anim($hDC, $tRECT) Local Const $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4) Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000), $fSize = 4 Local Static $fX = 10, $fY = 10, $bSet = False, $fVX, $fVY If Not $bSet Then $fVX = Random(0, 1, 1) ? Random(-1.5, -0.5) : Random(0.5, 1.5) $fVY = Random(0, 1, 1) ? Random(-1.5, -0.5) : Random(0.5, 1.5) $bSet = True EndIf $fX += $fVX $fY += $fVY If BitOR($tRECT.Left + $fX <= $tRECT.Left, $tRECT.Left + $fX - $fSize - 2 >= $tRECT.Right - $fSize - 2) Then $fVX *= -1 If BitOR($tRECT.Top + $fY <= $tRECT.Top, $tRECT.Top + $fY - $fSize - 2 >= $tRECT.Bottom - $tRECT.Top - $fSize - 2) Then $fVY *= -1 $fX = ($fX > $tRECT.Right) ? $tRECT.Right - $fSize : $fX _GDIPlus_GraphicsFillEllipse($hGfx, $tRECT.Left + $fX, $tRECT.Top + $fY, $fSize, $fSize, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) EndFunc Either hover your mouse over the 3rd header or resize any column to move background dot. Any idea how to trigger the animation permanentely?
    1 point
  7. Well, why not using additionally GDI+ to pimp up the colors? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <GuiListView.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $tagNMCUSTOMDRAW = "struct;" & $tagNMHDR & ";dword dwDrawStage;handle hdc;" & $tagRECT & _ ";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" ; Title TextCol BkCol - colours in BGR Global $aHdrData[][] = [["Tom", 0x000000, 0x00FFFF], _ ["Dick", 0x00FFFF, 0x0000FF], _ ["Harry", 0xFF0000, 0xFFCCCC]] $hGUI = GUICreate("Set Listview Header Colour ", 500, 300) $cListView = GUICtrlCreateListView(" | | ", 10, 10, 480, 280) _GUICtrlListView_SetExtendedListViewStyle($cListView, $LVS_EX_FULLROWSELECT) ; BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ;Get header handle Global $hHeader = _GUICtrlListView_GetHeader($cListView) ; Get the font of the Header control (credit KaFu) Local $hDC = _WinAPI_GetDC($hHeader) Local $hFont = _SendMessage($hHeader, $WM_GETFONT) Local $hObject = _WinAPI_SelectObject($hDC, $hFont) Local $tLogFont = DllStructCreate($tagLOGFONT) _WinAPI_GetObject($hFont, DllStructGetSize($tLogFont), DllStructGetPtr($tLogFont)) _WinAPI_SelectObject($hDC, $hObject) _WinAPI_ReleaseDC($hHeader, $hDC) Local $iWeight = DllStructGetData( $tLogFont, "Weight" ) ; Bold DllStructSetData( $tLogFont, "Weight", BitOR( $iWeight, $FW_BOLD ) ) $hHdrFont = _WinAPI_CreateFontIndirect( $tLogFont ) For $i = 1 To 15 _GUICtrlListView_AddItem($cListView, "Item" & $i) _GUICtrlListView_AddSubItem($cListView, $i - 1, "SubItem" & $i, 1) _GUICtrlListView_AddSubItem($cListView, $i - 1, "SubItem" & $i, 2) Next _GUICtrlListView_SetColumnWidth($cListView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($cListView, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($cListView, 2, $LVSCW_AUTOSIZE_USEHEADER) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return If DllStructGetData($tStruct, 1) = $hHeader Then Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) Switch $iCode Case $NM_CUSTOMDRAW Local $tNMCustomDraw = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMCustomDraw, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify parent window of any item related drawing operations Case $CDDS_ITEMPREPAINT ; Before an item is drawn: Default painting (frames and background) Return $CDRF_NOTIFYPOSTPAINT ; Notify parent window of any post item related drawing operations Case $CDDS_ITEMPOSTPAINT ; After an item is drawn: Custom painting (item texts) Local $tRECT = DllStructCreate($tagRECT) Local $iIndex = DllStructGetData($tNMCustomDraw, "dwItemSpec") ; Item index Local $hDC = DllStructGetData($tNMCustomDraw, "hdc") ; Device context _WinAPI_SelectObject($hDC, $hHdrFont) ; Set text font _WinAPI_SetBkMode($hDC, $TRANSPARENT) ; Transparent background _WinAPI_SetTextColor( $hDC, $aHdrData[$iIndex][1]) ; Set text colour ; Get header section size DllStructSetData($tRECT, 1, DllStructGetData($tNMCustomDraw, 6) + 1) DllStructSetData($tRECT, 2, DllStructGetData($tNMCustomDraw, 7) + 1) DllStructSetData($tRECT, 3, DllStructGetData($tNMCustomDraw, 8) - 2) DllStructSetData($tRECT, 4, DllStructGetData($tNMCustomDraw, 9) - 2) ; Set and draw back colour ;~ Local $hBrush = _WinAPI_CreateSolidBrush($aHdrData[$iIndex][2]) ;~ _WinAPI_FillRect($hDC, $tRECT, $hBrush) Local Const $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) Local Const $hBrush = _GDIPlus_LineBrushCreate($tRECT.Left, $tRECT.Top, $tRECT.Right, $tRECT.Bottom, 0xFF000000 + $aHdrData[$iIndex][1], 0xFFFFFFFF, 1) _GDIPlus_GraphicsFillRect($hGfx, $tRECT.Left, $tRECT.Top, $tRECT.Right, $tRECT.Bottom, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) ; Write text If $iIndex < _GUICtrlListView_GetColumnCount($cListView) Then _WinAPI_DrawText ( $hDC, $aHdrData[$iIndex][0], $tRECT, $DT_CENTER + $DT_VCENTER ) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndIf EndFunc ;==>_WM_NOTIFY I used a very simple color gradient but you can extend this example by using more GDI+ functions (plenty of variations)!
    1 point
  8. Hi again, Now I have it working in my GUIListViewEx UDF - after a bit of a struggle, I must admit. At least I now understand how the code works and does its magic. Thanks to AutoBert for the question, water and mLipok for the links, and LarsJ for the code - how pleasant when we all work together to produce something really useful. M23
    1 point
  9. Maybe: If StringRegExp(ClipGet(), "\d+") Then
    1 point
  10. Why not just: Local $iMon = StringFormat("%02i", @MON + 1) _DateAdd("d", -1, @YEAR & "/" & $iMon & "/01") or: @YEAR & "/" & @MON & "/" & _DateDaysInMonth(@YEAR, @MON) Anything wrong with these?
    1 point
  11. Usually ADO.au3 do not need driver for ACCESS
    1 point
  12. Ok, this seems to be creating the same result as the C code: Global Const $fPI = ACos(-1), $fRad = $fPI / 180, $fSmall_Float = 1E-12 Global $tTimePlace = DllStructCreate("struct;int year;int month;int day;double hour;endstruct") Func JulianToDate(ByRef $tTimePlace, $jd) Local $jdi, $a, $b, $c, $d, $e, $g, $g1 $jd += 0.5 $jdi = Int($jd) If ($jdi > 2299160) Then $a = Int(($jdi - 1867216.25) / 36524.25) $b = Int($jdi + 1 + $a - ($a / 4)) Else $b = $jdi EndIf $c = $b + 1524; $d = Int(($c - 122.1) / 365.25) $e = Int(365.25 * $d) $g = Int(($c - $e) / 30.6001) $g1 = Int(30.6001 * $g) $tTimePlace.day = Int($c - $e - $g1) $tTimePlace.hour = ($jd - $jdi) * 24 If $g <= 13 Then $tTimePlace.month = Int($g - 1) Else $tTimePlace.month = Int($g - 13) EndIf If $tTimePlace.month > 2 Then $tTimePlace.year = Int($d - 4716) Else $tTimePlace.year = Int($d - 4715) EndIf EndFunc ;==>JulianToDate Func Julian($year, $month, $day) Local $a, $b, $c, $e If $month < 3 Then $year -= 1 $month += 12 EndIf If ($year > 1582 Or ($year = 1582 And $month > 10) Or ($year = 1582 And $month = 10 And $day > 15)) Then $a = ($year / 100) $b = Int(2 - $a + $a / 4) EndIf $c = Int(365.25 * $year) $e = Int(30.6001 * ($month + 1)) Return $b + $c + $e + $day + 1720994.5 EndFunc ;==>Julian Func Sun_Position($j) Local $n, $x, $e, $l, $dl, $v, $m2, $i $n = 360 / 365.2422 * $j $i = Int($n / 360) $n = $n - $i * 360 $x = $n - 3.762863 If $x < 0 Then $x += 360 $x *= $fRad $e = $x Do $dl = $e - 0.016718 * Sin($e) - $x $e = $e - $dl / (1 - 0.016718 * Cos($e)) Until Abs($dl) < $fSmall_Float $v = 360 / $fPI * ATan(1.01686011182 * Tan($e / 2)) $l = $v + 282.596403 $i = Int($l / 360) $l = $l - $i * 360.0 Return $l EndFunc ;==>Sun_Position Func Moon_Position($j, $ls) Local $ms, $l, $mm, $n, $ev, $sms, $z, $x, $lm, $bm, $ae, $ec, $d, $ds, $as, $dm, $i $ms = 0.985647332099 * $j - 3.762863 If ($ms < 0) Then $ms += 360.0 $l = 13.176396 * $j + 64.975464 $i = Int($l / 360) $l = $l - $i * 360.0 If ($l < 0) Then $l += 360.0 $mm = $l - 0.1114041 * $j - 349.383063 $i = Int($mm / 360) $mm -= $i * 360.0 $n = 151.950429 - 0.0529539 * $j $i = Int($n / 360) $n -= $i * 360.0 $ev = 1.2739 * Sin((2 * ($l - $ls) - $mm) * $fRad) $sms = Sin($ms * $fRad) $ae = 0.1858 * $sms $mm += $ev - $ae - 0.37 * $sms $ec = 6.2886 * Sin($mm * $fRad) $l += $ev + $ec - $ae + 0.214 * Sin(2 * $mm * $fRad) $l = 0.6583 * Sin(2 * ($l - $ls) * $fRad) + $l Return $l EndFunc ;==>Moon_Position Func Moon_Phase($year, $month, $day, $hour, ByRef $ip) Local $j = Julian($year, $month, $day + $hour / 24.0) - 2444238.5 Local $ls = Sun_Position($j) Local $lm = Moon_Position($j, $ls) Local $t = $lm - $ls If ($t < 0) Then $t += 360 $ip = BitAND(Int(($t + 22.5) / 45), 0x7) Return (1.0 - Cos(($lm - $ls) * $fRad)) / 2 EndFunc ;==>Moon_Phase Func NextDay(ByRef $y, ByRef $m, ByRef $d, $dd) Local $jd = Julian($y, $m, $d) $jd += $dd JulianToDate($tTimePlace, $jd) $y = $tTimePlace.year $m = $tTimePlace.month $d = $tTimePlace.day EndFunc ;==>NextDay Func Main($y = @YEAR, $m = @MON) Local $d, $m0, $h, $i, $p, $ip = 0 Local $step = 1, $begun = 0, $pmax = 0, $pmin = 1, $plast = 0 Local $ymax, $mmax, $dmax, $hmax, $ymin, $mmin, $dmin, $hmin $d = 1 $m0 = $m ConsoleWrite("tabulation of the phase of the moon for one month" & @CRLF & @CRLF) ConsoleWrite("Date Time Phase Segment" & @CRLF) Do For $h = 0 To 23 Step $step $p = Moon_Phase($y, $m, $d, $h, $ip) If $begun Then If ($p > $plast And $p > $pmax) Then $pmax = $p $ymax = ($y) $mmax = ($m) $dmax = ($d) $hmax = ($h) ElseIf ($pmax) Then ConsoleWrite(StringFormat("%04d/%02d/%02d %02d:00 (fullest)\n", $ymax, $mmax, $dmax, $hmax)) $pmax = 0 EndIf If $p < $plast And $p < $pmin Then $pmin = $p $ymin = ($y) $mmin = ($m) $dmin = ($d) $hmin = ($h) ElseIf $pmin < 1 Then ConsoleWrite(StringFormat("%04d/%02d/%02d %02d:00 (newest)\n", $ymin, $mmin, $dmin, $hmin)) $pmin = 1.0 EndIf If $h = 16 Then ConsoleWrite(StringFormat("%04d/%02d/%02d %02d:00 %5.1f%% (%d)\n", $y, $m, $d, $h, Floor($p * 1000 + 0.5) / 10, $ip)) EndIf Else $begun = 1 EndIf $plast = $p Next NextDay($y, $m, $d, 1) If ($m <> $m0) Then ExitLoop Until False EndFunc ;==>Main Main()
    1 point
  13. or like this: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> $Form1 = GUICreate("Form1", 475, 285) $Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25) $Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17) local $doit = guictrlcreatebutton('Process Text',300,72,150,20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $doit StringReplace(GUICtrlRead($Edit1),@CR,'') guictrlsetdata($label1,@extended) EndSwitch WEnd
    1 point
  14. Replace the While-WEnd loop in sun_position() While Abs($dl) >= $SMALL_FLOAT $dl = $e - .016718 * Sin($e) - $x $e = $e - $dl / (1 - .016718 * Cos($e)) WEnd with a Do-Until loop: Do $dl = $e - .016718 * Sin($e) - $x $e = $e - $dl / (1 - .016718 * Cos($e)) Until Abs($dl) >= $SMALL_FLOAT It guarantees that the calculation in the loop is done at least once. On second thought: Just drop the loop and make sure that the calculation is done once.
    1 point
  15. In the UAC is enable, put #RequireAdmin at the top of your script If you are using a 64 bits OS, the file is probably copied in the C:\Windows\SysWOW64 folder If you want to copy the file in the System32 folder with a 64 bits OS, you should disable the WOW64 redirection before running the copy (_WinAPI_Wow64EnableWow64FsRedirection ( 0)) An other way is to copy the file in c:\windows\sysnative folder
    1 point
  16. Are you running it with the x64 version of AutoIt3? Jos
    1 point
  17. youtuber, If all you want to do is count the number of lines in the edit control then do something like this... #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> $Form1 = GUICreate("Form1", 475, 285) $Edit1 = GUICtrlCreateEdit("", 72, 72, 185, 89) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("", 296, 224, 44, 25) $Label2 = GUICtrlCreateLabel("Number of lines to be introduced:", 104, 224, 181, 17) local $doit = guictrlcreatebutton('Process Text',300,72,150,20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $doit guictrlsetdata($label1,StringSplit(GUICtrlRead($Edit1), @CR)[0]) EndSwitch WEnd kylomas
    1 point
  18. Hi @UEZ, thanks for your translation, it seems that it's ok that way. Regarding the "->" syntax, seems that is a way to access variables within a structure. I tried using a global array instead, and seems that it works as well. The translation now is complete...(?), but according to the result produced by the original executable found here: http://www.voidware.com/moon_phase.htm (see phase.exe near the bottom of the page) the results by this listing, are slight different. I don't know if that is due to some imprecise in my translation or different precision in AutoIt math.... (???) Anyway the moon phases provided by this listing are correct, have a look here for example to check: http://cycletourist.com/moon/lunar_calendar.php fixes or improvements are welcome Thanks everybody EDIT: Listing corrected as suggested by LarsJ in post #4 and now works OK. (Thanks LarsJ ) ; http://www.voidware.com/phase.c ; /* standalone moon phase calculation */ Const $PI = 3.1415926535897932384626433832795 Const $RAD = ($PI / 180.0) Const $SMALL_FLOAT = (1E-12) Global $TimePlace[4] ; [0] Year ; [1] Month ; [2] ; Day ; [3] Hour Global $ip main() Func JulianToDate($jd) $jd += 0.5 $jdi = Int($jd) If ($jdi > 2299160) Then $a = Int(($jdi - 1867216.25) / 36524.25) $b = Int($jdi + 1 + $a - ($a / 4)) Else $b = $jdi EndIf $c = $b + 1524; $d = Int(($c - 122.1) / 365.25) ; $e = Int(365.25 * $d) ; $g = Int(($c - $e) / 30.6001); $g1 = Int(30.6001 * $g) ; $TimePlace[2] = Int($c - $e - $g1) ; Day $TimePlace[3] = ($jd - $jdi) * 24 ; Hour If ($g <= 13) Then $TimePlace[1] = Int($g - 1) ; Month Else $TimePlace[1] = Int($g - 13) ; Month EndIf If $TimePlace[1] > 2 Then ; Month $TimePlace[0] = Int($d - 4716) Else $TimePlace[0] = Int($d - 4715); Year EndIf EndFunc ;==>JulianToDate ; double Func Julian($year, $month, $day) Local $y = $year, $m = $month, $d = $day #cs /* Returns the number of julian days for the specified day. #ce */ If ($month < 3) Then $year -= 1 $month += 12 EndIf If $year > 1582 Or ($year = 1582 And $month > 10) Or ($year = 1582 And $month = 10 And $day > 15) Then $a = Int($year / 100) ; $b = 2 - $a + Int($a / 4) EndIf $c = Int(365.25 * $year); $e = Int(30.6001 * ($month + 1)) Return $b + $c + $e + $day + 1720994.5 EndFunc ;==>Julian Func sun_position($j) Local $dl $n = 360 / 365.2422 * $j $i = Int($n / 360) $n = $n - $i * 360.0 $x = $n - 3.762863 ; If ($x < 0) Then $x += 360 $x *= $RAD $e = $x #cs ; This while - wend replaced by the following Do Until loop ; as suggested by @LarsJ in post #4 While Abs($dl) >= $SMALL_FLOAT $dl = $e - 0.016718 * Sin($e) - $x $e = $e - $dl / (1 - 0.016718 * Cos($e)) WEnd #ce Do $dl = $e - 0.016718 * Sin($e) - $x $e = $e - $dl / (1 - 0.016718 * Cos($e)) Until Abs($dl) < $SMALL_FLOAT $v = 360 / $PI * ATan(1.01686011182 * Tan($e / 2)) $l = $v + 282.596403 $i = Int($l / 360) $l = $l - $i * 360.0 Return $l EndFunc ;==>sun_position Func moon_position($j, $ls) ; /* ls = sun_position(j) */ $ms = 0.985647332099 * $j - 3.762863 If ($ms < 0) Then $ms += 360.0 $l = 13.176396 * $j + 64.975464 $i = Int($l / 360) $l = $l - $i * 360.0 If ($l < 0) Then $l += 360.0 $mm = $l - 0.1114041 * $j - 349.383063 $i = Int($mm / 360) $mm -= $i * 360.0 $n = 151.950429 - 0.0529539 * $j $i = Int($n / 360) $n -= $i * 360.0 $ev = 1.2739 * Sin((2 * ($l - $ls) - $mm) * $RAD) $sms = Sin($ms * $RAD) $ae = 0.1858 * $sms $mm += $ev - $ae - 0.37 * $sms $ec = 6.2886 * Sin($mm * $RAD) $l += $ev + $ec - $ae + 0.214 * Sin(2 * $mm * $RAD) $l = 0.6583 * Sin(2 * ($l - $ls) * $RAD) + $l Return $l EndFunc ;==>moon_position Func moon_phase($year, $month, $day, $hour, ByRef $ip) #cs /* Calculates more accurately than Moon_phase , the phase of the moon at the given epoch. returns the moon phase as a real number (0-1) #ce */ $j = Julian($year, $month, $day + $hour / 24.0) - 2444238.5 $ls = sun_position($j) $lm = moon_position($j, $ls) $t = $lm - $ls If ($t < 0) Then $t += 360 ; ; * ip = (int) ((t + 22.5) / 45) & 0x7 ; <----- ???? $ip = BitAND(Int(($t + 22.5) / 45), 0x7) Return (1.0 - Cos(($lm - $ls) * $RAD)) / 2 EndFunc ;==>moon_phase Func nextDay($y, $m, $d, $dd) $jd = Julian($y, $m, $d) $jd += $dd JulianToDate($jd) ; set result in $TimePlace[] #cs $y = $TimePlace[0] ; Year $m = $TimePlace[1] ; month $d = $TimePlace[2] ; day #ce EndFunc ;==>nextDay Func main() ; { $y = @YEAR $m = @MON $d = @MDAY $step = 1 $begun = 0 $pmax = 0 $pmin = 1 $plast = 0 ConsoleWrite("tabulation of the phase of the moon for one month" & @CRLF & @CRLF) ConsoleWrite("Year: " & $y & @CRLF) ConsoleWrite("month: " & $m & @CRLF) $d = 1 $m0 = Int($m) ConsoleWrite(@CRLF & "Date Time Phase Segment" & @CRLF) While True For $h = 0 To 23 Step $step $p = moon_phase($y, $m, $d, $h, $ip) If ($begun) Then If ($p > $plast And $p > $pmax) Then $pmax = $p $ymax = $y $mmax = $m $dmax = $d $hmax = $h ElseIf ($pmax) Then ; { ConsoleWrite(StringFormat("%04d/%02d/%02d %02d:00 (fullest)\n", $ymax, $mmax, $dmax, $hmax)) $pmax = 0 EndIf If ($p < $plast And $p < $pmin) Then $pmin = $p $ymin = $y $mmin = $m $dmin = $d $hmin = $h ElseIf ($pmin < 1) Then ConsoleWrite(StringFormat("%04d/%02d/%02d %02d:00 (newest)\n", $ymin, $mmin, $dmin, $hmin)); $pmin = 1.0 EndIf If ($h = 16) Then ConsoleWrite(StringFormat("%04d/%02d/%02d %02d:00 %5.1f%% (%d)\n", $y, $m, $d, $h, Floor($p * 1000 + 0.5) / 10, $ip)) EndIf Else $begun = 1 EndIf $plast = $p; Next nextDay($y, $m, $d, 1.0); $y = $TimePlace[0] ; Year $m = $TimePlace[1] ; month $d = $TimePlace[2] ; day If ($m <> $m0) Then ExitLoop ; break WEnd Return 0; EndFunc ;==>main
    1 point
  19. guinness

    Switch vs. Select

    Select is sugar for if...else if...else
    1 point
  20. trancexx

    How computers work

    But that's not it. When you start Windows you actually start a program (I'll underline it from now on). That program is the only thing that ever "touches" your computer's CPU. Then that program creates interface for you (the user) to start application(s). At the same time the program creates time slots in which it then puts tasks. Time slot is a portion of overall time. The program doesn't advertise how big one time-slot is. It can be two ticks, 1 millisecond, 6 instructions, or whatnot. This is done to create impression that it runs more things at the same time. It actually runs only one thing at any given time, but switches too fast for you to notice it. When mentioned applications are "started" the program puts it into one time slot. Sometimes these slots are divided into sub-slots (working threads) of a process. When one time-slot is "active" the program takes binary data (opcodes) from the application and "pushes" it to the CPU onto its behalf. Race condition can occur, for example, if the program has bug and allows two slots to overlap. This usually ends up with BSOD. More common and usual case of race condition occurring is when programmer asks the program to create sub-slots (threads) and then access the same addresses from two different sub-slots. Because the program didn't say for how long one sub-slot will run, it can happen that one sub-slot runs for longer time than another before execution is switched to another sub-slot. First slot might have executed more instructions. The problem for the code in another sub-slot is that the code from the first one may have changed data at the shared addresses. Then that other thread continues, but has no idea that the data it works on has been changed by someone else. Now, that is it in layman's terms.
    1 point
  21. Dim $sResult $strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_DiskDrive") For $objItem In $colItems $sResult &= "" & $objItem.Caption & @LF & " (" & Int($objItem.Size / 1024 ^ 3) & "GB) |" Next #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, -1, -1) $Combo1 = GUICtrlCreateCombo("Kies schijf...", 128, 200, 369, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData($Combo1, $sResult) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I did not get the script to work now, i have been searching and editting a little bit and i have come up with this script. Only problem i have now it won't run in WinPE can anyone help me with this, i really am stuck with this part. What i am trying to do here is: Create a pull down menu with the drives connected to the system in it, and after the drive is chosen and the start button is clicked it needs to be able to change a xml file for my diskpart function to work. If chosen drive has disk 0 in diskpart then input that in the xml, but if chosen drive has disk 1 then that etc. Hope you guys can help me with this.
    1 point
  22. Try this: $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & '\root\cimv2:Win32_LogicalDisk="C:"') MsgBox(0, "TEST", "Free Diskspace on C: " & $objWMI.FreeSpace & " bytes / " & Round($objWMI.FreeSpace / 1024^2) & " mb") Br, UEZ
    1 point
  23. GodForsakenSoul, Just create the input with the $ES_NUMBER style. It is all in the Help file..... M23
    1 point
×
×
  • Create New...