Leaderboard
Popular Content
Showing content with the highest reputation on 02/01/2021 in all areas
-
Help me to randomize simple algorithm
Earthshine and one other reacted to Melba23 for a topic
DesireDenied, You appear to be confusing "truly random" with what you perceive as "random". It is quite likely that successive numbers in a truly random sequence will be close neighbours - just look at any lottery draw. So trying to avoid such occurrences is in fact making the series less random, not more. M232 points -
Help me to randomize simple algorithm
DesireDenied and one other reacted to RTFC for a topic
This still produces the same sequence every time you run it. You need to use an external seed when calling SRandom, for example @AutoitPID or @MSEC (or a combination thereof) BEFORE ever calling Random.2 points -
WinMerge / Github / StackOverFlow / Track - AutoIt Syntax Highlighting
argumentum reacted to mLipok for a topic
For anyone interested: https://github.com/WinMerge/winmerge/releases/tag/v2.16.10 You can also take a look here: https://github.com/WinMerge/winmerge/issues/446 Download link: https://winmerge.org/downloads/?lang=en I wish you many benefits from this change. Keep calm and healthy. Regards, mLipok1 point -
Help me to randomize simple algorithm
DesireDenied reacted to Nine for a topic
Try this : #include <Constants.au3> #include <Array.au3> Const $MAX = 49 Local $aArray[$MAX] For $i = 1 to 500 GenerateNumber(20) Next _ArrayDisplay($aArray) Func GenerateNumber($iNum) SRandom(Int(@MSEC)) For $i = 1 to $iNum $aArray[Random(1,$MAX,1)-1] += 1 Next Sleep(Random(5,15,1)) EndFunc Looks to me quite random...1 point -
Help me to randomize simple algorithm
DesireDenied reacted to Nine for a topic
Help file says : Normally you should call it once for the whole sequence, not before each call to random1 point -
Help me to randomize simple algorithm
DesireDenied reacted to Danp2 for a topic
Have you tried calling SRandom?1 point -
TheSaint, Amended for the next release - thanks. M231 point
-
@Melba23 - Thanks for your UDF. Giving it the once over for the first time, to probably pinch most of it ... feeling too lazy to reinvent the wheel, especially when you have a done a much better job than I ever would. As it is I might need to seek medical attention after studying your code ... my poor simple brain. Anyway just noticed this little textual only error. _CFF_Check_Valid name used for the __CFF_Check_Selection function in the #INTERNAL_USE_ONLY# comments. EDIT And another - _CFF_Combo_Fill instead of __CFF_Fill_Combo1 point
-
But if you still want to have a single button "Cancel", here how you could do it with MsgBox : #include <WindowsConstants.au3> #include <Constants.au3> #include <SendMessage.au3> #include <WinAPIError.au3> $sCommand = " /AutoIt3ExecuteLine ""MsgBox(0, 'Shutdown'," & _ "'In accordance with company power saving policies, your computer will be shutdown in 1 minute.' & @CRLF & @CRLF & " & _ "'If you wish to abort this process, click the Cancel button below.', 60)""" ConsoleWrite ($sCommand & @CRLF) Run(@AutoItExe & $sCommand) $hWnd = WinWait("Shutdown") $hCtrl = ControlGetHandle($hWnd, "", "Button1") ConsoleWrite ($hWnd & "/" & $hCtrl & @CRLF) $tString = DllStructCreate("char text[7]") $tString.text = "Cancel" _SendMessageA($hCtrl, $WM_SETTEXT, 0, DllStructGetPtr($tString)) ConsoleWrite (_WinAPI_GetLastError() & @CRLF)1 point
-
Hey Guys, Searching multiple forum Topic's i realized that a timeout option isn't coming soon on this function. So i created a simple alternative for the InetRead Function. My function is first looking for the domain prefix by using the _URLSplit() Function from SmOke_N (Thanks! ) Then the function simply tries a InetGet on this domain withhout waiting for it, and starting a loop for Timeout. If InetGetInfo is receiving a Download Complete command the function is relaying the complete URL to the original InetRead() function, then returning the Data. For yours to use if needed, it is working perfectly here #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <array.au3> ; Read Website _InetRead("http://www.geenverbinding.nl/",1,2000) ; Show Msgbox before Ending Script. Msgbox(64,"","Finished") Func _InetRead($IR_URL,$IR_OPTIONS = 1,$IR_TIMEOUT = 2000) ; Define Var's Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) Local $ProcessCounter = 0 Local $ReadedOutput, $GetDomain $GetDomain = _URLSplit($IR_URL) If NOT IsArray($GetDomain) Then Return "" ; Start Connection to Server, Forced Reload. Local $hDownload = InetGet($GetDomain[1]&"://"&$GetDomain[2], $sFilePath, 1, 1) ; Start loop for Timeout Do Sleep(50) $ProcessCounter += 1 Until InetGetInfo($hDownload, 2) OR $ProcessCounter > ($IR_TIMEOUT/50) ; Close the handle returned by InetGet. InetClose($hDownload) ; Delete the file. FileDelete($sFilePath) If $ProcessCounter > ($IR_TIMEOUT/50) Then Return "" $ReadedOutput = InetRead($IR_URL,$IR_OPTIONS) Return $ReadedOutput EndFunc Func _URLSplit($szUrl) Local $sSREPattern = '^(?s)(?i)(http|ftp|https|file)://(.*?/|.*$)(.*/){0,}(.*)$' Local $aUrlSRE = StringRegExp($szUrl, $sSREPattern, 2) If Not IsArray($aUrlSRE) Or UBound($aUrlSRE) - 1 <> 4 Then Return SetError(1, 0, 0) If StringRight($aUrlSRE[2], 1) = '/' Then $aUrlSRE[2] = StringTrimRight($aUrlSRE[2], 1) $aUrlSRE[3] = '/' & $aUrlSRE[3] EndIf $szProtocol = $aUrlSRE[1] $szDomain = $aUrlSRE[2] $szPath = $aUrlSRE[3] $szFile = $aUrlSRE[4] Return $aUrlSRE EndFunc ;==>_URLSplit Just paste these Functions in your script, then simply add the Underscore to all your InetRead functions, enjoy! PS: Standard Timeout Setting is 2000 (Milliseconds), but you can change it to your needs.1 point
-
I know this is an older topic but maybe this will help someone who is searching for an answer. What I did is incorporate the Google Analytics Measurement Protocol and Trancexx's WinHttp functions. Here's a small function that I wrote that works very well for me. It pushes an event into my GA account. With Measure Protocol you can basically push anything into GA. Just remember with Measurement Protocol, your always going to get a 200 Response back. The best way to check to see if it worked is to go into your GA account and look in the Real Time stats under Events for this function and it will show there. It only takes a second or two to show up in GA if your doing it correctly. #include <WinHttp.au3> ;This will push 10 events into your GA account For $i = 1 To 10 _GA_Post("UA-xxxxxxxx-1","Autoit Test Event","Deleted",$i & " File.pdf") Sleep(1000) Next ;_GA_Post(Google Analytics Account ID, Event Catagory Label, Event Action Lable, Additional Lable(I used a file Name)) Func _GA_Post($GAID,$catagory,$action,$label) $payload = "v=1&t=event&tid="& $GAID &"&cid=e3057da6-19fa-474c-aeca-23ac17475b1a&ec="& $catagory &"&ea="& $action &"%20&el="& $label Local $gaOpen = _WinHttpOpen("Vspec Program/1.1 HTTP/5.1") Local $gaConnect = _WinHttpConnect($gaOpen, "www.google-analytics.com") Local $gaRequest = _WinHttpOpenRequest($gaConnect, "POST", "/collect") _WinHttpSendRequest($gaRequest, "Content-Type:application/x-www-form-urlencoded",$payload) _WinHttpReceiveResponse($gaRequest) $returned = _WinHttpReadData($gaRequest) ;Close handles _WinHttpCloseHandle($gaRequest) _WinHttpCloseHandle($gaConnect) _WinHttpCloseHandle($gaOpen) EndFuncYou really need to read up on the Parameter Reference for Measurement Protocol. The CID number in the Payload Variable is very important. https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters Also you can build your own hits using Google's Hit builder Tool https://ga-dev-tools.appspot.com/hit-builder/ HTH1 point
-
I'm going to use these menus. I've updated the UDF, ModernMenuRaw.au3. Of the posts it appears that Holger updated the code on a regular basis until May 2008. ProgAndy made some updates in August 2008. These updates were about the background color of the menubar, the ability to use icon handles, and better cleanup code on exit. The updates I've made are based on the UDF by ProgAndy attached to post 213. It's my intention to update the UDF to make it run under the current versions of AutoIt, and to get rid of errors. Especially already known errors, which can be fixed in a few lines of code. It's not my intention to add a lot of new code to the UDF. Updates 2014-10-18 This update is based on original code by Holger (first post) and updates by ProgAndy (posts 211 - 213). The update supports AutoIt 3.3.10 and later. Code relating to Windows versions not supported by 3.3.10 is deleted. WindowsConstants.au3 is included and double-defined global constants are commented out. Added an update to be able to use colored controls e.g. buttons with this UDF. Post 222. Update (one line) for x64 support. Post 266 by Holger. Added x64 support to functions by ProgAndy. Declared a few local variables. Updates 2014-10-19 Updates to pass Au3Check. (-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6) Updates 2015-01-24 Updates for tray menus suggested by nickston (posts 298, 299, 312) Most important is an update that makes it possible to use a flashing tray menu icon. There are also a few code optimizations. Updates 2021-11-12 Disabled $IDI_ global constants in ModernMenuRaw.au3. $IDI_ constants are included in AutoItConstants.au3. None of the updates above are script breaking. If you are using tray menus and want to compile your script, you should pay attention to posts 268 - 270. Note also that _TrayIconCreate creates a GUI to receive messages from tray icons. After calling this function you should probably use GUISwitch($hGui) or something. Post 227. In the top of ModernMenuRaw.au3 I've included commands.txt from the original zip by Holger. Two commands of ProgAndy to handle the background color of the menubar are added. I've also added an alphabetical list of functions, and a list of Windows messages (used with GUIRegisterMsg). Examples In order to make it easy the examples are included in the zip. The original examples by Holger are included with no changes at all. The 32 examples by AZJIO in the post above are also included with no changes. There are two versions of the examples: an english and a russian. The examples demonstrates the commands one by one and are named with the name of the command. Copied an example by AZJIO and renamed it to _TrayIconSetState-flashing.au3. Added one line of code to make the tray menu icon flash. Only an english version. A new example by nickston that demonstrates a flashing tray menu icon. The example shows how to turn flashing on and off. Two new examples _GUICtrlCreateODTopMenu.au3 and _GUIMenuBarSetBkColor.au3 that demonstrates the commands by ProgAndy to set the background color of the menubar. _GUIMenuBarSetBkColor.au3 is not working on Windows 7. A new example that shows how to use a bitmap from an image list as an icon in a menu item. The example shows also how to use icon handles. 7z-file ModernMenuRaw.au3 - update on 12.11.2021 ModernMenuRaw.au3 - all previous versions ExamplesAZJIO - 32 examples by AZJIO in english and russian versions ExamplesHolger - the original examples by Holger Examplesnickston - flashing tray menu icon ExampleszNew - three new examples Tested with AutoIt 3.3.10 on Windows 7 32/64 bit and Windows XP 32 bit. 2014-10-19: ModernMenuRaw.7z 2015-01-24: ModernMenuRaw.7z Tested with AutoIt 3.3.14.2/5 and beta 3.3.15.4 on Windows 7/10 32/64 bit. ModernMenuRaw.7z1 point
-
GUI/Tray Menu with icons and colors
pixelsearch reacted to AZJIO for a topic
32 example ModernMenuRaw_Examples.7z1 point -
Hi, You want to specify a reference/pointer to a struct as a parameter. So the type is struct*. Then just use the structure, autoit uses the pointer automatically for this type. #include <WinAPI.au3> Global Const $hDllBthProps = DllOpen("bthprops.cpl") Local $phRadio $hFind = _BluetoothFindFirstRadio($phRadio) MsgBox(0, "", "error: " & @error & @CRLF & "hFind: " & $hFind & @CRLF & "hRadio: " & $phRadio) _WinAPI_CloseHandle($phRadio) _BluetoothFindRadioClose($hFind) Func _BluetoothFindFirstRadio(ByRef $phRadio) $tBLUETOOTH_FIND_RADIO_PARAMS = DllStructCreate('DWORD') DllStructSetData($tBLUETOOTH_FIND_RADIO_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_FIND_RADIO_PARAMS)) $aResult = DllCall($hDllBthProps, "handle", "BluetoothFindFirstRadio", "struct*", $tBLUETOOTH_FIND_RADIO_PARAMS, "handle*", 0) If @error Then Return SetError(2, @error, 0) $phRadio = $aResult[2] Return SetError($aResult[0] = 0, 0, $aResult[0]) EndFunc Func _BluetoothFindRadioClose($hBtFind) Local $aResult = DllCall($hDllBthProps, "bool", "BluetoothFindRadioClose", "handle", $hBtFind) If @error Then Return SetError(2, @error, 0) Return SetError($aResult[0] = 0, 0, $aResult[0]) EndFunc1 point