Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/04/2019 in all areas

  1. 4 points
  2. Since you have the FileWrite and Msgbox in both conditions, it writes the file. You should be able to remove the first set and just have Exit in the condition check. Alternatively, you could change the logic and reduce a couple lines. If Not $iFileExists Then FileWrite($Name&'.txt', $Name&' '&$SSD) MsgBox(0,"Thank You", $Name & " has been updated.") EndIf
    1 point
  3. You write the file to the network share. Your check for the existence of the file checks whether it exists in the script's directory because you haven't changed directories yet. So of course the file never exists in the script's directory. You would be much better off using absolute paths instead of relative paths. Then things like that wouldn't happen when changing directories.
    1 point
  4. If you're interested
    1 point
  5. Right ...keep on arguing is probably not the best approach. You are one of the few that received a vacation from being able to post for lack of effort. So yes, you do get a special treatment from that moment on and would suggest to stop wasting time trying to prove you aren't guilty and simply demonstrate you do your due diligence from here on. Jos
    1 point
  6. Yes, AutoIt can do each and everyone one of the listed tasks. It will do whatever you code it to do. If it is a standalone AutoIt script, then you would launch it like you would launch any other script (command line, task scheduler, shortcut, etc.) Most likely, yes. It depends on how you ultimately code it. As I can see by your questions, and as you can see by my answers, you haven't spent much time researching AutoIt and its capabilities. You really need to do it so that you will stop asking questions that you can easily find/read on your own and get to asking questions specific to the code you have started to develop. This topic is on its 3rd page and almost no progress has been made. To be clear, my effort in helping you (or anyone else for that matter) is going to be directly proportionate to your effort in helping yourself learn and develop using AutoIt.
    1 point
  7. I understood that you needed Excel because that is where the customer information is kept. My question was not whether you wanted to get rid of Excel. My question was whether you wanted to do all of the processing in AutoIt or whether you wanted to continue to use Excel macros (VBScript) with AutoItX to try to do the processing? AutoIt can work with Excel workbooks. AutoIt can do most, if not all, of the things you are using Selenium to do. AutoIt can also do the file processing and the rest of the tasks you have said that you would like to do. So my question was, or should I say suggestion, is to do it all with AutoIt because this is an AutoIt forum and not an Excel/VBScript forum. The choice is yours. In any case, when you start your coding and run into AutoIt/AutoItX issues, post your code, describe the issue, describe the expected outcome, and I'm sure we can help you get past the issue so you can continue on with your project.
    1 point
  8. Please elaborate on "not working properly". Do you get any error messages etc.? It's hard to help without further information.
    1 point
  9. @oemript Read the Help file or quit this forums. You're very annoying.
    1 point
  10. Musashi

    How to handle the error?

    Global $oIE = _IECreate($sURL) This cannot be the entire code ! ; Example from the AutoIt-Help : #include <IE.au3> #include <MsgBoxConstants.au3> Local $sURL = "www.autoitscript.com" Local $oIE = _IECreate($sURL, 1) ; Check @extended return value to see if attach was successful If @extended Then MsgBox($MB_SYSTEMMODAL, "", "Attached to Existing Browser") Else MsgBox($MB_SYSTEMMODAL, "", "Created New Browser") EndIf
    1 point
  11. Yes, for the sake of completeness, I intend to use every available keyword in the reference script This belief seems to have stemmed from some kind of misconception and then spread throughout the scripts shared as examples in this forum. If you read the help file entry for Dim, you will get to know that it is not really different from other declaration keywords. The only special thing about it is that the scope of the variable defined using Dim is dependent on the availability of a variable with the same name in the Global scope. If a variable already exists in the global scope in the same name, nothing is done and the variable will refer to the global variable, otherwise it is created as a normal local variable which is only valid inside the function. It is generally not a good idea to depend on hacks such as this... and this will certainly throw in a cog for me when developing the actual interpreter as the scope cannot be determined during compile time. Also do not confuse it with the similar ReDim keyword, which is used to resize arrays Are you sure that this is true? I do not see anything special about Dim in this case, you can use Local to redeclare the variable in this case and it would work just as fine I am guessing. Correct me if I am wrong. Indeed, it is just a script which can be used as a good reference to display all possible syntax variations in AutoIt. It will also be useful to test my parser when I get around to writing it.
    1 point
  12. Thx LarsJ Your line of code did it, in Melba's script (without the button) and also in a little script I'm working on, learning how to select subitems not only with clicks but with the 4 direction keys, Enter key being managed in ListView via Yashied's Wsp.dll found here... which made you react there We're lucky to have you on this site.
    1 point
  13. AFAICT Dim has one and only one use case: force redeclaration to a given datatype of a variable passed ByRef to a function, irrespective of the datatype that was passed. Example: Local $a = "abc" f($a) _ArrayDisplay($a) Func f(ByRef $var) Dim $var = [1, 2, 3, 4, 5] EndFunc Any other case can be handled with Global/Local, even if I'd love to see file scope introduced.
    1 point
  14. This is working fine: - regread/regwrite changed to read/set global variable - removed unnecessary GUICtrlCreateLabel() from main loop - some minor fixes/optimizations #include <GUIConstants.au3> #include <Misc.au3> Global $switch = 1 $Blue = "0x0000FF" $Red = "0xFF0000" $FNT = "Comic Sans Ms" GUICreate ("Test") $idButton = GUICtrlCreateButton("Change", 210, 170, 85, 25) $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) ;~ If RegRead("HKEY_CURRENT_USER\Software","Dz") = "0" Then If $switch = 0 Then $color = $Red Else $color = $Blue $switch = 1 ;~ RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUICtrlSetColor($idLabel, $color) GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) GUISetState () While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton , $idLabel If $switch = 1 Then ;~ If RegRead("HKEY_CURRENT_USER\Software","Dz") = 1 Then ;~ $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) $color = $Red $switch = 0 ;~ RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","0") Else ;~ $idLabel = GUICtrlCreateLabel ("Label", 122, 74, 100, 18) $color = $Blue $switch = 1 ;~ RegWrite("HKEY_CURRENT_USER\Software","Dz","REG_SZ","1") EndIf GUICtrlSetColor($idLabel, $color) ;~ GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTITALIC,$FNT) EndSwitch Wend
    1 point
  15. It has been more than a month since the last post in this thread and I did not manage to start working on the reference script until now... I blame the many things that I am try to balance in my schedule, which includes gaming on my new PS4 and watching a ton of YouTube when I am not working Anyway, I finally made a very basic reference script covering comments and variables, this should be enough to get me started: #cs This is a simple reference script which aims to include every possible combination of AutoIt Syntax As a matter of fact, we are demonstrating multi-line comments now! #ce #Region Comments ; == Single-line ; This is a single line comment ; == Multi-line #comments-start This is a comment spanning multiple lines #comments-end ; NOTE: Technically multi-line comments are directives which are processed by the preprocessor #EndRegion #Region Variables ; == Declaration Local $vLocalVariableDemo Global $g_vGlobalVariableDemo Dim $g_vDimVariableDemo ; Dynamic scope, avoid at all costs! Global Const $g_vGlobalConstantDemo = 3.14 ; You can't change PI! Enum $FOO, $BAR ; $FOO = 0 and $BAR = 1 Enum Step 2 $MAYBE_EVEN, $EVEN, $EVEN_AGAIN ; $MAYBE_EVEN = 0, $EVEN = 2, $EVEN_AGAIN = 4 Enum Step *2 $ONE_BIT, $TWO_BIT, $FOUR_BIT, $ONE_BYTE, $TWO_BYTES, $FOUR_BYTES ; Exponents of 2: 1, 2, 4, 8, 16, 32, ... ; === Array declaration Global $g_aArrayDemo[10] ; == Initialization Global $g_sInitializedString = "Test" Global $g_nInitializedNumber = 42 Global $g_vInitializedVarFromExp = (@SEC / 2) - Floor(@SEC / 2) = 0.5 ? "Even" : 0xDD ; Initialization with an expression whose type is dynamic ; === Array initialization Global $g_aInitializedArray[2] = ["Foo", "bar"] #EndRegion If anyone wants to expand the list, then feel free to do so! I will probably adapt your changes with modifications in my next iteration
    1 point
  16. 1) From idea on the shitter --> proof of concept is rarely measured in anything other than minutes. 2) The helpfile is gd amazing (which often facilitates #1). 3) people who have to maintain your uncommented code in the future get the luxury of 1 and 2.
    1 point
  17. It works! Thank you! I have now successfully ripped some of my DVDs. I still need to work on some of error catching/reporting and clean up my code a bit. Then I plan to post it.
    1 point
  18. v10 > v11 Fixed - Slow processing speed, because for "Custom" header MediaInfo was extracted from every file before "Skip" check Fixed - Frame around single picture not displayed anymore with geometry 3x3, now set to 4x4 Updated MPlayer to r38116 Updated SQLite to 3.25.1 Updated ImageMagick to 6.9.9-51-portable-Q16-x86 Installer & Source is available at http://www.amt.cc or http://funk.eu/amt/ Enjoy ...
    1 point
  19. Here is a small example (from @UEZ: #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global $iW, $iH, $hImage, $hBitmap, $hGUI $hImage = _GDIPlus_BitmapCreateFromFile("C:\Program Files\AutoIt3\Examples\GUI\Torus.png") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetState() _WinAPI_BitmapDisplayTransparentInGUI($hBitmap, $hGUI) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete() Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Edit: after some changes (upgrades) you have to insert: #include <WinAPISysWin.au3> at top of script "#include section"
    1 point
  20. You must start GDI+ before you use any function from GDI+ and don't forget to cleanup the resources! Try this: #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIplus.au3> ; Needed for GDI functions Example() Func Example() _GDIPlus_Startup() Local $idListview, $hImage GUICreate("ImageList AddBitmap", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(32, 32) $webImage = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png" ; This line works-> _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp") Global $GDIpBmpLarge = _GDIPlus_BitmapCreateFromMemory(InetRead($webImage)) ;GDI+ image! Global $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 32,32) ;GDI+ image Global $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) ;GDI image! _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 120) ; Add items _GUICtrlListView_AddItem($idListview, "Item 1", 0) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _WinAPI_DeleteObject($GDIbmp) _GDIPlus_Shutdown() GUIDelete() EndFunc ;==>Example Br, UEZ
    1 point
  21. UEZ

    PNG in GUI

    Try this then: ;coded by UEZ 2011 #include <guiconstantsex.au3> #include <gdiplus.au3> #Include <memory.au3> _GDIPlus_Startup() Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x0172 Global $msg Global Const $hBmp = Load_BMP_From_Mem(InetRead("http://www.autoitscript.com/forum/public/style_images/autoit/logo.png"), True) ;to load an image from the net Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) Global Const $iWidth = _GDIPlus_ImageGetWidth($hBitmap) Global Const $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Global Const $hGUI = GUICreate("Display PNG Image in picture control", $iWidth, $iHeight) Global Const $idPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)) GUISetState() While True $msg = GUIGetMsg() Switch $msg Case $idPic MsgBox(0, "Information", "PNG image was clicked") Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit EndSwitch WEnd ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown() ; ; Requirement(s): GDIPlus.au3, Memory.au3 and _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format), ; Error: 0 ; Error codes: 1: $bImage is not a binary string ; 2: unable to create stream on HGlobal ; 3: unable to create bitmap from stream ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and ; Yashied for _GDIPlus_BitmapCreateDIBFromBitmap() from WinAPIEx.au3 ; Version: v0.97 Build 2012-04-10 Beta ;======================================================================================= Func Load_BMP_From_Mem($bImage, $hHBITMAP = False) If Not IsBinary($bImage) Then Return SetError(1, 0, 0) Local $aResult Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents If @error Then Return SetError(2, 0, 0) Local Const $hStream = $aResult[3] $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface If @error Then Return SetError(3, 0, 0) Local Const $hBitmap = $aResult[2] Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 $tVARIANT = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>Load_BMP_From_Mem Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) Local $tBIHDR, $Ret, $tData, $pBits, $hResult = 0 $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0) If (@error) Or ($Ret[0]) Then Return 0 $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $Ret[2], $Ret[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $pBits = DllStructGetData($tData, 'Scan0') If Not $pBits Then Return 0 $tBIHDR = DllStructCreate('dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword') DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 2, $Ret[2]) DllStructSetData($tBIHDR, 3, $Ret[3]) DllStructSetData($tBIHDR, 4, 1) DllStructSetData($tBIHDR, 5, 32) DllStructSetData($tBIHDR, 6, 0) $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0) If (Not @error) And ($hResult[0]) Then DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $Ret[2] * $Ret[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0')) $hResult = $hResult[0] Else $hResult = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hResult EndFunc ;==>_GDIPlus_BitmapCreateDIBFromBitmap Br, UEZ
    1 point
×
×
  • Create New...