Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/28/2015 in all areas

  1. TheDcoder, By a fluke - Local variables cannot exist outside of a function and are treated as Global even if not declared as such. What I should, of course, have posted was: #include <Array.au3> Local $aArray[1][3] Local $sInsert = "1|2|3" _Insert($aArray, $sInsert, 0) _ArrayDisplay($aArray, "", Default, 8) Func _Insert(ByRef $aTarget, $sSource, $iRow) _ArrayInsert($aTarget, $iRow, $sSource) _ArrayDelete($aTarget, $iRow + 1) EndFuncM23
    2 points
  2. There was a thread in general support forum the other day about possibility of compiled executable to verify binary integrity of itself when run. I can't find the topic now to link it, but meh never mind. Logical solution is to calculate checksum of the exe and save it somewhere. Later when the executable is run the checksum is calculated again and compared to the saved value. If they match, all is ok, and if they don't the exe was altered and verification fails. The obvious problem is how and where to store the hash value. Alternate data stream seems the simplest solution. That way the hash is bound to the exe only and the risks of unwanted manipulations are relatively low. The problem could be if the exe is saved and run from non-NTFS file systems. Another problem is that any read/write action on exe file usually ends up with ADS being deleted. The other solution is registry writing, but that bounds exe and hash to the system. For another system (or even user) the checking wouldn't be valid. Third solution is using some sort of ini file. But that means ini has to go everywhere exe goes, otherwise again the check wouldn't make sense. And it would be too simple for someone to manipulate data, to the level the check wouldn't make sense. So, this is kind of fourth option. CheckSumVerify2.a3x script below is include file that will calculate the hash of the executable on the first run, save it directly inside that executable using special technique and recheck the hash on every new run. If the new hash wouldn't match the saved one, the script will show message box saying that and further execution will be aborted. CheckSumVerify2.a3x Just to say that I haven't done any complicated tests to see if it would work in outer space, or even on all supported systems. However my guess is it should work. Don't UPX the compiled executables, because I'm calculating checksum of the image on disk and not the one in memory. Here's small example of usage: #include "CheckSumVerify2.a3x" If @Compiled Then MsgBox(64 + 262144, "Aha!", "This is an example exe that does nothing except showing this message." & @CRLF & @CRLF & _ "But if you change the binary of me I will show error message and won't allow further execution." & @CRLF & _ $cmdlineraw) Else MsgBox(64 + 262144, "Hey", "This is an example script that does nothing except showing this message." & @CRLF & @CRLF & _ "But if you compile me I will check binary integrity of the compiled executable every time its run.") EndIf If something wouldn't work, or if you have any questions - simply post here. I'll do my best to answer.
    1 point
  3. iamtheky

    2DArray --> Neo4j

    Hopefully this expands as I get to play more with Neo4j. Starting simple here is an example of mapping artists to the bands they are in (a not quite complete Puscifer visualization). ;2DArray TO Neo4j #include<array.au3> Local $aBandMaster[0] ; declare this array fo later Local $aArray[1][2] ; declare this array for right....now $aArray[0][0] = "name" ;Title of column 1, will also be the Property of the NODEs established by the elements in this column $aArray[0][1] = "is_member_of" ;Title of column 2, will also be the Relationship of the items in column 1 to those in column 2 $Property = $aArray[0][0] ; Using 0,0 as property $Relationship = $aArray[0][1] ; using 0,1 as relationship ;creating a 2D array with semicolon as the delimiter between the NAME (The Property) ; IS_MEMBER_OF (The Relationship) ;(The Relationship) for this example, is a comma delimited list of the bands that the person IS_MEMBER_OF _ArrayAdd($aArray , "Jeff;Puscifer,APC,EODM,TBM,CarinaRound,Filter" , 0 , ";") _ArrayAdd($aArray , "MJK;Puscifer,APC,Tool" , 0 , ";") _ArrayAdd($aArray , "MattMc;Puscifer,EODM,TBM" , 0 , ";") _ArrayAdd($aArray , "Carina;Puscifer,CarinaRound" , 0 , ";") _ArrayAdd($aArray , "MatMit;Puscifer" , 0 , ";") _ArrayAdd($aArray , "Paul;Puscifer,Ministry" , 0 , ";") _ArrayAdd($aArray , "Mahsa;Puscifer,Omniflux" , 0 , ";") ;~ _ArrayDisplay($aArray) ; Mira! it is the array we just created $sOutStr = "Create" & @LF ;sOutStr will be the running catchall for the command we eventually want to run in Neo4j For $i = 1 to ubound($aArray) - 1 $sOutStr &= "(" & $aArray[$i][0] & ":Person {" & $Property & ": '" & $aArray[$i][0] & "'})," & @LF ; as we are looping through, use column one to create NODES that are PERSONS (this is assumed unique, if not you should get on that) _ArrayAdd($aBandMaster , stringsplit($aArray[$i][1] , "," , 2)) ; also while looping split all the comma delimited strings in column 2 and make one big list of bands stored in $aBandMaster ;~ _ArrayDisplay($aBandMaster , "BandMaster") Next $aBands = _ArrayUnique($aBandMaster) ; unique that master list and now we have a nice list of all of the bands from everyones list ;~ _ArrayDisplay($aBands , "unique bands") For $k = 1 to $aBands[0] $sOutStr &= "(" & $aBands[$k] & ":Band {" & $Property & ": '" & $aBands[$k] & "'})," & @LF ;roll through that list once creating NODES, one for each BAND Next For $i = 1 to ubound($aArray) - 1 $aPersonalBands = stringsplit($aArray[$i][1] , "," , 2) ; second loop, only this time we are building relationships, so we are working only off of the comma separated list for each individual For $k = 0 to ubound($aPersonalBands) - 1 $sOutStr &= "(" & $aArray[$i][0] & ")-[:" & $Relationship & "]->(" & $aPersonalBands[$k] & ")," & @LF ;Since those NODES were created above, we know their names and can build RELATIONSHIPS Next Next consolewrite(stringtrimright($sOutstr , 2) & @LF) ; This should be able to copy/paste directly into Neo4j ; match n optional match (n)-[r]-() return n, r; ; you need to run this afterward in Neo4j for the visualization
    1 point
  4. Just a fast hack for next Thursday. Maybe too early but who cares... Source: ;coded by UEZ build 2016-01-08 ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "BassConstants.au3" #include "Bass.au3" _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iFrames = 0, $iShowFPS = 0, $fTimer, $bExit, $aAudio Global Const $iW = @DesktopWidth, $iH = @DesktopHeight, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Simple Firework by UEZ" Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $iMaxParticles = 51, $iFireworks = 10, $iParticleSize = 4 Global $iElements = 9, $aCoords[$iFireworks][$iElements + $iMaxParticles * 4 - 3] ;don't touch these values AutoItSetOption("GUIOnEventMode", 1) GDIPlus_SimpleFirework() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_SimpleFirework() $bExit = False $hGUI = GUICreate($sTitle & 0, $iW, $iH, 0, 0, $WS_POPUP) GUISetState(@SW_SHOW, $hGUI) WinSetTrans($hGUI, "", 0xF8) GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFFE0E0E0), _ $hBrush_Clr = _GDIPlus_BrushCreateSolid(0x70000000), _ $hBrush_Txt = _GDIPlus_BrushCreateSolid(0x10202020), $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xA0505050), _ $hFormat = _GDIPlus_StringFormatCreate(), $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily = _GDIPlus_FontFamilyCreate("Impact"), $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont = _GDIPlus_FontCreate($hFamily, $iH / 4.5), $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH), $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 150, 32) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $iX, $iY, $j = -2^32 + 1, $bAudio = True ;init sound _BASS_STARTUP() _BASS_Init(0, -1, 44100, 0, "") If @error Then $bAudio = False Local $aAudio[$iFireworks][2], $hAudio_Whoa, $hAudio_BgNoise For $iY = 0 To $iFireworks - 1 ;generated firework particles GenCoordinates($iY, $aCoords, 1.5, 3.5, 1, 5.5) If $bAudio Then $aAudio[$iY][0] = _BASS_StreamCreateFile(False, @ScriptDir & "\" & Random(1, 7, 1) & ".mp3", 0, 0, 0) $aAudio[$iY][1] = 0 EndIf Next $hAudio_Whoa = _BASS_StreamCreateFile(False, @ScriptDir & "\ApplauseWoah.mp3", 0, 0, 0) $hAudio_BgNoise = _BASS_StreamCreateFile(False, @ScriptDir & "\BgNoise.mp3", 0, 0, 0) _BASS_ChannelPlay($hAudio_BgNoise, True) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $iAlpha, $iCounterFX = 0, $iCounterParticles = 0 $fTimer = TimerInit() Do DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, _ "float", $iW, "float", $iH) ;erase canvas background _GDIPlus_GraphicsDrawStringEx($hCanvas, "Happy new year 2016", $hFont, $tLayout, $hFormat, $hBrush_Txt) ;draw background message text For $iY = 0 To $iFireworks - 1 ;calculate and draw firework particles If $aCoords[$iY][1] > $aCoords[$iY][4] Then ;draw rocket only until explosion $aCoords[$iY][0] += $aCoords[$iY][2] ;x vector $aCoords[$iY][1] -= Abs($aCoords[$iY][3] * 10) ;y vector should be in upper direction only _GDIPlus_BrushSetSolidColor($hBrush, 0x60909090) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", $aCoords[$iY][0], "float", $aCoords[$iY][1], "float", 2, "float", 2) $iCounterParticles += 1 For $iX = $iElements To UBound($aCoords, 2) - 5 Step 4 $aCoords[$iY][$iX] = $aCoords[$iY][0] ;copy x position $aCoords[$iY][$iX + 1] = $aCoords[$iY][1] ;copy y position Next Else For $iX = $iElements To UBound($aCoords, 2) - 5 Step 4 $aCoords[$iY][$iX] += $aCoords[$iY][$iX + 2] ;x coordinate $aCoords[$iY][$iX + 1] += $aCoords[$iY][$iX + 3] + $aCoords[$iY][8] ;y coordinate $aCoords[$iY][$iX + 2] *= 0.98 ;neg. accelaration of x vector $aCoords[$iY][$iX + 3] *= 0.98 ;neg. accelaration of y vector $iAlpha = $aCoords[$iY][6] > 0xFF ? 0xFF : $aCoords[$iY][6] Switch $aCoords[$iY][7] ;choose color mode Case 0 To 3 _GDIPlus_BrushSetSolidColor($hBrush, Int($iAlpha) * 0x1000000 + $aCoords[$iY][5]) Case Else Switch Mod($j, 3) Case 0 _GDIPlus_BrushSetSolidColor($hBrush, Int($iAlpha) * 0x1000000 + 0x10000 * Random(0xD0, 0xFF, 1) + 0x100 * Random(0xD0, 0xFF, 1) + Random(0xD0, 0xFF, 1)) Case Else _GDIPlus_BrushSetSolidColor($hBrush, Int($iAlpha) * 0x1000000 + 0x10000 * Random(0x40, 0xA0, 1) + 0x100 * Random(0x40, 0xA0, 1) + Random(0x40, 0xA0, 1)) EndSwitch $j += 1 EndSwitch ;draw only visible particles If BitAND($aCoords[$iY][$iX] > -1, $aCoords[$iY][$iX] < $iW, $aCoords[$iY][$iX + 1] > -1, $aCoords[$iY][$iX + 1] < $iH) Then DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hCanvas, "handle", $hBrush, _ "float", $aCoords[$iY][$iX], "float", $aCoords[$iY][$iX + 1], _ "float", $iParticleSize, "float", $iParticleSize) ;draw firework particles $iCounterParticles += 1 EndIf Next $aCoords[$iY][6] *= 0.933 ;decrease alpha channel $aCoords[$iY][8] *= 1.075 ;gravity accelaration (y axis) -> earth's gravitational force simulation If Not $aAudio[$iY][1] And $bAudio Then ;play audio fx _BASS_ChannelPlay($aAudio[$iY][0], False) $aAudio[$iY][1] = 1 $iCounterFX += 1 EndIf If $aCoords[$iY][6] < 0x08 Then ;reset firework elements $aAudio[$iY][1] = 0 GenCoordinates($iY, $aCoords) EndIf EndIf Next If $iCounterFX > 2 Then _BASS_ChannelPlay($hAudio_Whoa, False) EndIf _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS & @CRLF & "Particles: " & $iCounterParticles, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw background message text _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI $iCounterFX = 0 $iCounterParticles = 0 $iFPS += 1 $iFrames += 1 If $bExit Then ExitLoop Until Not Sleep(10) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_Txt) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC, $DC_obj) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) If $bAudio Then For $iY = 0 To $iFireworks - 1 _BASS_ChannelStop($aAudio[$iY][0]) Next _BASS_ChannelStop($hAudio_Whoa) _BASS_ChannelStop($hAudio_BgNoise) _BASS_Free() EndIf EndFunc ;==>GDIPlus_SimpleFirework Func GenCoordinates($iY, ByRef $aCoords, $fVXmin = 2.5, $fVXmax = 15.5, $fVYmin = 1.5, $fVYmax = 5.5) Local $aColors[7] = [0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF7514, 0xFFFFFF, 0x40E0D0] $aCoords[$iY][0] = $iWh ;x coordinate (x coordinate of starting point) $aCoords[$iY][1] = $iH ;y coordinate (y coordinate of starting point) $aCoords[$iY][2] = Random($fVXmin, $fVXmax) * (Random(0, 1, 1) = 0 ? -1 : 1) ;x vector (direction of rocket) $aCoords[$iY][3] = Random($fVYmin, $fVYmax) * (Random(0, 1, 1) = 0 ? -1 : 1) ;y vector (direction of rocket) $aCoords[$iY][4] = Random($iH * 0.15, $iH * 0.35) ;area of detonation ;~ $aCoords[$iY][5] = 0x10000 * Random(0x40, 0xE0, 1) + 0x100 * Random(0x40, 0xE0, 1) + Random(0x40, 0xE0, 1) ;random color $aCoords[$iY][5] = $aColors[Random(0, 6, 1)] ;random color $aCoords[$iY][6] = 0x250 ;alpha channel value $aCoords[$iY][7] = Random(0, 8, 1) ;value for color mode $aCoords[$iY][8] = 0.15 ;gravity accelaration (y axis) initial value Local $iX, $fSpeed, $fRadius, $iFX = Random(1, 20, 1), $e = Random(5, 25), $h = 0, $g = 360 / ($iMaxParticles - 1), _ $j = 360 / 10, $jj = $j, $k = Random(0.5, 1.5), $kk = Random(1, 3.5), $l = 0 For $iX = $iElements To UBound($aCoords, 2) - 5 Step +4 Switch $iFX Case 1 To 3 $fSpeed = Cos($g * $iFX * $e * $iX) * $e $fRadius = $fSpeed / 2 Case 4 To 6 $fSpeed = Sin($iX / 7.85) * $e ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 7 To 9 $fSpeed = Tan($iX / 2) + $e ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 10 To 12 $fSpeed = Cos($iX / 2.5) + $e ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 13 To 15 ;create circular effect $fSpeed = Random($e, $e + 0.333333) ;particle speed (explosion strength) $fRadius = $fSpeed / 2 Case 16 To 18 $fSpeed = $e $fRadius = $k $h = $jj $jj += $j If $jj > 360 Then $jj = $j - $l $k += $kk $l += Random(1, 15) EndIf Case Else $fSpeed = Random(5, 25) ;particle speed (explosion strength) $fRadius = $fSpeed / 2 EndSwitch $aCoords[$iY][$iX + 2] = ($fSpeed + Cos($h * $fRad) * $fRadius) - $fSpeed ;x vector particle speed $aCoords[$iY][$iX + 3] = ($fSpeed + Sin($h * $fRad) * $fRadius) - $fSpeed ;y vector particle speed $h += $g ;next angle Next EndFunc ;==>GenCoordinates Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS & " / Ø " & Round($iFrames / TimerDiff($fTimer) * 1000, 4) $iFPS = 0 EndFunc ;==>CalcFPS Sound FX and other files are in the archive only! Sounds best with earphones Speed: ~17 FPS on Intel Core i5 4300U @ 2.6 GHz CPU (1600x900). If it is too slow on your machine decrease the values for $iMaxParticles and $iFireworks. Download available in download section. Use e.g. 7-Zip to open archive. Happy new year...
    1 point
  5. JohnOne

    IE Download Unification

    Don't worry, many people have super secret websites they cannot divulge for all kinds of reasons. In fact a gentleman was here also from Brasil not long ago with almost the exact same question, and his own super secret web address.
    1 point
  6. iamtheky

    2DArray --> Neo4j

    i went the docker route for installing neo4j. I believe the latest docker installer comes with Kitematic, which essentially gives you a storefront to just spin up and down environments way easy.
    1 point
  7. FileWrite("xxx.txt", ";")
    1 point
  8. BrewManNH

    Chain functions

    Your WinExists might get stuck because there might be a dozen windows using that class open, then the code will wait until you close the program and not do anything else as long as it is still running.
    1 point
  9. ViciousXUSMC, Using my StringSize UDF (as I suggested) allows you to add spacer lines to get the text as near as possible to the centre of the label. I rewrote the questions file into INI format to make the whole thing easier: [Total] Total=1 [1] Q=Regarding the Tiburon MobileCom application, wich of the following is correct: 1=Users should log off and sign on at the start of each shift, listing all PCFR members assigned to that apparatus 2=Only the primary user should log off and sign on 3=As long as the system is up and running, users should not log off and sign back on 4=None of the above A=1Total is the total number of questions - each of which is divided into the question, 4 answers, and the index of the correct answer. Then you can do this: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <FileConstants.au3> #include <File.au3> #include "StringSize.au3" #include "String.au3" $sIniFile = "Question.txt" $iGUI_Width = 470 $iQuestion_Height = 148 $iAnswer_Height = 60+4 #Region ### START Koda GUI section ### Form=c:\users\it022565\desktop\random question\form1.kxf $Form1_1 = GUICreate("Question", 609, $iGUI_Width, 308, 317) GUISetBkColor(0x000000) $Label1 = GUICtrlCreateLabel("Random Question Of The Day", 184, 0, 243, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Label2 = GUICtrlCreateLabel("Question Body", 8, 32, 593, $iQuestion_Height, $SS_CENTER) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Label3Border = GUICtrlCreateLabel("", 5-2, 192-2, 600+4, $iAnswer_Height) GUICtrlSetBkColor(-1, 0x800000) $Label3 = GUICtrlCreateLabel("Label3", 5, 192, 600, 60, $SS_CENTER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Label4Border = GUICtrlCreateLabel("", 5-2, 258-2, 600+4, $iAnswer_Height) GUICtrlSetBkColor(-1, 0x800000) $Label4 = GUICtrlCreateLabel("Label4", 5, 258, 600, 60, $SS_CENTER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Label5Border = GUICtrlCreateLabel("", 5-2, 324-2, 600+4, $iAnswer_Height) GUICtrlSetBkColor(-1, 0x800000) $Label5 = GUICtrlCreateLabel("Label5", 5, 324, 600, 60, $SS_CENTER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $Label6Border = GUICtrlCreateLabel("", 5-2, 390-2, 600+4, $iAnswer_Height) GUICtrlSetBkColor(-1, 0x800000) $Label6 = GUICtrlCreateLabel("Label6", 5, 390, 600, 60, $SS_CENTER) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Select random question $iSelect = Random(1, IniRead($sIniFile, "Total", "Total", "Error"), 1) ; Read in each element of the question/answer, size it and set it in the label ; Question text Label width & height GUICtrlSetData($Label2, _SizeText(IniRead($sIniFile, $iSelect, "Q", "Error"), $iGUI_Width, $iQuestion_Height)) GUICtrlSetData($Label3, _SizeText(IniRead($sIniFile, $iSelect, "1", "Error"), $iGUI_Width, $iAnswer_Height)) GUICtrlSetData($Label4, _SizeText(IniRead($sIniFile, $iSelect, "2", "Error"), $iGUI_Width, $iAnswer_Height)) GUICtrlSetData($Label5, _SizeText(IniRead($sIniFile, $iSelect, "3", "Error"), $iGUI_Width, $iAnswer_Height)) GUICtrlSetData($Label6, _SizeText(IniRead($sIniFile, $iSelect, "4", "Error"), $iGUI_Width, $iAnswer_Height)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label3Border $vAnswer = 1 ExitLoop Case $Label4Border $vAnswer = 2 ExitLoop Case $Label5Border $vAnswer = 3 ExitLoop Case $Label6Border $vAnswer = 4 ExitLoop EndSwitch WEnd ; Check the result against the correct answer $sResult = ( ($vAnswer = IniRead($sIniFile, $iSelect, "A", "Error")) ? ("Correct") : ("Wrong") ) $Form1_2 = GUICreate("Answer", 609, 470, 308, 317) GUISetBkColor(0x000000) GUISwitch($Form1_2) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Question Body", 8, 32, 593, 148, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetFont(-1, 75, 800, 0, "MS Sans Serif") GUICtrlSetData(-1, $sResult) $Button1 = GUICtrlCreateButton("OK", 250, 300, 140, 70) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch WEnd Func _SizeText($sText, $iWidth, $iHeight) ; Size the text wrapping into the label $aSize = _StringSize($sText, 10, 800, 0, "MS Sans Serif", $iWidth - 20) ; Now add spacing lines if any are needed ahead of the text to get it near the centre of the label Return _StringRepeat(@CRLF, Int(($iHeight - $aSize[3]) / $aSize[1] / 2)) & $aSize[0] ; Internal working: ; - $iHeight - $aSize[3] is the space below the text ; - divide by line height to get number of blank lines below text ; - divide by 2 to get required space ABOVE text ; - Int makes sure space ABOVE text smaller than below ; - add required @CRLFs before text to "centre" it EndFuncI realise that is it is quite a rewrite, but it has the advantage of only needing the single file to hold all the questions, so I hope you feel it was worth it. I leave the errorchecking to you! M23
    1 point
  10. My way. #include <String.au3> Global $sMainString = "ASDLFJHASLDJHFKJAWEJQzCMXNZMDBlkhjaskdjfasIOJAOSDFJIOjalsdfiashdfiouhqwpoJAOWPIJASDLFJASDNlnasdfkjansdkjfnasdkKLJASDKLJFHASDKJFHASDlsajpofdsjhfaowsdefaoidsnLAZZSSzzSDFZKSJALKSDJFHALSDFHJK" ConsoleWrite("!Normal String" & @CRLF) ConsoleWrite($sMainString & @CRLF) ConsoleWrite("!Sorted String" & @CRLF) ConsoleWrite(_SortChars($sMainString) & @CRLF) Func _SortChars($sString) Local Const $sChars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" Local $sOutString = "" Local $sChar = "" For $i = 1 To StringLen($sChars) $sChar = StringMid($sChars, $i, 1) StringReplace($sString, $sChar, "", 0, 1) If @extended Then $sOutString &= _StringRepeat($sChar, @extended) EndIf Next Return $sOutString EndFunc ;==>_SortCharsSaludos
    1 point
  11. I made this for fun. Just a simple mod to a bubblesort. #include <Array.au3> Local $sString = "ASDLFJHASLDJHFKJAWEJQzCMXNZMDBlkhjaskdjfasIOJAOSDFJIOjalsdfiashdfiouhqwpoJAOWPIJASDLFJASDNlnasdfkjansdkjfnasdkKLJASDKLJFHASDKJFHASDlsajpofdsjhfaowsdefaoidsnLAZZSSzzSDFZKSJALKSDJFHALSDFHJK" ConsoleWrite("!Normal String" & @CRLF) ConsoleWrite($sString & @CRLF) ConsoleWrite("!New String" & @CRLF) ConsoleWrite(BubbleSortMod($sString) & @CRLF) Func BubbleSortMod($smyString) $bs_array=StringSplit($smyString,"",2) For $i = UBound($bs_array) - 1 To 1 Step -1 For $j = 2 To $i If asc($bs_array[$j - 1]) > asc($bs_array[$j]) Then $temp = $bs_array[$j - 1] $bs_array[$j - 1] = $bs_array[$j] $bs_array[$j] = $temp EndIf Next Next Return _ArrayToString($bs_array,"") EndFunc ;==>BubbleSort Saludos
    1 point
  12. Nice mikell ! Another way, probably slower... #Include <Array.au3> Local $res $string = "ASDLFJHASLDJHFKJAWEJQzCMXNZMDBlkhjaskdjfasIOJAOSDFJIOjalsdfiashdfiouhqwpoJAOWPIJASDLFJASDNlnasdfkjansdkjfnasdkKLJASDKLJFHASDKJFHASDlsajpofdsjhfaowsdefaoidsnLAZZSSzzSDFZKSJALKSDJFHALSDFHJK" MsgBox(0, "", _Sort($string) ) Func _Sort($txt)     $s = Execute("''" & StringRegExpReplace($txt, "(.)", "&';$1' & (StringIsUpper('$1') ? '' : '.')"))     $a = StringRegExp($s, ";(.\.?)", 3) _ArraySort($a) For $i = 0 to UBound($a) - 1 $res &= StringLeft($a[$i], 1) Next Return $res EndFunc Edit : Finally, Execute is not needed, this should suffice #Include <Array.au3> Local $res $string = "ASDLFJHASLDJHFKJAWEJQzCMXNZMDBlkhjaskdjfasIOJAOSDFJIOjalsdfiashdfiouhqwpoJAOWPIJASDLFJASDNlnasdfkjansdkjfnasdkKLJASDKLJFHASDKJFHASDlsajpofdsjhfaowsdefaoidsnLAZZSSzzSDFZKSJALKSDJFHALSDFHJK" MsgBox(0, "", _Sort($string) ) Func _Sort($txt) Local $s = StringRegExpReplace($txt, "[[:lower:]]\K", ".") Local $a = StringRegExp($s, "[[:lower:]]\.|.", 3) _ArraySort($a) For $i = 0 to UBound($a) - 1 $res &= StringLeft($a[$i], 1) Next Return $res EndFunc
    1 point
  13. This could be done to check also non word chars (or not) depending on whether you put a condition (or not) According to Santa's cogitations #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> $Form1 = GUICreate("Form1", 1156, 123, 254, 124) $Input1 = GUICtrlCreateInput("", 8, 48, 1137, 21) $Go = GUICtrlCreateButton("Go", 8, 80, 113, 25) $Label1 = GUICtrlCreateLabel("Enter a string of characters and click go. This program will order the characters like AaBbCc etc.", 8, 24, 456, 17) GUISetState() GuiCtrlSetData($Input1, _ "DKJFHASDlsajpofdsjhfaowsdefaoidsnLAZZSSzzSDFZKSJAL, StringInStr($StringTemp,Chr($AsciiValue),1);" ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Go Msgbox(0,"", _Sort(GUICtrlRead($Input1)) ) EndSwitch WEnd Func _Sort($txt) Local $a = StringSplit($txt, ""), $res _ArrayColInsert($a, 1) For $i = 1 to $a[0][0] $n = Asc(StringLower($a[$i][0])) $a[$i][1] = (StringIsUpper($a[$i][0])) ? $n-0.5 : $n Next _ArraySort($a, 0, 1, 0, 1) ; _ArrayDisplay($a) For $i = 1 to $a[0][0] If StringIsAlpha($a[$i][0]) Then $res &= $a[$i][0] ; condition here Next Return $res EndFunc
    1 point
  14. Made some small modifications and added source code comments.
    1 point
  15. TheSaint

    Restart Programm

    This is the basic idea I was mentioning. Global $check, $vshost $vshost = @WindowsDir & "\vshost.exe" AdlibRegister("MyAdLibFunc", 250) Run($vshost) $check = 1 Func MyAdLibFunc() If $check = 1 Then If Not ProcessExists("vshost.exe") Then Run($vshost) EndIf EndIf EndFunc ;==>MyAdLibFunc You can adjust that 250 milliseconds to what you want. Basically the "MyAdLibFunc" function will be called repeatedly every 250 milliseconds or until you close your GUI or click STOP. $vshost is obviously just an example of a path. You can use a button in your GUI to both Run the program you want to watch, plus set $check = 1 You can also add in a window check too if you want, with WinExists etc. You could also add a STOP button, to set AdlibUnRegister( "MyAdLibFunc") or just have that run when your GUI closes. EDIT Strictly speaking, you don't really need to use $check = 1, but that can provide greater flexibility if you need it (i.e. you could use START and STOP monitoring buttons). Even with that, you could just enable and disable the Adlib function at need and not use the $check flag. It all depends on what else you might be doing.
    1 point
  16. in your listing you are mixing 2D and 1D arrays...? in line 2 you are using a 2d array (with just 1 row) and you can populate it like this: Local $aArray[1][3] = [[1,2,3]] if it were with 2 rows you should populate like this: Local $aArray[2][3] = [[1,2,3],[4,5,6]] while in line 9 you are declaring an 1d array, the syntax is ok, but since you are declaring a variable, you have to add the "Local" or "Global" statement. Also you should use the right number for the wanted elements [3] Local $aArray[3] = [1, 2, 3]
    1 point
  17. Gianni

    Snowfall

    it's snowing.... #include <WindowsConstants.au3> #include <WINAPI.au3> Local $isnowflakes = 500 ; number of snowflakes Local $iMinR = 5 ; minimum length of the snowflake's side Local $iMaxR = 8 ; max length Local $aSnow[$isnowflakes][5] Local $AlphaKey = 0xABABAB, $hBackground = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW, $WS_EX_LAYERED + $WS_EX_TOPMOST) GUISetBkColor($AlphaKey, $hBackground) _WinAPI_SetLayeredWindowAttributes($hBackground, $AlphaKey, 0, $LWA_COLORKEY) GUISetState(@SW_SHOW, $hBackground) For $i = 0 To UBound($aSnow) - 1 _Randomize($aSnow, $i, $iMinR, $iMaxR) $aSnow[$i][3] = GUICtrlCreateLabel("", $aSnow[$i][1], $aSnow[$i][2], $aSnow[$i][0], $aSnow[$i][0]) GUICtrlSetBkColor(-1, 16777215) ; snow white Next While 1 For $i = 0 To UBound($aSnow) - 1 $aSnow[$i][2] += $aSnow[$i][4] ; increment y pos GUICtrlSetPos($aSnow[$i][3], $aSnow[$i][1], $aSnow[$i][2]) If $aSnow[$i][2] > @DesktopHeight Then _Randomize($aSnow, $i, $iMinR, $iMaxR) GUICtrlSetPos($aSnow[$i][3], $aSnow[$i][1], $aSnow[$i][2], $aSnow[$i][0], $aSnow[$i][0]) EndIf Next WEnd Func _Randomize(ByRef $aSnow, $i, $iMinR, $iMaxR) $aSnow[$i][0] = Random($iMinR, $iMaxR, 0) ; dimension of snow $aSnow[$i][1] = Random(0 - $iMaxR, @DesktopWidth + $iMaxR, 0) ; x position $aSnow[$i][2] = 0 - $iMaxR ; y position (out of screen at startup) $aSnow[$i][4] = Random(0.1, $iMaxR * 3) EndFunc ;==>_Randomize
    1 point
  18. trancexx

    Bitmap2AscII

    It's written in VScript. That's my version of AutoIt. It has pretty much the same syntax as AutoIt, but has true compiler. It's what I wanted to do with AutoIt while being active in development. Anyway, not to repeat myself, some limited fuckers had different ideas. Oh, and Jon doesn't want me to talk about my work on AutoIt on the forums, so that's about all the info I'm willing to share. Not all codecs support frame count format, particularly those that handle streaming video formats, because streaming is done in time intervals, and not in frames. I can explain the algo if you want, the code can obviously be written in AutoIt. We are going off-topic here, so create new thread somewhere if you want to go further. No PMs please.
    1 point
  19. OverloadUT

    HTTP UDF's

    I am working on a fairly large project and a big part of it is an AutoIt application that uploads a lot of data to a PHP script. For a while I was using INetGet and submitting all my data as GET variables in the URL. However, the amount of data to upload got too big (over 1000 characters) and the INetGet function started to fail. I also hated that INetGet ONLY works if the webserver responds with "200 OK" - There is no way to tell the difference between a 404 error and simply not being able to connect to the server in the first place. So I write this library of UDF's. Basically, it's a fully compliant HTTP/1.1 client. It uses only the TCP functions; no DllCall needed here! I had a blast learning all about the HTTP protocol and how to use it. Advantages over INetGet: The data is downloaded right in to variables instead of to files. You can of course then write this data to a file if you wish. You can read all of the headers supplied by the webserver. You can get the HTTP Response Code from the webserver. When it failes, you know exactly what failed instead of having to guess. ; =================================================================== ; HTTP UDF's ; v0.5 ; ; By: Greg "Overload" Laabs ; Last Updated: 07-22-06 ; Tested with AutoIt Version 3.1.1.131 ; Extra requirements: Nothing! ; ; A set of functions that allow you to download webpages and submit ; POST requests. ; ; Main functions: ; _HTTPConnect - Connects to a webserver ; _HTTPGet - Submits a GET request to a webserver ; _HTTPPost - Submits a POST request to a webserver ; _HTTPRead - Reads the response from a webserver ; =================================================================== I consider this UDF package to be a "beta" and that's why I call it version 0.5. However, I would love people to give it a try and tell me how it works for them. I have done extensive testing and I think I have the parser working perfectly. I plan on improving this library. It's possible that I might change the way the functions work (I don't think the _HTTPConnect function is necessary; I could move that functionality right in to the Get or Post functions.) To Do: Add a function that downloads the data right to a file. You might not want to download a 10 meg file in to memory before saving it to a file.Add a method to get the progress of the download. This will probably be in the form of a callback function, if that's possible in AutoIt.Add the ability to automatically follow "Location:" headers. Currently you'd have to do it manually.Other things I can't think of!Post #25 For Updated functions to work with current AutoIt versions.
    1 point
  20. Had a bit of time, so converted some code I found into a dll. Original code is written by LARRY OSTERMAN http://blogs.msdn.com/b/larryosterman/ includes example $V7Voldll = "V7Vol.dll" $aDllCall = DllCall($V7Voldll, 'float', 'getvol') If @error Then Exit MsgBox(0,"Error",@error) EndIf MsgBox(0,"Result",Round($aDllCall[0],2) * 100)V7Vol.rar
    1 point
×
×
  • Create New...