caramen

[Solved]Auto text

21 posts in this topic

#1 ·  Posted (edited)

Hello guys. 

I totaly reworked a script to get less problem(Melba23) and i used a topic to copy an existing script and modified it. 

Since my last post it was bad evaluated as a spam bot but by my fault since i have not explained the purpose of it corectly. (Yes i got ugly english)

 

Then FIRST OF ALL the purpose of this script is to allow a call center to complet multiple fields in internet explorer and optionnaly; i am gonna see that after the principal code to configure multiple email that can be send. I know there is some UDF for outlook etc... but i want a single script to do all. this is the way i want to do that. 

 

Ok this is my complete code for the moment. 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>


$dll = DllOpen("user32.dll")

Global    $EnvoyerMess1Sub1
Global    $EnvoyerMess2Sub1
Global    $EnvoyerMess3Sub1
Global    $EnvoyerMess4Sub1
Global    $EnvoyerMess5Sub1

Global    $EnvoyerMess1Sub2
Global    $EnvoyerMess2Sub2
Global    $EnvoyerMess3Sub2
Global    $EnvoyerMess4Sub2
Global    $EnvoyerMess5Sub2

Global    $EnvoyerMess1Sub3
Global    $EnvoyerMess2Sub3
Global    $EnvoyerMess3Sub3
Global    $EnvoyerMess4Sub3
Global    $EnvoyerMess5Sub3

Global    $EnvoyerMess1Sub4
Global    $EnvoyerMess2Sub4
Global    $EnvoyerMess3Sub4
Global    $EnvoyerMess4Sub4
Global    $EnvoyerMess5Sub4

Global Const $SettingsFile = @SCRIPTDIR & '\Settings.ini'
$Setting1 = IniRead ($SettingsFile, 'Stats', 'Utilisation', "ERROR")
IniWrite ($SettingsFile, 'Stats', 'Utilisation',$Setting1+1)

$Valeur1 = IniRead ($SettingsFile, 'NomMenu', 'Menu1', "ERROR")
$Valeur2 = IniRead ($SettingsFile, 'NomMenu', 'Menu2', "ERROR")
$Valeur3 = IniRead ($SettingsFile, 'NomMenu', 'Menu3', "ERROR")
$Valeur4 = IniRead ($SettingsFile, 'NomMenu', 'Menu4', "ERROR")

$Valeur11 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu1.1', "ERROR")
$Valeur12 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu1.2', "ERROR")
$Valeur13 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu1.3', "ERROR")
$Valeur14 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu1.4', "ERROR")
$Valeur15 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu1.5', "ERROR")

$Valeur21 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu2.1', "ERROR")
$Valeur22 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu2.2', "ERROR")
$Valeur23 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu2.3', "ERROR")
$Valeur24 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu2.4', "ERROR")
$Valeur25 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu2.5', "ERROR")

$Valeur31 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu3.1', "ERROR")
$Valeur32 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu3.2', "ERROR")
$Valeur33 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu3.3', "ERROR")
$Valeur34 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu3.4', "ERROR")
$Valeur35 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu3.5', "ERROR")

$Valeur41 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu4.1', "ERROR")
$Valeur42 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu4.2', "ERROR")
$Valeur43 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu4.3', "ERROR")
$Valeur44 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu4.4', "ERROR")
$Valeur45 = IniRead ($SettingsFile, 'NomMenu', 'SousMenu4.5', "ERROR")

$Message11 = IniRead ($SettingsFile, 'Messages', 'Message11', "ERROR")
$Message12 = IniRead ($SettingsFile, 'Messages', 'Message11', "ERROR")
$Message13 = IniRead ($SettingsFile, 'Messages', 'Message11', "ERROR")
$Message14 = IniRead ($SettingsFile, 'Messages', 'Message11', "ERROR")
$Message15 = IniRead ($SettingsFile, 'Messages', 'Message11', "ERROR")

$Message21 = IniRead ($SettingsFile, 'Messages', 'Message21', "ERROR")
$Message22 = IniRead ($SettingsFile, 'Messages', 'Message22', "ERROR")
$Message23 = IniRead ($SettingsFile, 'Messages', 'Message23', "ERROR")
$Message24 = IniRead ($SettingsFile, 'Messages', 'Message24', "ERROR")
$Message25 = IniRead ($SettingsFile, 'Messages', 'Message25', "ERROR")

$Message31 = IniRead ($SettingsFile, 'Messages', 'Message31', "ERROR")
$Message32 = IniRead ($SettingsFile, 'Messages', 'Message32', "ERROR")
$Message33 = IniRead ($SettingsFile, 'Messages', 'Message33', "ERROR")
$Message34 = IniRead ($SettingsFile, 'Messages', 'Message34', "ERROR")
$Message35 = IniRead ($SettingsFile, 'Messages', 'Message35', "ERROR")

$Message41 = IniRead ($SettingsFile, 'Messages', 'Message41', "ERROR")
$Message42 = IniRead ($SettingsFile, 'Messages', 'Message42', "ERROR")
$Message43 = IniRead ($SettingsFile, 'Messages', 'Message43', "ERROR")
$Message44 = IniRead ($SettingsFile, 'Messages', 'Message44', "ERROR")
$Message45 = IniRead ($SettingsFile, 'Messages', 'Message45', "ERROR")

BuildHiddenGUI()

While 1
    Sleep ( 10 )
    If _IsPressed("04", $dll) Then CallCustomContextMenu()
    $msg = GUIGetMsg()
    Switch $msg

;~ =====================================================

        Case $EnvoyerMess1Sub1
;~         MouseClick("left")

           Send(""&$Message11)

        Case $EnvoyerMess2Sub1
           Send(""&$Message12)

        Case $EnvoyerMess3Sub1
           Send(""&$Message13)

        Case $EnvoyerMess4Sub1
           Send(""&$Message14)

        Case $EnvoyerMess5Sub1
           Send(""&$Message15)

;~ ======================================================

        Case $EnvoyerMess1Sub2

        Case $EnvoyerMess2Sub2

        Case $EnvoyerMess3Sub2

        Case $EnvoyerMess4Sub2

        Case $EnvoyerMess5Sub2

;~ ======================================================

        Case $EnvoyerMess1Sub3

        Case $EnvoyerMess2Sub3

        Case $EnvoyerMess3Sub3

        Case $EnvoyerMess4Sub3

        Case $EnvoyerMess5Sub3


;~ =======================================================

        Case $EnvoyerMess1Sub4

        Case $EnvoyerMess2Sub4

        Case $EnvoyerMess3Sub4

        Case $EnvoyerMess4Sub4

        Case $EnvoyerMess5Sub4

;~ ======================================================

        Case $ConfigITEM

    EndSwitch

WEnd
DllClose($dll)

Func BuildHiddenGUI()
    Global $Contextmenu, $msg, $GUI, $aTSR
    Global $SubMenu1, $folderitem, $programitem, $fileitem, $ConfigITEM, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    $aTSR = _GetTotalScreenResolution()

    $GUI = GuiCreate("GUI Context Menu",1,1, $aTSR[0], 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)

    GUISetState()

    $Contextmenu = GUICtrlCreateContextMenu()
    $SubMenu1 = GUICtrlCreateMenu(""&$Valeur1, $Contextmenu)
      $EnvoyerMess1Sub1 = GUICtrlCreateMenuItem(""&$Valeur11, $SubMenu1)
      $EnvoyerMess2Sub1 = GUICtrlCreateMenuItem(""&$Valeur12, $SubMenu1)
      $EnvoyerMess3Sub1 = GUICtrlCreateMenuItem(""&$Valeur13, $SubMenu1)
      $EnvoyerMess4Sub1 = GUICtrlCreateMenuItem(""&$Valeur14, $SubMenu1)
      $EnvoyerMess5Sub1 = GUICtrlCreateMenuItem(""&$Valeur15, $SubMenu1)
    $SubMenu2 = GUICtrlCreateMenu(""&$Valeur2, $Contextmenu)
      $EnvoyerMess1Sub2 = GUICtrlCreateMenuItem(""&$Valeur21, $SubMenu2)
      $EnvoyerMess2Sub2 = GUICtrlCreateMenuItem(""&$Valeur22, $SubMenu2)
      $EnvoyerMess3Sub2 = GUICtrlCreateMenuItem(""&$Valeur23, $SubMenu2)
      $EnvoyerMess4Sub2 = GUICtrlCreateMenuItem(""&$Valeur24, $SubMenu2)
      $EnvoyerMess5Sub2 = GUICtrlCreateMenuItem(""&$Valeur25, $SubMenu2)
    $SubMenu3 = GUICtrlCreateMenu(""&$Valeur3, $Contextmenu)
      $EnvoyerMess1Sub3 = GUICtrlCreateMenuItem(""&$Valeur31, $SubMenu3)
      $EnvoyerMess2Sub3 = GUICtrlCreateMenuItem(""&$Valeur32, $SubMenu3)
      $EnvoyerMess3Sub3 = GUICtrlCreateMenuItem(""&$Valeur33, $SubMenu3)
      $EnvoyerMess4Sub3 = GUICtrlCreateMenuItem(""&$Valeur34, $SubMenu3)
      $EnvoyerMess5Sub3 = GUICtrlCreateMenuItem(""&$Valeur35, $SubMenu3)
    $SubMenu4 = GUICtrlCreateMenu(""&$Valeur4, $Contextmenu)
      $EnvoyerMess1Sub4 = GUICtrlCreateMenuItem(""&$Valeur41, $SubMenu4)
      $EnvoyerMess2Sub4 = GUICtrlCreateMenuItem(""&$Valeur42, $SubMenu4)
      $EnvoyerMess3Sub4 = GUICtrlCreateMenuItem(""&$Valeur43, $SubMenu4)
      $EnvoyerMess4Sub4 = GUICtrlCreateMenuItem(""&$Valeur44, $SubMenu4)
      $EnvoyerMess5Sub4 = GUICtrlCreateMenuItem(""&$Valeur45, $SubMenu4)

    GUICtrlCreateMenuItem("", $contextmenu)     ; separator

   $ConfigITEM = GUICtrlCreateMenuItem("Configuration", $contextmenu)
EndFunc

Func CallCustomContextMenu()
    Local $contextmenu, $msg
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

Func WinGroupActive()
    AutoItSetOption("WinTitleMatchMode", 4)
    If WinActive("classname=ExploreWClass") _
        Or WinActive("classname=CabinetWClass") _
        Or WinActive("classname=#32770") _
        Or WinActive("classname=DV2ControlHost") _
        Or WinActive("classname=MMCMainFrame") _
        Or WinActive("[CLASS:Progman; Title:Program Manager]") Then
        Return True
    Else
        Return False
    EndIf
EndFunc

 

By this way the script is very more clear about the purpose. When i use middle mouse click i got a context menu that apear. Then i can send the preconfigured message in the ini file that will alow me to send particular message without spending much time on it. 

First question : 

When i push middle click on a particular windows how to get back focus on it ??

plz dont make attention on the declared fonction that are unused i am gonna clean that at the end. 

Edited by caramen

Share this post


Link to post
Share on other sites



i thougth about 

$windows =  WinGetTitle("[active]")
            WinActivate (""&$windows)

but where tu put the function WinGetTitle? 

Share this post


Link to post
Share on other sites

solution : 

Func CallCustomContextMenu()
    Global      $windows =  WinGetTitle("[active]")
    Local $contextmenu, $msg
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc

thx.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Script is finish and work well but i got a new improvement but difficult for me again x)

 

Since i use Settings.ini file and i read all values at the start of the script and not in the gui loop

If i change any value in the ini file i need to Quit my script executable and luch it again 

 

Is there a way to close the script and start it again after changing a value automaticaly ? :blink:

Edited by caramen

Share this post


Link to post
Share on other sites

Solution : 

 

Thx x)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's possible without restarting. Just put all inireads in a func. This func has to be called at script start and on button click "ReRead INI". Therefor this "ReRead INI"-button has to be implementet in you GUI.

Edited by AutoBert

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I thougth about that and tryed with bad logic,

include made me add 3 line of code x) it s better :P 

 

THx

Edited by caramen

Share this post


Link to post
Share on other sites

Now this is my problem :  

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Include <Restart.au3>


$dll = DllOpen("user32.dll")


Global $fInterrupt = False

Global $cButton = "NO"


Global    $Boucle
Global    $BoucleStop


Global Const $SettingsFile = @SCRIPTDIR & '\Settings.ini'
$Setting1 = IniRead ($SettingsFile, 'Stats', 'Utilisation', "ERROR")
IniWrite ($SettingsFile, 'Stats', 'Utilisation',$Setting1+1)


$MessageBoucle = IniRead ($SettingsFile, 'Messages', 'MessageBoucle', "ERROR")

BuildHiddenGUI()

While 1
    Sleep ( 10 )
    If _IsPressed("04", $dll) Then CallCustomContextMenu()
    $msg = GUIGetMsg()
    Switch $msg



        Case $Boucle
           GUICtrlSetData($cButton, "No")
                    _Running()

           WinActivate (""&$windows)
                    Sleep (5000)
           Send(""&$MessageBoucle)
                    Sleep (5000)

        Case $BoucleStop
           GUICtrlSetData($cButton, "Yes")


    EndSwitch

WEnd
DllClose($dll)

Func BuildHiddenGUI()
    Global $Contextmenu, $msg, $GUI, $aTSR
    Global $SubMenu1, $folderitem, $programitem, $fileitem, $ConfigITEM, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    $aTSR = _GetTotalScreenResolution()

    $GUI = GuiCreate("GUI Context Menu",1,1, $aTSR[0], 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)

    GUISetState()

    $Contextmenu = GUICtrlCreateContextMenu()


    $Boucle = GUICtrlCreateMenuItem("Boucle", $contextmenu)
    $BoucleStop = GUICtrlCreateMenuItem("Boucle Stop", $contextmenu)

    GUICtrlCreateMenuItem("", $contextmenu)

    $Aide = GUICtrlCreateMenuItem("Aide", $contextmenu)



EndFunc

Func CallCustomContextMenu()
    Global      $windows =  WinGetTitle("[active]")
    Local $contextmenu, $msg
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

Func WinGroupActive()
    AutoItSetOption("WinTitleMatchMode", 4)
    If WinActive("classname=ExploreWClass") _
        Or WinActive("classname=CabinetWClass") _
        Or WinActive("classname=#32770") _
        Or WinActive("classname=DV2ControlHost") _
        Or WinActive("classname=MMCMainFrame") _
        Or WinActive("[CLASS:Progman; Title:Program Manager]") Then
        Return True
    Else
        Return False
    EndIf
 EndFunc

 Func _Running()

    ConsoleWrite("Running"  & @CRLF) ; Now we are here we can no longer read the main loop

    ; Here we run our loop checking every second if the flag has been set in the handler
    $nBegin = TimerInit()
    Do
        Sleep(1000)

        ; Here we look for the flag set in the handler
        If $fInterrupt = True Then
            ConsoleWrite("Interrupted" & @CRLF)
            ; Reset the flag
            $fInterrupt = False
            ; And return early
            Return
        EndIf
        ConsoleWrite("Still running!" & @CRLF)

    Until TimerDiff($nBegin) > 50000

    ; Now the loop has finished naturally

EndFunc   ;==>_Running

 Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

    ; The button was pressed
    If BitAND($wParam, 0x0000FFFF) = $cButton Then
        Switch GUICtrlRead($cButton)
            ; We only want to react if the function is already running
            Case "No"
                ; Set the flag
                $fInterrupt = True
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc   ;==>_WM_COMMAND

(i made reproducer to make the script shorter) 

I added these case :

Case $Boucle
           GUICtrlSetData($cButton, "No")
                    _Running()

           WinActivate (""&$windows)
                    Sleep (5000)
           Send(""&$MessageBoucle)
                    Sleep (5000)

        Case $BoucleStop
           GUICtrlSetData($cButton, "Yes")

 

i whould like to make the loop and exit loop after Case

$BoucleStop

I tryed the help given in that post : 

 

but cant get it working. 

Share this post


Link to post
Share on other sites

@caramen: please don't pm me, after the pm i remember this thread is only pseudo for 2 locked threads.

Quote

caramen,

When you asked via PM if you could post a thread about interrupting a loop I did not expect you to repost essentially the same code as in the thread I locked yesterday.

and in the other way, why needing help:

 

1 hour ago, caramen said:

include made me add 3 line of code x) it s better :P 

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I pm you to get faster answer* 

I did what melba requested (rework the code) (and explain the purpose ) (like i explained you in the PM :/ ) 

Edited by caramen

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

but your real attempt is still against forumrules, so please don't pm me. The way to solve is already showed:

1 hour ago, AutoBert said:

It's possible without restarting. Just put all inireads in a func. This func has to be called at script start and on button click "ReRead INI". Therefor this "ReRead INI"-button has to be implementet in you GUI.

but you find a better solution:

1 hour ago, caramen said:

I thougth about that and tryed with bad logic,

include made me add 3 line of code x) it s better :P 

 

THx

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I am sorry man. You are mistaking about the question. 

 

The first question is answered : how to restart the script ? 

 

The second question is an other probleme : How to stop the loop during the case execution ?

Or may the restart script is a solution ? (but i cant get the context menu again while i am in the loop)

 

Edited by caramen

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

And trust me i canT afford an other warning so be sure i took attention about not breaking any rule .... :sweating: 

 

Or maybe it s me mistaking ? In this case i am gonna retract any question and stop posting. 

Edited by caramen

Share this post


Link to post
Share on other sites
3 minutes ago, caramen said:

And trust me i canT afford an other warning so be sure i took attention about not breaking any rule

Don't be too sure that isn't coming ... you are in the queue for review and zero credit left.. verdict will be there soon so better lay very low till then.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

When i say i cant afford i main : i must not have an other one. did i spelled whrong ?

Share this post


Link to post
Share on other sites

caramen,

This time you have explained yourself clearly in the OP and not just spoken of a "spambot" (which is why the thread was locked last time), so we are going to leave the thread open.

However, the Forum rules clearly prohibit PMing others for help, so consider yourself suitably admonished for doing so - please do not make a habit of it in future.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I am on the good way xD. Thanks melba i thougth i was mistaking again. Jos made me afraid a lot :sweating:.

 

So i repost a reworked Reproducer to try to get the while working. Can someone help me ?

 

I am trying to push middle click:

-Start loop by clicking : Boucle

Re push middle click 

-Stop loop if i click : Boucle Stop

This is for send msg on monitored server. 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Include <Restart.au3>


$dll = DllOpen("user32.dll")


Global $fInterrupt = False

Global $Flag = "Yes"


Global    $Boucle
Global    $BoucleStop


Global Const $SettingsFile = @SCRIPTDIR & '\Settings.ini'
$Setting1 = IniRead ($SettingsFile, 'Stats', 'Utilisation', "ERROR")
IniWrite ($SettingsFile, 'Stats', 'Utilisation',$Setting1+1)
IniWrite ($SettingsFile, 'Messages', 'MessageBoucle','Message test')

$MessageBoucle = IniRead ($SettingsFile, 'Messages', 'MessageBoucle', "ERROR")

BuildHiddenGUI()

While 1
    Sleep ( 10 )
    If _IsPressed("04", $dll) Then CallCustomContextMenu()
    $msg = GUIGetMsg()
    Switch $msg



        Case $Boucle
           $Flag = "Yes"
                    _Running()

           WinActivate (""&$windows)
           Send(""&$MessageBoucle)
                    Sleep (5000)
        Case $BoucleStop
           $Flag= "Yes"


    EndSwitch

WEnd

DllClose($dll)

;~ =========================================GUI================================================


Func BuildHiddenGUI()
    Global $Contextmenu, $msg, $GUI, $aTSR
    Global $SubMenu1, $folderitem, $programitem, $fileitem, $ConfigITEM, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    $aTSR = _GetTotalScreenResolution()

    $GUI = GuiCreate("GUI Context Menu",1,1, $aTSR[0], 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)

    GUISetState()

    $Contextmenu = GUICtrlCreateContextMenu()


    $Boucle = GUICtrlCreateMenuItem("Boucle", $contextmenu)
    $BoucleStop = GUICtrlCreateMenuItem("Boucle Stop", $contextmenu)

    GUICtrlCreateMenuItem("", $contextmenu)

    $Aide = GUICtrlCreateMenuItem("Aide", $contextmenu)



EndFunc



Func CallCustomContextMenu()
    Global      $windows =  WinGetTitle("[active]")
    Local $contextmenu, $msg
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

;~ =========================================================================================


;~ ========================================While attemp=================================================


 Func _Running()

    ConsoleWrite("Running"  & @CRLF) ; Now we are here we can no longer read the main loop

    ; Here we run our loop checking every second if the flag has been set in the handler
    $nBegin = TimerInit()
    Do
        Sleep(1000)

        ; Here we look for the flag set in the handler
        If $fInterrupt = True Then
            ConsoleWrite("Interrupted" & @CRLF)
            ; Reset the flag
            $fInterrupt = False
            ; And return early
            Return
        EndIf
        ConsoleWrite("Still running!" & @CRLF)

    Until TimerDiff($nBegin) > 50000

    ; Now the loop has finished naturally

EndFunc   ;==>_Running

 Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)

    ; The button was pressed
    If BitAND($wParam, 0x0000FFFF) = $Flag Then
        Switch $cButton
            ; We only want to react if the function is already running
            Case $Msg
                ; Set the flag
                $fInterrupt = True
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc   ;==>_WM_COMMAND

;~ =====================================================================================================

 

Edited by caramen

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

@Melba23 can you explain me how to do the trick you explained me but with that kinda script ?

 

I have to admite i cant realy understand that trick i dont realy want a posted script made by you but i whould prefer understand the trick to make my own script. 

 

I can read the tutorial about flags and try lot of things to introduce exemples.but  i am not getting anything working. what i am missing ?

 

Edited by caramen

Share this post


Link to post
Share on other sites

I am still working on this and trying. But failing :/ 

Reworked reproducer : 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Include <Restart.au3>

Opt("GUIOnEventMode", 0)

$dll = DllOpen("user32.dll")


Global $fInterrupt = False

Global $Flag = "Yes"


Global    $Boucle
Global    $Reload
Global    $BoucleStop


Global Const $SettingsFile = @SCRIPTDIR & '\Settings.ini'
$Setting1 = IniRead ($SettingsFile, 'Stats', 'Utilisation', "ERROR")
IniWrite ($SettingsFile, 'Stats', 'Utilisation',$Setting1+1)
IniWrite ($SettingsFile, 'Messages', 'MessageBoucle','Message test')

$MessageBoucle = IniRead ($SettingsFile, 'Messages', 'MessageBoucle', "ERROR")

BuildHiddenGUI()

While 1
;~    Global        $windows =  WinGetTitle("[active]")
    Sleep ( 10 )
    If _IsPressed("04", $dll) Then CallCustomContextMenu()
    $msg = GUIGetMsg()
    Switch $msg



        Case $Boucle
           WinActivate (""&$windows)
           _Running()

        Case $BoucleStop

           WinActivate (""&$windows)

        Case $Reload
             _ScriptRestart()

    EndSwitch

WEnd

DllClose($dll)

;~ =========================================GUI================================================


Func BuildHiddenGUI()
    Global $Contextmenu, $msg, $GUI, $aTSR
    Global $SubMenu1, $folderitem, $programitem, $fileitem, $ConfigITEM, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    $aTSR = _GetTotalScreenResolution()

    $GUI = GuiCreate("GUI Context Menu",1,1, $aTSR[0], 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)

    GUISetState()

    $Contextmenu = GUICtrlCreateContextMenu()


    $Boucle = GUICtrlCreateMenuItem("Boucle", $contextmenu)
     GUICtrlSetOnEvent($Boucle, "_Running")
    $BoucleStop = GUICtrlCreateMenuItem("Boucle Stop", $contextmenu)
     GUICtrlSetOnEvent($BoucleStop, "")
    $Reload = GUICtrlCreateMenuItem("Reload", $contextmenu)
     GUICtrlSetOnEvent($Reload, "_ScriptRestart")


    GUICtrlCreateMenuItem("", $contextmenu)

    $Aide = GUICtrlCreateMenuItem("Aide", $contextmenu)



EndFunc



Func CallCustomContextMenu()
    Global      $windows =  WinGetTitle("[active]")
    Local $contextmenu, $msg
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

;~ =========================================================================================


;~ ========================================While attemp=================================================


 Func _Running()

     For $i = 1 To 20
         ConsoleWrite("-Func 1 Running" & @CRLF)
         Sleep(100)
     Next
     ConsoleWrite(">Func 1 Ended" & @CRLF)

EndFunc   ;==>_Running

Some question apear... 

 

Why? 

If i use ("GUIOnEventMode", 1) my function is running but i cant open the GUI context menu anymore. this little script part make me so crazy. guess i am gonna give up :(

 

Share this post


Link to post
Share on other sites

While your sample do "_Running()", the while is on the "Case $Boucle". So "CallCustomContextMenu()" can be done only after _Running() End.

While u do "For $i = 1 To 20 sleep(100)", "_IsPressed" is not fire.

You should look maybe arround AdlibRegister :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
;#Include <Restart.au3>

Opt("GUIOnEventMode", 0)

$dll = DllOpen("user32.dll")


Global $fInterrupt = False

Global $Flag = "Yes"


Global    $Boucle
Global    $Reload
Global    $BoucleStop


Global Const $SettingsFile = @SCRIPTDIR & '\Settings.ini'
$Setting1 = IniRead ($SettingsFile, 'Stats', 'Utilisation', "ERROR")
IniWrite ($SettingsFile, 'Stats', 'Utilisation',$Setting1+1)
IniWrite ($SettingsFile, 'Messages', 'MessageBoucle','Message test')

$MessageBoucle = IniRead ($SettingsFile, 'Messages', 'MessageBoucle', "ERROR")

BuildHiddenGUI()

While 1
;~    Global        $windows =  WinGetTitle("[active]")
    Sleep ( 10 )
    If _IsPressed("04", $dll) Then CallCustomContextMenu()
    $msg = GUIGetMsg()
    Switch $msg



        Case $Boucle
           WinActivate (""&$windows)
           ;_Running()
           AdlibRegister("_Running", 100); fire _Running all 100ms

        Case $BoucleStop

           WinActivate (""&$windows)
           AdlibUnRegister("_Running")
           ConsoleWrite(">Func 1 Ended" & @CRLF)

        Case $Reload
             ;_ScriptRestart()

    EndSwitch

WEnd

DllClose($dll)

;~ =========================================GUI================================================


Func BuildHiddenGUI()
    Global $Contextmenu, $msg, $GUI, $aTSR
    Global $SubMenu1, $folderitem, $programitem, $fileitem, $ConfigITEM, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    $aTSR = _GetTotalScreenResolution()

    $GUI = GuiCreate("GUI Context Menu",1,1, $aTSR[0], 1,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
    WinSetTrans( $GUI, '', 1)

    GUISetState()

    $Contextmenu = GUICtrlCreateContextMenu()


    $Boucle = GUICtrlCreateMenuItem("Boucle", $contextmenu)
     GUICtrlSetOnEvent($Boucle, "_Running")
    $BoucleStop = GUICtrlCreateMenuItem("Boucle Stop", $contextmenu)
     GUICtrlSetOnEvent($BoucleStop, "")
    $Reload = GUICtrlCreateMenuItem("Reload", $contextmenu)
     ;GUICtrlSetOnEvent($Reload, "_ScriptRestart")


    GUICtrlCreateMenuItem("", $contextmenu)

    $Aide = GUICtrlCreateMenuItem("Aide", $contextmenu)



EndFunc



Func CallCustomContextMenu()
    Global      $windows =  WinGetTitle("[active]")
    Local $contextmenu, $msg
    Global $newsubmenu, $folderitem, $programitem, $fileitem, $otheritem
    Global $folderitem1, $folderitem2, $programitem1, $programitem2
    Local $pos
    Global $GUI, $aTSR
    WinActivate ($GUI)
    ControlClick ( $GUI, "", "", "right", 1, $aTSR[0], 1)
EndFunc

Func _GetTotalScreenResolution()
    Local $aRet[2], $VirtualDesktopWidth, $VirtualDesktopHeight
    Global Const $SM_VIRTUALWIDTH = 78
    Global Const $SM_VIRTUALHEIGHT = 79
    $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $aRet[0] = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $aRet[1] = $VirtualDesktopHeight[0]
    Return $aRet
EndFunc

;~ =========================================================================================


;~ ========================================While attemp=================================================


 Func _Running()

     ;For $i = 1 To 20
         ConsoleWrite("-Func 1 Running" & @CRLF)
         ;Sleep(100)
     ;Next
     ;ConsoleWrite(">Func 1 Ended" & @CRLF)

 EndFunc   ;==>_Running

 

1 person likes this

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

    • harvester2001
      By harvester2001
      Hi
      I need your help I need create broadcast text message/notification to multiple lan clients. I can install listener program on pc its not a problem.
      But I don`t know how to start, could somebody write me example script how broadcast script and client who listen non stop for message should look like.
      I try to find example on forum but I have problem to understand those scripts.
      Many thx for help.
    • ur
      By ur
      I have a text file whose data will be as below.
      win10x64 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (32-bit)_2500.exe" SilentInstall.exe win10x64clone1 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (64-bit)_2500.exe" DM64.exe win10x64clone2 ~\erwin Notallowed1! "erwin Mart Server r9.7 (32-bit).exe" SilentInstall.exe win10x64clone3 ~\erwin Notallowed1! "erwin License Server r9.7 (32-bit).exe" SilentInstall.exe Each line will have multiple values separated by space.
      If a value contains space in it, the value is surrounded by quotes.
      My task is to check how many values are there in each line.
      If the line contains 5 values, I need to replace the 4th value with the string contained in a variable.
      If it contains 4 values then also  I need to replace the 4th value followed by appending 5 th value to it as SilentInstall.exe
      If the value I am replacing contains spaces then I need to surround the new value with quotes.
       
      Any one can suggest how to do this,??
    • marcoauto
      By marcoauto
      ciao,
      I need to scale an outlined GDI text in a GUI. The problem is that I can't do this. The outline is often out of the GUI
      I started from this script:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_PathTransform.htm
      that fit a string to windows and I changed
       $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
      $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path with 
      $aBounds = _GDIPlus_PathGetWorldBounds($hPath,$hMatrix,$hPen) ;Get bounding rectangle of the path with pen size but doesn't work
      so, I tried to change other thins, but nothing... Sometimes works, but if I change the string often result change
      This is my script:
      #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <array.au3> Example() Func Example() Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds ; Create GUI $iW = 650 $iH = 300 $hGUI = GUICreate("GDI+", $iW, $iH) GUISetState(@SW_SHOW) ; Draw a string using path _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing) ;~ _GDIPlus_GraphicsClear($hGraphic, 0xFF000000) $MergedImageBackgroundColor = 0x00000000 _GDIPlus_GraphicsClear($hGraphic, $MergedImageBackgroundColor) $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200) $stroke_size = 15 $hPen = _GDIPlus_PenCreate(0xFFFFBB00, $stroke_size) ;stroke size in pixel $hPen2 = _GDIPlus_PenCreate(0xFFFFff00, 2) ;stroke size in pixel _GDIPlus_PenSetLineJoin($hPen,$GDIP_PENSETLINEJOIN_ROUND) $hPath = _GDIPlus_PathCreate() ;Create new path object ;~ $fSize = 20 $hFamily = _GDIPlus_FontFamilyCreate("Myriad Pro") ;Create font family object $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0 Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_PathAddString($hPath, "autoitForeverLollipop", $tLayout, $hFamily);, 0, $fSize, $hFormat) ;Add the outline of the string to the path ;~ _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $fSize, $hFormat) ; Tranform Path to fit to window $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path $aPoints = _GDIPlus_PathGetPoints($hPath) ConsoleWrite($aBounds[0] & @CRLF) ConsoleWrite($aBounds[1] & @CRLF) ConsoleWrite($aBounds[2] & @CRLF) ConsoleWrite($aBounds[3] & @CRLF) ConsoleWrite($aPoints[$aPoints[0][0]][0] & " - " & $aPoints[1][0] & " + 2*" & $stroke_size & " = " & $aPoints[$aPoints[0][0]][0]-$aPoints[1][0]+2*$stroke_size & @CRLF) ;~ $aBounds[0] = $aBounds[0] $aBoundsNp = _GDIPlus_PathGetWorldBounds($hPath,0,$hPen) ;Get bounding rectangle of the path with pen ConsoleWrite($aBoundsNp[0] & @CRLF) ConsoleWrite($aBoundsNp[1] & @CRLF) ConsoleWrite($aBoundsNp[2] & @CRLF) ConsoleWrite($aBoundsNp[3] & @CRLF) ConsoleWrite($iW & " / 2 = " & $iW / 2 & @CRLF) ConsoleWrite("$ih / 2 = " & $iH / 2 & @CRLF) ;~ ConsoleWrite($iW & " $aBounds[2] = " & $iW / $aBounds[2] & @CRLF) ConsoleWrite($iW & " $aBoundsNp[2] = " & $iW / $aBoundsNp[2] & @CRLF) ConsoleWrite($iH & " $aBoundsNp[3] = " & $iH / $aBoundsNp[3] & @CRLF) ;~ _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI) ;~ _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) $hMatrix = _GDIPlus_MatrixCreate() $iW = $iW - $stroke_size ;+ $stroke_size $iH = $iH - $stroke_size ConsoleWrite(" -$aBounds[0]+1*$stroke_size/72 = " & -$aBounds[0]+1*$stroke_size/72 & @CRLF) ConsoleWrite(" -1.8+1*$stroke_size/72 = " & -1.8+1*$stroke_size/72 & @CRLF) _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0]+2*$stroke_size/72, -$aBounds[1]+1*$stroke_size/72) ;Translate Matrix to the offset of the bounding rectangle ;~ _GDIPlus_MatrixTranslate($hMatrix, -1.59166666666667+0*($stroke_size/72), -$aBounds[1]+1*$stroke_size/72) ;Translate Matrix to the offset of the bounding rectangle ;~ _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path $aBoundsNp = _GDIPlus_PathGetWorldBounds($hPath,0,$hPen) ;Get bounding rectangle of the path with pen ConsoleWrite($aBoundsNp[0] & @CRLF) ConsoleWrite($aBoundsNp[1] & @CRLF) ConsoleWrite($aBoundsNp[2] & @CRLF) ConsoleWrite($aBoundsNp[3] & @CRLF) ;~ _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI) _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example if you change the line 
      _GDIPlus_PathAddString($hPath, "autoitForeverLollipop", $tLayout, $hFamily);, 0, $fSize, $hFormat) ;Add the outline of the string to the path with a smaller string
      _GDIPlus_PathAddString($hPath, "autoitFitted", $tLayout, $hFamily);, 0, $fSize, $hFormat) ;Add the outline of the string to the path the result is ok
      Can someone can help me?
      Thankyou
    • marcoauto
      By marcoauto
      Ciao,
      Is there a function to create a stroke text?
      I have found the solution to fill the text with a texture, to make a shadow and to make a text with glow , but I can't reproduce the stoke effect.)
      I have attached an example image of what I would like to reproduce
      I have tried to adapt this script of Malkey but with no result
      The Malkey script is this (I have edit some line) and the original post is here: 
       
      #include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> Global $nPI = 3.1415926535897932384626433832795 Global $ghGDIPDll $hWnd = GUICreate("GDI+ Example", 800, 150) $iGlow = 2; <== Amount of Glow min = 1 Max about 5 _GDIPlus_Startup() $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(800, 150, $hGraphicGUI) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) _GDIPlus_GraphicsClear($hGraphics, 0xff003000) ; Black-green background ;~ _GDIPlus_GraphicsClear($hGraphics, 0xffffffff) ; White Background _AntiAlias($hGraphics, 4) $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") $hFont = _GDIPlus_FontCreate($hFamily, 80) $hLayout = _GDIPlus_RectFCreate(0, 0, 800, 150) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hStringFormat, 1) For $i = 1 To 15 Step 3 $hBrush3 = _GDIPlus_BrushCreateSolid("0x" & hex($iGlow,2) & "00ff00"); <====== Glow (Transparency) For $x = 0 To 360 Step 3 DllStructSetData($hLayout, "Y", ((18 - $i)) * Sin($x * $nPI / 180)) DllStructSetData($hLayout, "X", ((18 - $i)) * Cos($x * $nPI / 180)) $hStringFormat = _GDIPlus_StringFormatCreate() _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush3) Next Next DllStructSetData($hLayout, "Y", 0) DllStructSetData($hLayout, "X", 0) $hStringFormat = _GDIPlus_StringFormatCreate() $hBrush3 = _GDIPlus_BrushCreateSolid("0xfF00FF00") _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush3) GUISetState() GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush3) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hGraphicGUI) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_Shutdown() Func _AntiAlias($hGraphics, $iMode) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias ;Func to redraw on PAINT MSG Func MY_PAINT($hWnd, $msg, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hWnd, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT Thank you very much,
      Marco

    • Blueman
      By Blueman
      Hey Guys,
      I am Struggling with a issue that i cannot seem to fix.
      I hope that you guys can help me with this.
      I have a GUI with some text attributes, for all i use the following code;
      $Label_ts_Header = GUICtrlCreateLabel("Manual Adress", 60, 10, 500, 50) GUICtrlSetBkColor($Label_ts_Header, $COLOR_WHITE) GUICtrlSetFont ($Label_ts_Header, 26, 800, 0, "Calibri") This is all working like it should, but when i activate the GUI on another pc the text size is bigger and the GUI size is somewhat smaller.
      The problem is that it isn't on all computers, i can't seem to find the problem,..
      If i make it fit on one pc it is to small on another or to big,..
      What am i doing wrong?
       
      Is there some kind of attribute that i need to add to the top of my script to normalize text sizes in the script?
       
      Thanks!
       
      EDIT: Found the problem guys, some computers has changed the text size to 125% // Can i force 100% for my GUI somehow ?
       
      EDIT2: Fixed it guys! // I used the Function Below to get the DPI Setting and used that to determine the text size (example below)
       
      Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, 0) Local $aResult #forcedef $__g_hGDIPDll, $ghGDIPDll $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) Local $iDPI = $aResult[2] Local $aresults[2] = [$iDPIDef / $iDPI, $iDPI / $iDPIDef] _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Return $aresults EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio  
      $Label_S2 = GUICtrlCreateLabel("Data from The Base", 10, 300, 400, 20) GUICtrlSetBkColor($Label_S2, $COLOR_WHITE) GUICtrlSetFont ($Label_S2, 13 * _GDIPlus_GraphicsGetDPIRatio()[0])