Jump to content
badcoder123

Drawing To Window/Screen

Recommended Posts

I was looking around the help file and I came across _GDIPlus_GraphicsDrawRect and _WinAPI_DrawLine and I seem to be having the same "problem" where every time it draws into a window and you lose or gain focus it has to redraw itself. Is there anyway around this? 

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <GDIPlus.au3>

_GDIPlus_Startup()

Run("notepad.exe")
$hWnd = WinWait("Untitled")

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$Color = 0xFFFF0000
$hPen = _GDIPlus_PenCreate($Color, 2)


For $i = 1 To 10
    _GDIPlus_GraphicsDrawRect($hGraphic, 200, 200, 25 ,25, $hPen)
    ToolTip($i)
    Sleep(1000)
Next

_WinAPI_RedrawWindow($hWnd, 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_PenDispose($hPen)
_GDIPlus_Shutdown()

 

Edited by badcoder123

Share this post


Link to post
Share on other sites

There is a way i think, if you create a transparent GUI, then whatever you paint stays there, other than that, i dont think so, whenever the application refreshes, your drawing is gone, so maybe you have to keep drawing, a lot.

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
20 minutes ago, careca said:

There is a way i think, if you create a transparent GUI, then whatever you paint stays there, other than that, i dont think so, whenever the application refreshes, your drawing is gone, so maybe you have to keep drawing, a lot.

 

Is it possible to make it so you can click through the GUI or make a hole in it?

Share this post


Link to post
Share on other sites

search for setwindowrgn and you will get examples on non rectangular windows. I assume you then can make forms with holes in it

 

 

Edited by junkew

Share this post


Link to post
Share on other sites

Maybe, but im not an expert on it, i've seen gui's where only an image is clickable, and the rest is go-through.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

based on the link a small example making red rect area (actually the hwnd with custom rect) around the notepad editable area

  • Hard to close the window in itself use alt+f4 or just close notepad and example will break ;-)

 

#include <GuiConstants.au3>
#include <guiconstantsex.au3>
#include <winapi.au3>

Run("notepad.exe")

; Wait 10 seconds for the Notepad window to appear.
$hWnd =    WinWait("[CLASS:Notepad]", "", 10)

; Retrieve the position as well as height and width of the active window.
Local $aPos = WinGetPos($hWnd)

; Display the array values returned by WinGetPos.
;~ MsgBox($MB_SYSTEMMODAL, "", "X-Pos: " & $aPos[0] & @CRLF & _
;~             "Y-Pos: " & $aPos[1] & @CRLF & _
;~             "Width: " & $aPos[2] & @CRLF & _
;~             "Height: " & $aPos[3])

$gW=$aPos[2] - 8
$gH=$aPos[3] - 40
$gX=$aPos[0] + 4
$gY=$aPos[1] + 48

$hGUI = GUICreate("Test", $gW, $gH, $gX, $gY , BitOr($WS_POPUP,$WS_DLGFRAME))
;~ $hGUI = GUICreate("Test", $gW, $gH, $gX, $gY )
GUISetBkColor(0xFF0000)

GUISetState()

While 1
  If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit

    ; Retrieve the position as well as height and width of the active window.
    $aPos = WinGetPos($hWnd)
;~  winsetontop($hgui,"",$WINDOWS_NOONTOP)
    $gW=$aPos[2] - 8
    $gH=$aPos[3] - 60
    $gX=$aPos[0] + 4
    $gY=$aPos[1] + 48
    _GUICreateInvRect($hGUI, 4, 4, $gW-8, $gH-8)
    winmove($hGui,"",$gX,$gY, $gW, $gH)
winsetontop($hgui,"",$WINDOWS_ONTOP)
    sleep(100)
Wend

Func _GUICreateInvRect($hWnd, $iX, $iY, $iW, $iH)

    $aPos = WinGetPos($hWnd)

    Local $hMask_1 = _WinAPI_CreateRectRgn(0, 0, $aPos[2], $iY)
    Local $hMask_2 = _WinAPI_CreateRectRgn(0, 0, $iX, $aPos[3])
    Local $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, 0, $aPos[2], $aPos[3])
    Local $hMask_4 = _WinAPI_CreateRectRgn(0, $iY + $iH, $aPos[2], $aPos[3])

    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2)
    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2)
    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2)

    _WinAPI_DeleteObject($hMask_2)
    _WinAPI_DeleteObject($hMask_3)
    _WinAPI_DeleteObject($hMask_4)

    _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1)

EndFunc

 

Edited by junkew

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By xYuri
      This simple dllcall gives me error 5, access denied,
      Func _WinAPI_VkKeyScan($__key) _WinAPI_SetLastError(0) $res = DllCall('User32.dll', 'SHORT', 'VkKeyScan', 'CHAR', $__key) _xConsole('res: '&$res) $_LastErr = _WinAPI_GetLastError() If $_LastErr <> 0 Then _xConsole('Err: {' & $_LastErr & '}> ' & _WinAPI_GetLastErrorMessage()) Return $res EndFunc Am i doing something wrong?
      Also tried VkKeyScanA and W
      Edit:
      I want to send `:` via PostMessage() WM_KEYDOWN
    • By Sori
      Not going to dump the code down because it's essentially a keylogger.
      <snip>
    • By UEZ
      Here some graphical examples written completely in FreeBasic just for fun.  
      _WinAPI_SetWindowTitleIcon Check for Numeric Entry in an EditBox using RegEx CreateWindowEx (hGUI) Example FB 3D Starfield Rotating Flight FB File2Bas Code Generator FB Fire Particles FB Fireworks FB GFX Examples FB Image to Trapezoid Transformation FB Layered Parallax Effect FB Plasma FB Puristic Clock FB Rotating Cube FB Rotating Earth FB Rutt Etra Izer Effect FB Simple Recursive Tree Generator FB Snowfall FB Tunnel Flight FB Water Effect FMOD Examples GDI - GDI+ 3D Sinus Wave GDI - GDI+ Animated Pythagoras Tree GDI - GDI+ Bezier Lines GDI - GDI+ Particles - Repulsive Force Sim v2.0 GDI - GDI+ Plasma v5 Booster GDI - GDI+ Random Pattern GDI - GDI+ Space Flight GDI - GDI+ Tunnel Flight - WipeOut Style GDI Classic Raytraced Tunnel GDI Elastic Twister Effect GDI Exploding Pixels GDI Infinite Image Zoom Flight GDI Liquid Pixels GDI Mandelbrot GDI Particle Repulsion Grid GDI Particles Mouse Attraction GDI Starfield GDI The Nautilus Raymarcher GDI Worm Tunnel Flight GDI+ 3D Starfield Scrolling v1 Booster GDI+ 3D Starfield Scrolling v3 Booster GDI+ Convert Bitmap to ASCII GDI+ GIF Anim to ASCII Player GDI+ Image Painting GDI+ Impossible Possible GDI+ Kaleidoscope GDI+ Performance Test - Au3 vs FB GDI+ Polar Clock GDI+ Rotating Earth GDI+ Spiral Text GDI+ Star Wars Scroller GDI+ Streamer GDI+ Swiss Railway Clock GDI+ The MATRIX Ini Read - Write Rutt_Etra_Izer_Booster Stack TitchySID uFMOD  
      Download: FreeBasic Examples build 2019-05-08.rar
       
      I will add new examples from time to time.
       
      FreeBasic source codes are also included.
       
    • By TheDcoder
      Hi, I thought I would never post a C/WinAPI related question in this forum ever, but here we are after a few years and me having learnt enough of C to write a basic console program
      My issue is that I am trying to read my child process's stdout output but ReadFile never returns if the child exits or if it is killed... very strange , I have been trying to work my way around this. The options I can think of are:
      Create a new thread and check for existance of the process constantly while reading Somehow make the pipe asynchronous (overlapped) so that I can read it in a non-blocking manner Fix ReadFile to return when the process ends Obviously I would prefer No. 3, I just want to make my program work. Here is my code if you guys want to take a look:
      // No text highlighting for C/C++ but we have it for C#? Blasphemy! bool allium_start(struct TorInstance *instance, char *config, allium_pipe *output_pipes) { char *cmd; // Figure out the command string for execution if (config) { char *parameters = " -f -"; cmd = malloc(strlen(instance->tor_path) + strlen(parameters) + 1); if (!cmd) return false; strcpy(cmd, instance->tor_path); strcat(cmd, parameters); } else cmd = instance->tor_path; // Prepare startup info with appropriate information SecureZeroMemory(&instance->startup_info, sizeof instance->startup_info); instance->startup_info.dwFlags = STARTF_USESTDHANDLES; SECURITY_ATTRIBUTES pipe_secu_attribs = {sizeof(SECURITY_ATTRIBUTES), NULL, true}; HANDLE pipes[2]; if (output_pipes == NULL) { CreatePipe(&pipes[0], &pipes[1], &pipe_secu_attribs, 0); output_pipes = pipes; } instance->startup_info.hStdOutput = output_pipes[1]; instance->startup_info.hStdError = output_pipes[1]; instance->stdout_pipe = output_pipes[0]; // Stored for internal reference if (config) { // Reuse the pipes array to store standard input pipes CreatePipe(&pipes[0], &pipes[1], &pipe_secu_attribs, 0); instance->startup_info.hStdInput = pipes[0]; } // Create the process bool success = CreateProcessA( NULL, cmd, NULL, NULL, config ? true : false, 0, NULL, NULL, &instance->startup_info, SecureZeroMemory(&instance->process, sizeof instance->process) ); // Free command string if needed if (config) free(cmd); // Write config to Tor's standard input unsigned long bytes_written; if (success) { WriteFile(pipes[1], config, strlen(config), &bytes_written, NULL); // Work around for simulating Ctrl + Z which sends the substitution character (ASCII 26), // this is needed in order for Tor to detect EOT/EOF while reading the config WriteFile(pipes[1], &(char){26}, 1, &bytes_written, NULL); } CloseHandle(pipes[1]); // Return on failure if (!success) return false; } char *allium_read_stdout_line(struct TorInstance *instance) { char *buffer = instance->buffer.data; // Check for valid buffer and allocate if needed if (instance->buffer.size == 0 || !buffer) { buffer = instance->buffer.data = malloc(instance->buffer.size = 80 + 1); if (!buffer) return NULL; } // Process the input unsigned int read_len = 0; while (true) { // Read data unsigned long bytes_read; if (ReadFile(instance->stdout_pipe, buffer, 1, &bytes_read, NULL) == false || bytes_read == 0) return NULL; // Check if we have reached end of line if (buffer[0] == '\n') break; // Proceed to the next character ++buffer; ++read_len; // Resize buffer if it is full if (read_len == instance->buffer.size) { char *new_buffer = malloc(instance->buffer.size += 50); if (new_buffer) memcpy(new_buffer, instance->buffer.data, read_len); free(instance->buffer.data); if (!new_buffer) return NULL; instance->buffer.data = new_buffer; buffer = instance->buffer.data + read_len; } } // Terminate the new line with null character and return // Special handling for Windows, terminate at CR if present buffer[read_len >= 2 && buffer[-1] == '\r' ? -1 : 0] = '\0'; } The allium_start function creates the redirection pipes and the child process, the other allium_read_stdout_line function reads from the stdout pipe created by the first function, ReadFile in this function does not return when the child ends or gets killed.

      I appriciate the help of the WinAPI gurus here, thanks in advance!
    • By Miliardsto
      hello Im wondering if it is possible to process image in autoit like this
      1. firstly there is colorfull wallpaper
      2. Fill all colors (exception rose color) - with white
      3. Fill rose color with black color
      I see Gdi functions have things to manipulate images
      https://imgur.com/a/lFdY26g
×
×
  • Create New...