Jump to content

GDI flickering


Recommended Posts

I need help to build a script to write with my joypad.

Idea is stolen from 'texter'

Posted Image

that make possible a lot of possibilities:

Posted Image

have some idea to how build script, but have low skill in coding.

Now i post some (bad) GDI code to start :

[need fix for flickering please]

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

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

#Include <Misc.au3>

;----------------------------------------------var
Global $gui, $guiPos, $pic, $picPos
Global $f_sx_commander = 0
Local $msg

$dll = DllOpen("user32.dll")

;---------------------------------------------- GUI
$gui = GUICreate("whatistexter", 512, 256)
$pic = GUICreate("", 512, 256, 0, @DesktopHeight - (@desktopheight - 360), $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
GUICtrlCreatePic(@ScriptDir & "\wallpaper.bmp", 0, 0, 0, 0)
WinSetOnTop("whatistexter", "", 1)
GUISetState(@SW_SHOW, $pic)
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)
;---------------------------------------------- hotkey
HotKeySet("{ESC}", "main")

$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)

;---------------------------------------------- MAIN
Do
    $msg = GUIGetMsg()
    
;---------------------------------------------- left
    If _IsPressed("64", $dll) Then
;~          MsgBox(0,"_IsPressed", " Numeric keypad 4 key");left
        my_left_square(675,850,25)
    ElseIf  _IsPressed("66", $dll) Then
;~          MsgBox(0,"_IsPressed", " Numeric keypad 6 key");right
        my_left_square(825,850,25)
    ElseIf  _IsPressed("62", $dll) Then     
;~          MsgBox(0,"_IsPressed", " Numeric keypad 2 key");down
        my_left_square(750,925,25)
    ElseIf  _IsPressed("68", $dll) Then
;~          MsgBox(0,"_IsPressed", " Numeric keypad 8 key");up
        my_left_square(750,780,25)
    ElseIf _IsPressed("67", $dll) Then
;~          MsgBox(0,"_IsPressed", " Numeric keypad 4 key");left-up
        my_left_square(675,800,25)
    ElseIf  _IsPressed("69", $dll) Then
;~          MsgBox(0,"_IsPressed", " Numeric keypad 6 key");right-up
        my_left_square(825,800,25)
    ElseIf  _IsPressed("61", $dll) Then     
;~          MsgBox(0,"_IsPressed", " Numeric keypad 2 key");left-down
        my_left_square(675,925,25)
    ElseIf  _IsPressed("63", $dll) Then
;~          MsgBox(0,"_IsPressed", " Numeric keypad 8 key");right-down
        my_left_square(825,925,25)
    Else
        my_left_square(750,850,25)
    EndIf


;---------------------------------------------- right
    If _IsPressed("41", $dll) Then
        my_left_square(450,850,25);a
    ElseIf  _IsPressed("44", $dll) Then
        my_left_square(600,850,25);d
    ElseIf  _IsPressed("58", $dll) Then     
        my_left_square(525,925,25);x
    ElseIf  _IsPressed("57", $dll) Then
        my_left_square(525,780,25);w
    ElseIf _IsPressed("51", $dll) Then
        my_left_square(450,800,25);q
    ElseIf  _IsPressed("45", $dll) Then
        my_left_square(600,800,25);e
    ElseIf  _IsPressed("5A", $dll) Then     
        my_left_square(450,925,25);z
    ElseIf  _IsPressed("43", $dll) Then
        my_left_square(600,925,25);c
    Else
        my_left_square(525,850,25)
    EndIf
    
    
    Sleep(10)
    
Until $msg = $GUI_EVENT_CLOSE





Func main()
    Exit
EndFunc  ;==>main


func my_left_square($start_x, $start_y, $mylenght)
    _GDIPlus_Startup ()
    $hDC = _WinAPI_GetWindowDC(0)

    $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
    $Color = 0xFF000000
    $hPen = _GDIPlus_PenCreate($Color,2)

    _GDIPlus_GraphicsDrawLine($hGraphic, $start_x , $start_y, $start_x + $mylenght, $start_y, $hPen);oriz UP
    _GDIPlus_GraphicsDrawLine($hGraphic, $start_x  + $mylenght, $start_y, $start_x + $mylenght, $start_y + $mylenght, $hPen);right

    _GDIPlus_GraphicsDrawLine($hGraphic, $start_x , $start_y + $mylenght, $start_x + $mylenght, $start_y + $mylenght, $hPen);oriz down          
    _GDIPlus_GraphicsDrawLine($hGraphic, $start_x , $start_y, $start_x, $start_y + $mylenght, $hPen);left
    
    $Color += Hex(2)
    _GDIPlus_PenSetColor($hPen, $Color)

    Sleep(25)


    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
    _WinAPI_ReleaseDC(0, $hDC)
    _GDIPlus_Shutdown()
    $f_sx_commander = 0
EndFunc

Next step is to study and add some joystick UDF see in example forum.

Anyone want to partecipate and help me to realize this handy tool ?

Thank you for your time,

m.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...