Leaderboard
Popular Content
Showing content with the highest reputation on 10/08/2017 in all areas
-
Hi! I wrote an UDF that can simplify the way you can control Telegram Bot with AutoIt. If you don't know what is a Telegram Bot, maybe you should read their official website here. All about this UDF is on my GitHub: what is, how it work, how to use and also a Test.au3 to see the script in action. But... let's talk about this UDF. What is: It's an UDF that contain functions to control a Telegram Bot. Send messages, photo, video, stickers, wait for incoming messages and answer to them. How it works: Insert you Token given from BotFather, initialize your bot with _InitBot() function and... you're ready! All functions are commented: You will find a description of what it does, an explanation for every argument that function has need and what it return. This is the test script, that initialize your bot, run all functions and write the return value. #include "Telegram UDF.au3" $ChatID = "Your_Chat_ID_For_Test" _InitBot("Bot_ID","Bot_Token") ConsoleWrite("Test _GetUpdates -> " & @TAB & _GetUpdates() & @CRLF) ConsoleWrite("Test _GetMe -> " & @TAB & _GetMe() & @CRLF) ConsoleWrite("Test _SendMsg -> " & @TAB & _SendMsg($ChatID,"Test _SendMsg") & @CRLF) ConsoleWrite("Test _ForwardMsg -> " & @TAB & _ForwardMsg($ChatID,$ChatID,'MsgID') & @CRLF) ConsoleWrite("Test _SendPhoto -> " & @TAB & _SendPhoto($ChatID,"C:\image.jpg","Test _SendPhoto") & @CRLF) ConsoleWrite("Test _SendVideo -> " & @TAB & _SendVideo($ChatID,"C:\video.mp4","Test _SendVideo") & @CRLF) ConsoleWrite("Test _SendAudio -> " & @TAB & _SendAudio($ChatID,"C:\audio.mp3","Test _SendAudio") & @CRLF) ConsoleWrite("Test _SendDocument -> " & @TAB & _SendDocument($ChatID,"C:\document.txt","Test _SendDocument") & @CRLF) ConsoleWrite("Test _SendVoice -> " & @TAB & _SendVoice($ChatID,"C:\voice.ogg","Test _SendVoice") & @CRLF) ConsoleWrite("Test _SendSticker -> " & @TAB & _SendSticker($ChatID,"C:\sticker.webp") & @CRLF) ConsoleWrite("Test _SendLocation -> " & @TAB & _SendLocation($ChatID,"74.808889","-42.275391") & @CRLF) ConsoleWrite("Test _SendContact -> " & @TAB & _SendContact($ChatID,"0123456789","Josh") & @CRLF) ConsoleWrite("Test _SendChatAction -> " & @TAB & _SendChatAction($ChatID,"typing") & @CRLF) ConsoleWrite("Test _GetUserProfilePhotos -> " & @TAB & _GetUserProfilePhotos($ChatID) & @CRLF) ConsoleWrite("Test _GetChat -> " & @TAB & _GetChat($ChatID) & @CRLF) While 1 $msgData = _Polling() _SendMsg($msgData[2],$msgData[3]) WEnd Last part of the script (While cycle) use Polling function to put the script in a wait-state for incoming messages: _Polling() function return an array ($msgData in this case) that contain information about the received message (for example, $msgData[2] is the Chat ID of the user that send the message, important to send a reply. See GitHub page for other info. So, finally, here you can find and download the library -> https://github.com/xLinkOut/telegram-udf-autoit <- UPDATE: Thanks to @mLipok to added my Telegram UDF on AutoItScript Wiki! UPDATE 2: Functions that send files to Telegram Servers (photos, videos..) don't need anymore cURL executable file. Thanks to @Jos that suggested how to use WinHttp UDF by trancexx. If you have question, bug report or anything else just contact me or reply to this Thread Don't forget to follow me on GitHub for future updates. Bye!1 point
-
Maybe this ? $testSTring="www.google.com" & @crlf $testSTring&="http:\\google.com" & @crlf $testSTring&="https:\\www.google.com" & @crlf $testSTring&=" " & @crlf $testSTring&="www.github.com" & @crlf $testSTring&="telegraaf.nl" & @crlf $testSTring&="hardwareinfo.nl" & @crlf $testSTring&="www.github.com" & @crlf $testSTring&=@crlf consolewrite($testSTring) consolewrite("===========" & @CRLF) $newString=stringregexpreplace($testString,"(?m)^(?!\h*http)(?=\S+)", "http:\\\\" ) consolewrite($newString)1 point
-
this will come close. You have to tweak the urls that starts with h but as i do not know your data (maybe all start with www) $testSTring="www.google.com" & @crlf $testSTring=$testSTring & "http:\\google.com" & @crlf $testSTring=$testSTring & "https:\\www.google.com" & @crlf $testSTring=$testSTring & "www.github.com" & @crlf $testSTring=$testSTring & "telegraaf.nl" & @crlf $testSTring=$testSTring & "hardwareinfo.nl" & @crlf $testSTring=$testSTring & "www.github.com" & @crlf consolewrite($testSTring) $testSTring=@crlf&$testString consolewrite("===========" & @CRLF) $newString=stringregexpreplace($testString,"\r\n([^h])",@CRLF & "http:\\\1" ) $newstring=stringmid($newstring,3) consolewrite($newString)1 point
-
cyxstudio, GUICtrlRead only reads the selected item in a List control (look in the Help file to check) - and your For loop syntax is wrong. This is how you might do it: #include <GUIConstantsEx.au3> #include <GuiListBox.au3> GUICreate("Hello World", 200, 200) GUISetState(@SW_SHOW) $List = GUICtrlCreateList("", 0, 0, 200, 200) GUICtrlSetData($List, "1") GUICtrlSetData($List, "2") GUICtrlSetData($List, "3") GUICtrlSetData($List, "4") For $iIndex = 0 to _GUICtrlListBox_GetCount($List) - 1 ; Index starts at 0 so we need to reduce by 1 MsgBox("", "", _GUICtrlListBox_GetText($List, $iIndex)) Next M231 point
-
Chimp, The functions are mainly intended for large amounts of data with a large number of rows, where it's reasonable to use as much code and virtual listviews. I've added a new paragraph to top of first post to stress this. In a virtual listview with many rows and maybe also custom draw code to add column colors you'll get a huge amount of WM_NOTIFY messages. You can get 1000 messages per second. This means that you have to be very careful about the performance of the code. You cannot add a lot of Case or If statements to implement more functionality. Because the purpose of these functions is large amounts of data with 10,000 rows or more where row numbers are important, and because of performance considerations, I don't think I'll add an option to remove the row number column. The performance considerations is also the main reason why I've omitted some of the original features. Embeddable GUI control A main purpose of these functions is testing and debugging large arrays and CSV files in an easy and fast way, and also to display large arrays and CSV files for end users in an easy and fast way. Using the functions as an embeddable GUI control seems to be more cumbersome and time consuming. Sorry, but I don't think I'll add the code. Regards Lars.1 point
-
youtuber, Roughly following your logic... #include <array.au3> #include <file.au3> ; open the output file Global $File_to_written = @ScriptDir & "\replace.txt" Local $FileOpen = FileOpen($File_to_written, 2) If $FileOpen = -1 Then Exit MsgBox(17, 'ERROR', 'File open failed for output file') ; read the input file Local $ReadString = FileRead(@ScriptDir & '\dummy_urls.txt') Local $aURLS = StringSplit($ReadString, @CRLF, 3) For $1 = 0 To UBound($aURLS) - 1 If StringLeft($aURLS[$1], 3) = 'www' Then $aURLS[$1] = 'http://' & $aURLS[$1] Next _FileWriteFromArray($FileOpen, $aURLS) FileClose($FileOpen) ShellExecute($File_to_written) file used for testing... dummy_urls.txt kylomas1 point
-
@hemichallenger In order to get this running you need to use the .NET CLR.au3 Udf from here : Like this : #AutoIt3Wrapper_UseX64=y #include "..\Includes\CLR.Au3" #include <FileConstants.au3> ; ***************************************************** ; PARAMETERS : (Output mode ) ; OUTPUT : 0 = Console, 1 = GRID, 2 = Printer, 3 = File, , 4 = Null ; ***************************************************** _Run_PSHost_Script('Get-Process -ComputerName "." | select -Property * | where name -like Name* ',3) Func _Run_PSHost_Script($PSScript, $iOutput = 0) Local $oAssembly = _CLR_LoadLibrary("System.Management.Automation") ConsoleWrite("!$oAssembly: " & IsObj($oAssembly) & @CRLF) ; Create Object Local $pAssemblyType = 0 $oAssembly.GetType_2("System.Management.Automation.PowerShell", $pAssemblyType) ConsoleWrite("$pAssemblyType = " & Ptr($pAssemblyType) & @CRLF) Local $oActivatorType = ObjCreateInterface($pAssemblyType, $sIID_IType, $sTag_IType) ConsoleWrite("IsObj( $oAssemblyType ) = " & IsObj($oActivatorType) & @TAB & @CRLF) ; Create Object Local $pObjectPS = 0 $oActivatorType.InvokeMember_3("Create", 0x158, 0, 0, 0, $pObjectPS) ConsoleWrite("IsObject: " & IsObj($pObjectPS) & @TAB & "$pObject: " & ObjName($pObjectPS) & @CRLF) ; <<<<<<<<<<<<<<<<<<< PS COMMAND HERE >>>>>>>>>>>>>>>>>>>> $pObjectPS.AddScript($PSScript) ; Add Script here ; <<<<<<<<<<<<<<<<<<< Output >>>>>>>>>>>>>>>>>>>> Switch $iOutput Case 0 ;~ $pObjectPS.AddCommand("Out-Host") ;~ $pObjectPS.AddCommand("Out-String") ;~ $pObjectPS.AddCommand("Write-Host") Msgbox(16,"Error","This Output method '0' is not working yet :-( " & @CRLF & "choose another one") Exit Case 1 $pObjectPS.AddCommand("Out-GridView") Case 2 $pObjectPS.AddCommand("Out-Printer") Case 3 $pObjectPS.AddCommand("Out-File") $sFile = @DesktopDir & "\PShost.txt" ConsoleWrite("> " & $sFile & @CRLF) $pObjectPS.AddArgument($sFile) Case 4 $pObjectPS.AddCommand("Out-Null") Case Else MsgBox(0,"PSHost","Wrong Output Choice ?") EndSwitch $objAsync = $pObjectPS.BeginInvoke() ConsoleWrite("$objAsync " & IsObj($objAsync & @TAB & "$pObject: " & ObjName($objAsync) ) & @CRLF) While $objAsync.IsCompleted = False ;~ ConsoleWrite($objAsync.IsCompleted & @CRLF) ContinueLoop WEnd $objPsCollection = $pObjectPS.EndInvoke($objAsync) Switch $iOutput Case 0 ;~ ConsoleWrite( $objPsCollection & @CRLF) MsgBox(16,"PSHost","Output To Console is not working yet :-( ?" & @CRLF & @CRLF & " Best make a different OUTPUT option.") Case 1 Sleep(10000) ;~ WinWaitClose("") Case 3 MsgBox(0,"PSHost","File Output Ready on Desktop.") EndSwitch EndFunc Enjoy!1 point
-
Basic Notepad Program
autoautoauto reacted to Skeletor for a topic
Hi Guys, When I used to scratch the surface with Delphi5, I could only create a simple Notepad program. Now that I'm into AutoIt, I've created just a bare bone Notepad. Can be improved, but maybe this will be useful for those, like me, starting out with programming. I know there are way better notepads out there like Aupad, but, #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <APIDlgConstants.au3> #include <Memory.au3> #include <WinAPIDlg.au3> #include <WinAPIFiles.au3> Opt('WinTitleMatchMode', 3) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Notepad", 620, 440, 192, 124) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem4 = GUICtrlCreateMenuItem("New" & @TAB & "Ctrl+N", $MenuItem1) $MenuItem5 = GUICtrlCreateMenuItem("Open" & @TAB & "Ctrl+O", $MenuItem1) $MenuItem6 = GUICtrlCreateMenuItem("Save" & @TAB & "Ctrl+S", $MenuItem1) $MenuItem17 = GUICtrlCreateMenuItem("Print" & @TAB & "Ctrl+P", $MenuItem1) $MenuItem7 = GUICtrlCreateMenuItem("Exit" & @TAB & "Ctrl+W", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Edit") $MenuItem8 = GUICtrlCreateMenuItem("Undo" & @TAB & "Ctrl+Z", $MenuItem2) $MenuItem9 = GUICtrlCreateMenuItem("Cut" & @TAB & "Ctrl+X", $MenuItem2) $MenuItem10 = GUICtrlCreateMenuItem("Copy" & @TAB & "Ctrl+C", $MenuItem2) $MenuItem11 = GUICtrlCreateMenuItem("Paste" & @TAB & "Ctrl+V", $MenuItem2) $MenuItem12 = GUICtrlCreateMenuItem("Delete" & @TAB & "Del", $MenuItem2) $MenuItem16 = GUICtrlCreateMenu("Format") $MenuItem19 = GUICtrlCreateMenuItem("Word Wrap", $MenuItem16) $MenuItem18 = GUICtrlCreateMenuItem("Font", $MenuItem16) $MenuItem15 = GUICtrlCreateMenu("View") $MenuItem20 = GUICtrlCreateMenuItem("Status Bar", $MenuItem15) $MenuItem3 = GUICtrlCreateMenu("Help") $MenuItem13 = GUICtrlCreateMenuItem("View Help", $MenuItem3) $MenuItem14 = GUICtrlCreateMenuItem("About Notepad" & @TAB & "F1", $MenuItem3) $Edit1 = GUICtrlCreateEdit("", 0, 0, 620, 420, $ES_WANTRETURN) GUICtrlSetFont($Edit1, 10, 400, -1, "Lucida Console") GUICtrlSetData(-1, "") Dim $Form1_AccelTable[11][2] = [["^n", $MenuItem4], ["^o", $MenuItem5], ["^s", $MenuItem6], ["^p", $MenuItem17], ["^w", $MenuItem7], ["^z", $MenuItem8], ["^x", $MenuItem9], ["^c", $MenuItem10], ["^v", $MenuItem11], ["{DEL}", $MenuItem12], ["{F1}", $MenuItem14]] GUISetAccelerators($Form1_AccelTable) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Warning If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52, "Notepad Closing", "Are you sure you want to exit?") Select Case $iMsgBoxAnswer = 6 ;Yes Exit Case $iMsgBoxAnswer = 7 ;No EndSelect #EndRegion --- CodeWizard generated code Start --- Case $MenuItem4 GUICtrlSetData($Edit1, "") Case $MenuItem5 FileOpenDialog("Open Text File", @DesktopDir, "Text File (*.txt)") Case $MenuItem6 $filesave = FileSaveDialog("Save Text File", @DesktopDir, "Text File (*.txt)") $Edit1_Read = GUICtrlRead($Edit1) FileWrite($filesave, $Edit1_Read) Case $MenuItem7 #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Warning If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52, "Notepad Closing", "Are you sure you want to exit?") Select Case $iMsgBoxAnswer = 6 ;Yes Exit Case $iMsgBoxAnswer = 7 ;No EndSelect #EndRegion --- CodeWizard generated code Start --- EndSwitch WEnd If you don't attempt something, you never know you can actually achieve that goal.1 point -
Nice! But remember not to go wild!1 point
-
But now that he has brought up this topic, I would like to air my view. Most of us have indeed crafted pretty much most of the same scripts offered up here. And I am keen to encourage people with their programming. I would suggest though, that one needs to look at the sense of cluttering up the forum with simple things that are useful to be sure, and certainly have a place in our toolbox, but perhaps should be left for others to learn from scratch. If all of us were to upload these type of programs (and many do), we would be using up space here unnecessarily with repetitive stuff (which happens). If you craft such a thing, but add a handy twist, then that is different and certainly acceptable, and probably even desirable. Otherwise, I would task people to think logically before uploading their really simple stuff ... perhaps do a search of the forum first, to see if something very much the same is already available. That and the Help file. I would also suggest, that the forum and AutoIt have been around long enough, for all the simple basic stuff to have already seen the light of day. I quite realize, that people get very enthusiastic with their programs, especially the first ones, and the urge to show how clever you are, can be strong. I just suggest you temper that urge with sense. Whatever you do though, don't let my statements here, curb your enthusiasm for programming.1 point
-
Ever want to use notepad to run or compile autoit scripts? Well, a while ago I saw a post where Melba23 posted a script that added a menu entry to notepad and it was even able to detect what buttons you clicked and when I saw that I just HAD TO DO THIS. Whenever you use a tool, the wrapper script for notepad will even save the file that's open for you when you run any tool and if a file is modified by tidy, the script will also reload the script into notepad. The Script uses NomadMemory.au3 to get the file that's open in notepad, what I'm not so sure about is if the memory address range is different on different systems like vitsa or windows 7, I've only tested this on windows XP x86. NotePadWrapper.rar1 point