caramen Posted May 31, 2016 Posted May 31, 2016 (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. expandcollapse popup#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 June 6, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted May 31, 2016 Author Posted May 31, 2016 i thougth about $windows = WinGetTitle("[active]") WinActivate (""&$windows) but where tu put the function WinGetTitle? My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted May 31, 2016 Author Posted May 31, 2016 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. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted June 1, 2016 Author Posted June 1, 2016 (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 ? Edited June 1, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted June 1, 2016 Author Posted June 1, 2016 Solution : Thx x) My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
AutoBert Posted June 1, 2016 Posted June 1, 2016 (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 June 1, 2016 by AutoBert
caramen Posted June 1, 2016 Author Posted June 1, 2016 (edited) I thougth about that and tryed with bad logic, include made me add 3 line of code x) it s better THx Edited June 1, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted June 1, 2016 Author Posted June 1, 2016 Now this is my problem : expandcollapse popup#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. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
AutoBert Posted June 1, 2016 Posted June 1, 2016 @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
caramen Posted June 1, 2016 Author Posted June 1, 2016 (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 June 1, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
AutoBert Posted June 1, 2016 Posted June 1, 2016 (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 THx Edited June 1, 2016 by AutoBert
caramen Posted June 1, 2016 Author Posted June 1, 2016 (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 June 1, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted June 1, 2016 Author Posted June 1, 2016 (edited) And trust me i canT afford an other warning so be sure i took attention about not breaking any rule .... Or maybe it s me mistaking ? In this case i am gonna retract any question and stop posting. Edited June 1, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Developers Jos Posted June 1, 2016 Developers Posted June 1, 2016 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. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
caramen Posted June 1, 2016 Author Posted June 1, 2016 When i say i cant afford i main : i must not have an other one. did i spelled whrong ? My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Moderators Melba23 Posted June 1, 2016 Moderators Posted June 1, 2016 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
caramen Posted June 2, 2016 Author Posted June 2, 2016 (edited) I am on the good way xD. Thanks melba i thougth i was mistaking again. Jos made me afraid a lot . 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. expandcollapse popup#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 June 2, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted June 3, 2016 Author Posted June 3, 2016 (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 June 3, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted June 6, 2016 Author Posted June 6, 2016 I am still working on this and trying. But failing :/ Reworked reproducer : expandcollapse popup#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 My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Synapsee Posted June 6, 2016 Posted June 6, 2016 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 : expandcollapse popup#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 caramen 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now