Jump to content

monoscout999

Active Members
  • Posts

    1,048
  • Joined

  • Last visited

  • Days Won

    1

monoscout999 last won the day on September 2 2011

monoscout999 had the most liked content!

About monoscout999

  • Birthday 02/23/1984

Profile Information

  • Member Title
    a member
  • Location
    Argentina

Recent Profile Visitors

483 profile views

monoscout999's Achievements

Universalist

Universalist (7/7)

10

Reputation

  1. Hi Damein. Becuase the notepad isn`t open when the ControlGetPos() function is called, you can solve this with a WinWait call after you run notepad... Run("notepad.exe") WinWait("[CLASS:Notepad]") $pos = ControlGetPos("[CLASS:Notepad]", "", "Edit1") MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," & $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] ) ...Or add a error check to avoid the error Run("notepad.exe") $pos = ControlGetPos("[CLASS:Notepad]", "", "Edit1") If not @error then MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," & $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] ) This deppend of the future usage of your script.
  2. Here is how i will do it... i am a off of coding practice so ask wherever you want to know or you don`t understand, i will try to answer. #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <winapi.au3> Global Const $IMAGE_BITMAP = 0 Global Const $STM_SETIMAGE = 0x172 Global $iWidth = 100 Global $iHeight = 100 ; Creating GUI, Save Button and Pic Control... $hGUI = GUICreate("Graphic") GUISetBkColor(0xABCDEF) $iPic = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) $iButton1 = GUICtrlCreateButton("Save To File...", 0, 370, 200, 30) $iButton2 = GUICtrlCreateButton("Generate Random Image...", 200, 370, 200, 30) ; Creating an empty image and getting the graphic context... _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) ; Drawing random points... $hPen = _GDIPlus_PenCreate(0xFF000000) Local $i For $y = 0 To $iHeight For $x = 0 To $iWidth $i = Random(0, 1, 1) If $i = 1 Then _GDIPlus_PenSetColor($hPen, 0xFFFFFFFF) ; If i = 1 then white Else _GDIPlus_PenSetColor($hPen, 0xFF000000) ; If i = 0 then black EndIf _GDIPlus_GraphicsDrawRect($hGraphic, $x, $y, 1, 1, $hPen) ; Creating Squares of 1X1(dots) Next Next ; Showing the Image in the Pic Control... $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) _WinAPI_DeleteObject($hBitmap) ; Showing the GUI and the starting the main loop... GUISetState() While True $iMsg = GUIGetMsg() Switch $iMsg Case -3 _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Exit Case $iButton1 _GDIPlus_ImageSaveToFile($hImage, @DesktopDir & "\temp.png") Case $iButton2 Local $i For $y = 0 To $iHeight For $x = 0 To $iWidth $i = Random(0, 1, 1) If $i = 1 Then _GDIPlus_PenSetColor($hPen, 0xFFFFFFFF) ; If i = 1 then white Else _GDIPlus_PenSetColor($hPen, 0xFF000000) ; If i = 0 then black EndIf _GDIPlus_GraphicsDrawRect($hGraphic, $x, $y, 1, 1, $hPen) ; Creating Squares of 1X1(dots) Next Next $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) _WinAPI_DeleteObject($hBitmap) EndSwitch WEnd Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0
  3. nice script UEZ i never saw a Static variable they seems very usefull today i learn something new.
  4. The script have a window? ----> use If _IsPressed("your Key" , $YourUser32DLL) and WinExists("Your window") The script have not a window? ---->
  5. Comparing the image file like a text is not correct, if the pic have a comment on the headder or something this will be different. if you want to compare the pixels of each you should use LockBits or something similar.
  6. The pic isnt created when you register "StartDoggy" function, try to create all the controls and the variables that you use in the function before registering the adlib funcion,
  7. thanks BogQ this is solved and added a backbuffer to smoth the process. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <Winapi.au3> #include <GDIPlus.au3> Global Const $SC_MOVE = 0xF010 Global Const $STM_SETIMAGE = 0x172 Global Const $STM_GETIMAGE = 0x173 Global $img = @ScriptDir & "\bot2.bmp" InetGet("http://www.mediafire.com/imgbnc.php/c83b527a400083eedd4f6958da2d9f6f1db83d5f6513f59045fae80a37df1e276g.jpg", $img) $hGUI = GUICreate("Graficos Simples GDI+") $Pic = GUICtrlCreatePic($img, 0, 0, 400, 400) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While True $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN _CreatingBox($Pic) EndSwitch WEnd Func _CreatingBox($iPic) Local $hPic = GUICtrlGetHandle($iPic) Local $aCursor = GUIGetCursorInfo() Local $x = $aCursor[0] Local $y = $aCursor[1] Local $oldX = $x Local $oldY = $y _GDIPlus_Startup() Local $hBMP = GUICtrlSendMsg($iPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0) Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) Local $auxBMP = _GDIPlus_BitmapCloneArea($hImage, 0, 0, 400, 400) Local $hGrap = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hDC = _WinAPI_GetDC($hGUI) Local $hAuxGraph = _GDIPlus_GraphicsCreateFromHDC($hDC) local $hBrush = _GDIPlus_BrushCreateSolid(0x447722FF) Do $aCursor = GUIGetCursorInfo($hGUI) If $oldX <> $aCursor[0] Or $oldY <> $aCursor[1] Then $oldX = $aCursor[0] $oldY = $aCursor[1] _GDIPlus_GraphicsDrawImageRect($hGrap, $auxBMP, 0, 0, 400, 400) _GDIPlus_GraphicsfillEllipse($hGrap, $x, $y, $aCursor[0] - $x, $aCursor[1] - $y,$hBrush) _GDIPlus_GraphicsDrawImageRect($hAuxGraph, $hImage, 0, 0, 400, 400) EndIf Until Not $aCursor[2] _gdiplus_brushdispose($hBrush) _GDIPlus_GraphicsDispose($hAuxGraph) _WinAPI_ReleaseDC($hGUI, $hDC) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_GraphicsDispose($hGrap) _GDIPlus_ImageDispose($auxBMP) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc ;==>_CreatingBox
  8. ok @Ramzes but i am looking a way to draw when you click and drag on the GUI.
  9. Hello. i like to do a litle paint just for fun, i want that the user draw an ellipse in the GUI, i cannot erase the pre drawing. I want that someone with experience in this kind of program give me some hint. this is my try. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <Winapi.au3> #include <GDIPlus.au3> Global Const $SC_MOVE = 0xF010 Global Const $STM_SETIMAGE = 0x172 Global Const $STM_GETIMAGE = 0x173 Global $img = @ScriptDir & "\bot2.bmp" InetGet("http://www.mediafire.com/imgbnc.php/c83b527a400083eedd4f6958da2d9f6f1db83d5f6513f59045fae80a37df1e276g.jpg", $img) $hGUI = GUICreate("Graficos Simples GDI+") $Pic = GUICtrlCreatePic($img, 0, 0, 400, 400) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() While True $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN _CreatingBox($Pic) EndSwitch WEnd Func _CreatingBox($iPic) Local $hPic = GUICtrlGetHandle($iPic) Local $aCursor = GUIGetCursorInfo() Local $x = $aCursor[0] Local $y = $aCursor[1] _GDIPlus_Startup() Local $hBMP = GUICtrlSendMsg($iPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0) Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) Local $hGrap = _GDIPlus_ImageGetGraphicsContext($hImage) Local $hDC = _WinAPI_GetDC($hGUI) Local $hAuxGraph = _GDIPlus_GraphicsCreateFromHDC($hDC) Do $aCursor = GUIGetCursorInfo() _GDIPlus_GraphicsDrawEllipse($hAuxGraph, $x, $y, $aCursor[0] - $x, $aCursor[1] - $y) _WinAPI_PostMessage($hGUI, $WM_ERASEBKGND, $hDC, 0) ;~ _WinAPI_PostMessage($hGUI, $WM_PAINT, 0, 0) ;~ _winapi_updatewindow($hGUI) Until Not $aCursor[2] _GDIPlus_GraphicsDispose($hAuxGraph) _WinAPI_ReleaseDC($hGUI, $hDC) _GDIPlus_GraphicsDrawEllipse($hGrap, $x, $y, $aCursor[0] - $x, $aCursor[1] - $y) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_GraphicsDispose($hGrap) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc ;==>_CreatingBox
  10. Very good Vaulter or Melba23... and add on. PNG in Pic Control, maybe already posted. #include <GDIPlus.au3> #include <Constants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Global Const $SC_MOVE = 0xF010 Global Const $STM_SETIMAGE = 0x172 ; This Is For Getting The PNG From a URL $PngFile = @ScriptDir & "\MyPNG.png" $Inet = InetGet("http://img26.imageshack.us/img26/7439/boton3p.png", $PngFile) ;Here is the GUI creation $hGUI = GUICreate("PNG Pic by monoscout999") GUISetBkColor(0x123456, $hGUI) $Pic = GUICtrlCreatePic("", 10, 10, 50, 50) _SetPNGIntoPicControl($Pic, $PngFile) GUISetState() While True $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $GUI_EVENT_PRIMARYDOWN _ControlMove($Pic) EndSwitch WEnd ; Here is the function declared Func _SetPNGIntoPicControl($iPic, $sPNGFile) _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_SetPNGIntoPicControl Func _ControlMove($cID) Local $aCurPos = GUIGetCursorInfo() If @error Then Return False If $aCurPos[4] = $cID Then GUICtrlSendMsg($cID, $WM_SYSCOMMAND, BitOR($SC_MOVE, $HTCAPTION), 0) EndIf EndFunc ;==>_ControlMove
  11. @Xander you should post a working replicator of the issue, as far i can see is that your main problem is that your script exit in the 11 line :S , in that case i will send you to read tutorials and the help file because it seems like noob mistakes. I agree with Beege in that point. Is Ilogic ask for help with a code like yours.
  12. in this link there is a discuss about this issue, we never finish the solution, maybe you can add something usefull that might help us.
  13. You will see examples in the help file... do a try and post it here.
×
×
  • Create New...