Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/06/2015 in all areas

  1. Hello everyone! As always, I'm proud to present you vPaint. It's an image editor. It uses GDI+ as its drawing library. I want to thank to all members of this forum. Without you, this app wouldn't be ever written. Thank you for everything. Download: vPaint 4 image editor
    1 point
  2. Lately, in this forum, there were many questions and problems referring to the use of ie.au3 UDF using the latest version of AutoIt v3.3.14.x. I would like to present the correct usage of the UDF. I hope that it will help many users to prevent problems. #include <ie.au3> #include <MsgBoxConstants.au3> ; STEP 1 ; YOU MUST SET ANY COM ERROR HANDLER IN ONE OF THE FOLLOWING WAY ; STEP 1: CASE 1 ; you should set COM Error Handler Function for ie.au3 UDF _IEErrorHandlerRegister(_User_ErrFunc) ; STEP 1: CASE 2 ; eventually if you not want to recieve additional information ; you can use just the same function without parameter ; _IEErrorHandlerRegister() ; STEP 1: CASE 3 ; or use your own global COM Error Handler ;~ Global $oCOMErrorHandler = ObjEvent("AutoIt.Error", _User_ErrFunc) ; STEP 2 ; if you do not wish to get in Console Output Pane information like the following: ; --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType ; You can uncomment this following line: ; _IEErrorNotify(False) _Example() Func _Example() ; First lets create some IE Object Local $oIE = _IECreate('google.com') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IECreate', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(1,0,0) Endif ; here we try to get reference to LuckyStrike button Local $oLuckyStrike = _IEGetObjByName($oIE, 'btnI') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(2,0,0) Endif ; here we try to click LuckyStrike button with previously achieved Object which is a reference to HTML DOM OBJECT in IE Instance _IEAction($oLuckyStrike, 'click') ; you should wait when page is loading _IELoadWait($oIE) ; some user interaction If MsgBox($MB_YESNO, 'Question', 'Do you want to back ?') = $IDYES Then _IEAction($oIE, 'back') EndIf EndFunc ;==>_Example ; User's COM error function. ; After SetUp with ObjEvent("AutoIt.Error", ....) will be called if COM error occurs Func _User_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_User_ErrFunc Regards, mLipok
    1 point
  3. You are welcome. I am glad you are making progress.
    1 point
  4. MuffinMan

    csv editing

    You can do that directly in Excel... Select cells you want formatted in this way.Right click and select "Format Cells..."Select the "Number" Tag, and scroll down to "Custom" in the category list.Type "00000000" into the Type field.Everything will be zero padded to 8 digits.
    1 point
  5. Teks, In fact GUIGetMsg sleeps for about 12-15ms at every call. A clever little wrinkle from Jon which means you do not have to add a Sleep in the idle loop when in MessageLoop mode - but you certainly do need one if you are in OnEvent mode. Both modes have their pros and cons. I nearly always use MessageLoop mode as it means fewer functions to write for simple scripts - but there have been reports (from people I trust) that having a HUGE MessageLoop loop (with perhaps 100+ controls) can cause problems, although I have never come across it myself. M23
    1 point
  6. goss34, Does this help? #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cLabel = GUICtrlCreateLabel("0", 10, 10, 20, 20) GUISetState() ; Get a timestamp $nBegin = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; See if the timer delay has expired - here it is 5 secs If TimerDiff($nBegin) > 5 * 1000 Then ; Read the value displayed $sValue = GUICtrlRead($cLabel) ; Increase it by 1 and reset GUICtrlSetData($cLabel, $sValue + 1) ; Reset the timestamp for the next delay $nBegin = TimerInit() EndIf WEndTeks, Using Event mode will not help here - as you can see from the above you can very easily do this in either mode. M23
    1 point
  7. This can help : when you want change Wallpaper Desktop you need refresh : _ChangeWallpaper(@DesktopDir&"/image.jpg",1) Func _ChangeWallpaper($sFile,$iType) If Not FileExists($sFile) Then SetError(1) Return -1 EndIf If StringTrimLeft($sFile,StringInStr($sFile,'.',0,-1)) <> 'jpg' Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') Case Else EndSelect RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile) DllCall("User32.dll","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0) Return 0 EndFunc
    1 point
  8. If the question is whether you can add your own custom shortcut to do a "Copy as RTF" then the answer is yes: Just add it to the "user.shortcuts" config parameter. Example: user.shortcuts=\ Ctrl+r|IDM_SAVEASRTF|\ Ctrl+Shift+V|IDM_PASTEANDDOWN|\ Ctrl+PageUp|IDM_PREVFILE|\ Ctrl+PageDown|IDM_NEXTFILE|\ Ctrl+Alt+f|IDM_TOGGLE_FOLDALL|\ Ctrl+Alt+x|IDM_TOGGLE_FOLDRECURSIVE|\ Ctrl+F1|IDM_HELP_SCITE|Jos
    1 point
  9. If @error Then ; ini file is empty $newsection = 1 ; add the first section ( section [1] ) IniWrite($sGuvercinINI, $newsection, "...", "...") ; <<<<<<<<<<<<<<<<<<<< ; Obviously this was just a sample line and you must put instead the whole bunch of IniWrite ; etc Else ....Never heard of a save button. This is new ?
    1 point
  10. Local $a = 0 While 1 (my command here) $a += 1 If $a==300 Then Sleep(500) $a = 0 EndIf WEnd
    1 point
  11. Meanwhile there are plenty of GDI+ examples in this forum which is the best documentation / tutorial. Apropos doc / tut. On German and French AutoIt forum there are GDI+ tutorials. Maybe the Google / Bing translator is good enough to understand those. Further we have added a lot of additional GDI+ functions with examples - check out the help file. Anyhow, here an example: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPIRes.au3> #include <WindowsConstants.au3> Global $g_vDuration = Default, $g_hBitmap = _GDIPlus_CreateHBitmapCaretLine() OnAutoItExitRegister('OnAutoItExit') Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93) Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20) GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console") Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg Switch $hWnd Case $hForm Switch _WinAPI_LoWord($wParam) Case $idInput Switch _WinAPI_HiWord($wParam) Case $EN_KILLFOCUS _WinAPI_HideCaret($lParam) _WinAPI_DestroyCaret() _WinAPI_SetCaretBlinkTime($g_vDuration) $g_vDuration = Default Case $EN_SETFOCUS $g_vDuration = _WinAPI_SetCaretBlinkTime(250) _WinAPI_CreateCaret($lParam, $g_hBitmap) _WinAPI_ShowCaret($lParam) EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func OnAutoItExit() _WinAPI_DeleteObject($g_hBitmap) If Not IsKeyword($g_vDuration) Then _WinAPI_SetCaretBlinkTime($g_vDuration) EndIf EndFunc ;==>OnAutoItExit Func _GDIPlus_CreateHBitmapCaretLine($iW = 9, $iH = 14, $iLineSize = 3, $iCaretColor = 0xFF000000, $iBGColor = 0xFFFFFFFF) _GDIPlus_Startup() Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local Const $hBrush = _GDIPlus_BrushCreateSolid(BitXOR(0x00FFFFFF, $iCaretColor)) _GDIPlus_GraphicsClear($hGfx, BitXOR(0x00FFFFFF, $iBGColor)) _GDIPlus_GraphicsFillRect($hGfx, 0, $iH - $iLineSize, $iW, $iLineSize, $hBrush) Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return $hHBitmap EndFunc The tricky thing is that the brush / bg color must be inverted otherwise you will see the caret inverse.
    1 point
×
×
  • Create New...