Jump to content
caramen

[Solved]Auto text

Recommended Posts

caramen

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
caramen

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
caramen

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
caramen

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
caramen

Solution : 

 

Thx x)

Share this post


Link to post
Share on other sites
AutoBert

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
caramen

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
caramen

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
AutoBert

@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
caramen

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
AutoBert

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
caramen

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
caramen

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
Jos
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                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
caramen

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
Melba23

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
caramen

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
caramen

@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
caramen

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
Synapsee

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

 

  • Like 1

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

    • reida
      By reida
      Hello. On page there is mail address. How to keep in a text file this address? 
      It is page and email
      https://alpari.com/
      info@alpari.com
    • caramen
      By caramen
      Hey.  
       
      I requested help about how to get a value from a text in a variable. 
      Now i know how to do that. But i learned with the command FileRead. Now i whould like to know how to replace the command :
      FileRead('Dossier.txt') The purpose is to read a webpage text. To find some value inside. 
       
      Btw i tryed to play with WindowsInfo.au3 but i dont got much thing.  
    • therks
      By therks
      I'm trying to create a simple clock widget that automatically scales the text to the size of the window. I came up with the following method, but it doesn't work as well as I'd like. It especially has trouble scaling to the width of the window for some reason (in the example, try resizing the window to be narrow and tall).
      Does anyone have a better method?
      #include <Misc.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $_FONT_FAMILY = 'Arial', $_LB_TEXT Main() Func Main() _GDIPlus_Startup() Local $hGUI GUIRegisterMsg($WM_SIZE, WM_SIZE) $hGUI = GUICreate('', 300, 100, Default, Default, $WS_OVERLAPPEDWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $_LB_TEXT = GUICtrlCreateLabel('This is a string', 0, 0, 300, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont($_LB_TEXT, _MeasureString($hGUI, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) GUISetState() Local $iGM While 1 $iGM = GUIGetMsg() Switch $iGM Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) GUICtrlSetFont($_LB_TEXT, _MeasureString($hWnd, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) EndFunc Func _MeasureString($hWnd, $sString, $sFont = 'Arial') Local $iError, $aSize, $hGraphic, $hFormat, $hFamily, $tLayout, $iFontSize, $hFont, $aInfo If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf $aSize = WinGetClientSize($hWnd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate($sFont) $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[0], $aSize[1]) $iFontSize = 0 Do If Not $hFamily Then $iError = 1 $iFontSize = 10 ExitLoop EndIf $iFontSize += 1 $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) If $aInfo[1] = 0 Then ExitLoop Until DllStructGetData($aInfo[0], 3) >= $aSize[0] Or DllStructGetData($aInfo[0], 4) >= $aSize[1] $iFontSize -= 1 _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return SetError($iError, 0, $iFontSize) EndFunc
    • dadalt95
      By dadalt95
      Hi!
      I want to get the signal in this website:
      https://binary-signal.com/pt/chart/eurusd
      I have tried using _IEBodyReadText  and some _StringBetween. What happens is that the text are being update every tick and _IEBodyReadText doesn't.
      To perform the update I used  _IEAction($oIE, "refresh") but it's not good because the website block me after some time due too many requests..
      Is there any other way to get this text every tick?
      PS: The text I want to get is WAIT, CALL or PUT.
       
      Here is the code:
      global $oIE = _IECreate ('https://binary-signal.com/pt/chart/eurusd', 0, 1 , 1 , 0) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') ;MsgBox ( 0, "asf", $result[0]) $espera=StringInStr($result[0], "WAIT") $compra=StringInStr($result[0], "CALL") $venda=StringInStr($result[0], "PUT") ;MsgBox($MB_SYSTEMMODAL, "", $espera) $n=0 $c=0 Captar() Func Captar() ;_IENavigate($oIE, "https://binary-signal.com/pt/chart/eurusd") ;MsgBox($MB_SYSTEMMODAL, "", $n) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') If (Not $compra=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "COMPRE") $n=1 $c=$c+1 ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "VENDA") $c=$c+1 $n=1 ;_IEAction($oIE, "refresh") ;MsgBox($MB_SYSTEMMODAL, "", $n) Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() Else ;MsgBox("", "", "ESPERE") $n=0 Sleep(1000) ;_IEAction($oIE, "refresh") Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') Captar() EndIf EndFunc  
    • vin1
      By vin1
      i need a script that can replace words in text with other words from a words list
      it has to have 2 edit boxes input/output and a button "run"
      from word_list.txt it choses which word to replace with. words are separated with commas for multiple choice
       

       
       

       
       
      ; AutoIt GUI Example ; Created: 17/01/2005 - CyberSlug ; Modifed: 05/12/2011 - guinness ; Modifed: 09/06/2014 - mLipok #Region INCLUDE #include <AVIConstants.au3> #include <GuiConstantsEx.au3> #include <TreeViewConstants.au3> #EndRegion INCLUDE #Region GUI GUICreate("Sample GUI", 400, 420) GUISetIcon(@SystemDir & "\mspaint.exe", 0) #EndRegion GUI #Region EDIT GUICtrlCreateEdit(@CRLF & " Sample Edit Control", 10, 10, 380, 175) GUICtrlSetTip(-1, '#Region EDIT') #EndRegion EDIT #Region EDIT2 GUICtrlCreateEdit(@CRLF & " Sample Edit Control", 10, 185, 380, 175) GUICtrlSetTip(-1, '#Region EDIT') #EndRegion EDIT2 #Region BUTTON GUICtrlCreateButton("Sample Button", 10, 360, 100, 30) GUICtrlSetTip(-1, '#Region BUTTON') #EndRegion BUTTON #Region GUI MESSAGE LOOP GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() #EndRegion GUI MESSAGE LOOP  
×