Leaderboard
Popular Content
Showing content with the highest reputation on 03/14/2016 in all areas
-
TrayMenu problem
DickG reacted to InunoTaishou for a topic
Your Sleep function is causing you to not get the tray message when it's sent to your script. You'll have to use TrayOnEventMode or Call a function that does your sleep. Initialize a timer. While loop using your timer and the timeout you want. In the loop use your Switch (TrayGetMsg()). Here's for the TraySetOnEventMode #Region: Initialize Func Initialize() Local $ThisFunc = "Initialize" $Title = "Tray Test" $Version = "0.1" ;Prevent another instance. If _Singleton($Title, 1) = 0 Then ProcessClose($Title & ".exe") ;Set options. See Function Reference > Misc. Management > AutoIt Set Option in Help file for list Opt("GUICloseOnESC");1=ESC closes, 0=ESC will not close Opt("WinTitleMatchMode", 2);1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Opt("TrayMenuMode", 3);remove Exit and Script Paused tray menu items Opt("TrayOnEventMode", 1) Return EndFunc #EndRegion #Region: Loop Func Loop() Local $ThisFunc = "Loop" Local $i = "" Local $Exit_app, $Settings ;Create menu items. $Settings = TrayCreateItem("Set period", -1, -1, 0) TrayItemSetOnEvent($Settings, "Settings") $Exit_app = TrayCreateItem("Exit") TrayItemSetOnEvent($Exit_app, "Close") ;Set Tray tip. TraySetToolTip ("Event Log");sets tooltip TraySetState(1);show Tray icon TrayItemSetState(-1, $TRAY_ENABLE) MsgBox(0, $ThisFunc, "Starting loop.") While 1 $i += 1 If $i >= 5 Then ExitLoop MsgBox(0, $ThisFunc, "Count = " & $i) ;Repeat every 5 seconds. Sleep(5000) WEnd MsgBox(0, $ThisFunc, "Ended loop.") Exit Return EndFunc #EndRegion Func Settings() MsgBox("", "", "Set Period tray item clicked") EndFunc Func Close() Exit 0 EndFunc1 point -
You could use this concept to build the needed func $sFileread = "[Question1]" & @CRLF & @CRLF & _ "Name: Q" & @CRLF & @CRLF & _ "Salary: $40 hourly / Bi Weekly" & @CRLF & @CRLF & _ "Status: Single" & @CRLF & @CRLF & _ "Debt: $250,000" & @CRLF & @CRLF & @CRLF & _ "Question 1: Will Q manage to afford a million dollar house?" & @CRLF & @CRLF & _ "[/Question1]" & @CRLF & @CRLF & _ "[Answer1]" & @CRLF & @CRLF & _ "A1=No" & @CRLF & @CRLF & _ "A2=Yes" & @CRLF & @CRLF & _ "A3=None of the above" & @CRLF & @CRLF & _ "[/Answer1]" $var1 = "Question1" $res = StringStripWS(StringRegExp($sFileread, '\[' & $var1 & '\]\R+([^[]+)', 3)[0], 4) Msgbox(0, $var1, $res) $var2 = "Answer1" $res = StringStripWS(StringRegExp($sFileread, '\[' & $var2 & '\]\R+([^[]+)', 3)[0], 4) Msgbox(0, $var2, $res)1 point
-
You mean something like this here? $sFileread = "[Question1]" & @CRLF & @CRLF & _ "Name: Q" & @CRLF & @CRLF & _ "Salary: $40 hourly / Bi Weekly" & @CRLF & @CRLF & _ "Status: Single" & @CRLF & @CRLF & _ "Debt: $250,000" & @CRLF & @CRLF & @CRLF & _ "Question 1: Will Q manage to afford a million dollar house?" & @CRLF & @CRLF & _ "[/Question1]" & @CRLF & @CRLF & _ "[Answer1]" & @CRLF & @CRLF & _ "A1=No" & @CRLF & @CRLF & _ "A2=Yes" & @CRLF & @CRLF & _ "A3=None of the above" & @CRLF & @CRLF & _ "[/Answer1]" ConsoleWrite(StringRegExpReplace($sFileread, "[^\S]*[\[.*\]].*", "") & @CRLF)1 point
-
That is a clean example too, gives me hope for understanding the workshop!1 point
-
As promised: an example of sorting the contents of a 3D array. I hadn't tested more than two dimensions when I posted version 0.2.0-beta yesterday, and I was a bit worried it might not work. Thank goodness it did. I have tried to make this an easy example. Example: Foul Play in the English Premiership #include <Array.au3> #include <ArrayWorkshop.au3> ; stats for the English premiership home games 2014-2015 Local $aHomeGames = [["","Fouls","Yellow Cards","Red Cards"],["Arsenal",179,27,1],["Aston Villa",191,28,4],["Burnley",212,33,0], _ ["Chelsea",200,36,1],["Crystal Palace",270,26,2],["Everton",185,27,0],["Hull",229,28,3],["Leicester",225,20,2],["Liverpool",190,29,2], _ ["Man City",234,35,1],["Man United",223,31,1],["Newcastle",208,33,1],["QPR",222,36,1],["Southampton",232,23,2],["Stoke",240,33,0], _ ["Sunderland",218,45,1],["Swansea",195,25,1],["Tottenham",219,37,1],["West Brom",197,34,1],["West Ham",204,33,1]] _ArrayDisplay($aHomeGames, 'Home Games') ; stats for the English premiership away games 2014-2015 Local $aAwayGames = [["","Fouls","Yellow Cards","Red Cards"],["Arsenal",218,36,2],["Aston Villa",205,41,2],["Burnley",203,34,0], _ ["Chelsea",223,42,3],["Crystal Palace",234,35,1],["Everton",233,40,3],["Hull",228,34,4],["Leicester",176,28,5],["Liverpool",255,43,2], _ ["Man City",144,34,3],["Man United",223,42,2],["Newcastle",231,55,0],["QPR",216,28,1],["Southampton",197,30,2],["Stoke",221,34,2], _ ["Sunderland",243,38,2],["Swansea",246,52,2],["Tottenham",187,37,1],["West Brom",219,26,2],["West Ham",247,36,6]] _ArrayDisplay($aAwayGames, 'Away Games') ; now let's make this a 3D cuboid Local $aCuboid = $aHomeGames ; create a 2D template _ArrayAttach($aCuboid, $aHomeGames, 3) ; stack tables [3D] _ArrayAttach($aCuboid, $aAwayGames, 3) ; ditto ; calculate the total number of fouls, yellow cards and red cards for games played home and away For $i = 1 To UBound($aCuboid) -1 ; loop through the teams For $j = 1 To 3 ; [fouls, yellow cards, red cards] $aCuboid[$i][$j][0] = $aCuboid[$i][$j][1] + $aCuboid[$i][$j][2] ; add two values from each 3D region Next Next ; THE (VERY FIRST) 3D TEST ; sort the 3D array from the highest to the lowest number of fouls (home and away) _ArraySortXD($aCuboid, 1, 2+1, -1, 1, 1) ; this is just an example ; let's check to see if _ArraySortXD actually works [^^] ; because we stacked the tables in a certain way, we can delete the 3rd dimension and check the result with _ArrayDisplay _DeleteDimension($aCuboid, 3) ; other methods can also be used to check the contents of the first table in the 3D stack _ArrayDisplay($aCuboid, 'Dirtiest Premiership Team in 2015') Regarding the suggestion by @iamtheky above, the complication of limiting array regions in every dimension would involve additional stop parameters (for up to nine dimensions) and have a negative impact on speed. It's actually more complicated than that. Nice idea though!1 point
-
Reading data from file and making a table with it.
tarretarretarre reacted to RISHKARI for a topic
I was playing with FileOpen() however I couldn't manage to make it work. Autoit had to be able to read the data inside to finish up with a project I was working on. This really does help with storing data locally aswell. Mate, this is just perfect. I honestly expected it to be a lot bigger than what it is. I was wondering how I might go about reading a column that is string? The column it self can change in size but right before it starts it has 4 bytes saying how long the text is. I appreciate for help! Chris.1 point -
Yes, you can do like this : #include <Array.au3> Local $sIn = ":TheDcoder!anything_could_be_here PRIVMSG TheDcoder :Foobar" Local $aOut = StringRegExp($sIn, "^:(.+?)!(.+?) PRIVMSG (.+?) :(\N+)$", 3) If Not @error Then _ArrayDisplay($aOut) EndIf1 point
-
@TheDcoder, your first message was not clear enough. I understood the same thing than jchd. #include <Array.au3> Local $sIn = ":TheDcoder!anything_could_be_here PRIVMSG TheDcoder :Foobar" Local $aOut = StringRegExp($sIn, ":(.+?)!(.+?) PRIVMSG (.+?) :(\N+)", 3) _ArrayDisplay($aOut)1 point
-
By drawing the selected item in the postpaint stage: #include <GuiListView.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <SQLite.au3> #include <Math.au3> Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" Global $aListView, $hListView, $TreeView_SelTitle, $aTreeViewState[19][8] = [[18,"","","","","","",""]], $sSelectedTVIndex = 3 Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 881, 516, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $TreeView = _GUICtrlTreeView_Create($Form1, 8, 16, 319, 489, BitOR($GUI_SS_DEFAULT_TREEVIEW,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) $TreeView_Root_1 = _GUICtrlTreeView_Add($TreeView, 0, "Root - 1") _GUICtrlTreeView_SetIcon($TreeView, $TreeView_Root_1, "shell32.dll", 4) $TreeView_Root_2 = _GUICtrlTreeView_Add($TreeView, 0, "Root - 2") _GUICtrlTreeView_SetIcon($TreeView, $TreeView_Root_2, "shell32.dll", 4) Global $ListView = GUICtrlCreateListView("Rowid|Name|Time|Category", 336, 16, 538, 486, $LVS_OWNERDATA, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) ; $LVS_OWNERDATA must be included for a virtual listview _GUICtrlListView_SetExtendedListViewStyle( $ListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 88) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 112) GUICtrlSetOnEvent(-1, "ListViewClick") ;------------------------------------------------------------------------------------------ ; Get the font of the TreeView control ; Copied from the _GUICtrlGetFont example by KaFu ; See http://www.autoitscript.com/forum/index.php?showtopic=124526 Local $hDC = _WinAPI_GetDC( $TreeView ) $hFont = _SendMessage( $TreeView, $WM_GETFONT ) Local $hObject = _WinAPI_SelectObject( $hDC, $hFont ) Local $lvLOGFONT = DllStructCreate( $tagLOGFONT ) DllCall( 'gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFont, 'int', DllStructGetSize( $lvLOGFONT ), 'ptr', DllStructGetPtr( $lvLOGFONT ) ) _WinAPI_SelectObject( $hDC, $hObject ) _WinAPI_ReleaseDC( $TreeView, $hDC ) $TreeViewFont = _WinAPI_CreateFontIndirect( $lvLOGFONT ) Local $iWeight = BitOR( DllStructGetData( $lvLOGFONT, "Weight" ), $FW_BOLD ) DllStructSetData( $lvLOGFONT, "Weight", $iWeight ) $TreeViewFontBold = _WinAPI_CreateFontIndirect( $lvLOGFONT ) ;------------------------------------------------------------------------------------------ Local $idTVContextMenu = GUICtrlCreateContextMenu(GUICtrlCreateDummy()) $hTVContextMenu = GUICtrlGetHandle($idTVContextMenu) Local $idTVContextMenu_Refresh = GUICtrlCreateMenuItem("Refresh", $idTVContextMenu) Local $idTVContextMenu_Rename = GUICtrlCreateMenuItem("Rename", $idTVContextMenu) GUICtrlCreateMenuItem("", $idTVContextMenu) ; separator Local $idTVContextMenu_MarkALLRead = GUICtrlCreateMenuItem("Mark ALL Items Read", $idTVContextMenu) Local $idTVContextMenu_MarkALLUnRead = GUICtrlCreateMenuItem("Mark ALL Items UnRead", $idTVContextMenu) ;------------------------------------------------------------------------------------------ GUIRegisterMsg($WM_NOTIFY, "LWS_WM_NOTIFY") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### SubFunction_FillTreeView() While 1 Sleep(100) WEnd Func Form1Close() GUIRegisterMsg( $WM_NOTIFY, "" ) ; Exit EndFunc ;========================================================================================== Func ListViewClick() EndFunc ;========================================================================================== Func TreeView1Click() Local $sQuery, $aResult, $iRows, $iColumns Static Local $TreeView_SelTitlePRE = "" If $TreeView_SelTitlePRE == "" Then $TreeView_Selected = _GUICtrlTreeView_GetFirstChild($TreeView, $TreeView_Root_1) _GUICtrlTreeView_ClickItem($TreeView, $TreeView_Selected, "left") Else $TreeView_Selected = _GUICtrlTreeView_GetSelection($TreeView) EndIf $TreeView_SelTitle = _GUICtrlTreeView_GetText($TreeView, $TreeView_Selected) If $TreeView_SelTitle == $TreeView_SelTitlePRE Then Return Else $TreeView_SelTitlePRE = $TreeView_SelTitle EndIf ConsoleWrite($TreeView_SelTitle & @CRLF) EndFunc ;========================================================================================== Func SubFunction_FillTreeView() ConsoleWrite(" > $sSelected TV Index = " & $sSelectedTVIndex & @CRLF) ConsoleWrite(" > $sSelected TV Name = " & $aTreeViewState[$sSelectedTVIndex][5] & @CRLF) Local $idTVItem[$aTreeViewState[0][0]+1] = [$aTreeViewState[0][0]] _GUICtrlTreeView_BeginUpdate($TreeView) _GUICtrlTreeView_DeleteChildren($TreeView, $TreeView_Root_1) _GUICtrlTreeView_DeleteChildren($TreeView, $TreeView_Root_2) _GUICtrlTreeView_SetTextColor($TreeView, 0x77B5FE) ; color of additional text For $i = 1 To $aTreeViewState[0][0] $aTreeViewState[$i][0] = 3 ; icon num in "shell32.dll" $aTreeViewState[$i][1] = 0x000000 ; item text color $aTreeViewState[$i][2] = 0 ; text is bold (or not) $aTreeViewState[$i][3] = "some info" ; some additional text $aTreeViewState[$i][5] = String("item " & $i); item name Switch Mod($i,2) Case 0 $idTVItem[$i] = _GUICtrlTreeView_AddChild($TreeView,$TreeView_Root_2, $aTreeViewState[$i][5]) Case Else $idTVItem[$i] = _GUICtrlTreeView_AddChild($TreeView,$TreeView_Root_1, $aTreeViewState[$i][5]) EndSwitch Switch Mod($i,3) Case 0 $aTreeViewState[$i][2] = 0 Case Else $aTreeViewState[$i][2] = 1 EndSwitch _GUICtrlTreeView_SetItemParam($TreeView, $idTVItem[$i], $i) _GUICtrlTreeView_SetIcon($TreeView, $idTVItem[$i], "shell32.dll", $aTreeViewState[$i][0]) Next _GUICtrlTreeView_Expand($TreeView, $TreeView_Root_1, True) _GUICtrlTreeView_EndUpdate($TreeView) _GUICtrlTreeView_ClickItem($TreeView, $idTVItem[$sSelectedTVIndex]) SubFunction_FillListView() EndFunc ;========================================================================================== Func SubFunction_FillListView_Delayed() AdlibUnRegister("SubFunction_FillListView_Delayed") SubFunction_FillListView() EndFunc ;========================================================================================== Func SubFunction_FillListView() _GUICtrlListView_BeginUpdate ($ListView) _GUICtrlListView_DeleteAllItems ($ListView) For $i = 0 To 63 $ret = _GUICtrlListView_AddItem($ListView, "Row "&$i&": Col 0") ;ConsoleWrite($i & @TAB & "$ret = " & $ret & @CRLF) _GUICtrlListView_AddSubItem($ListView, $i, "Row "&$i&": Col 1", 1) _GUICtrlListView_AddSubItem($ListView, $i, "Row "&$i&": Col 2", 2) _GUICtrlListView_AddSubItem($ListView, $i, "Row "&$i&": Col 3", 3) Next _GUICtrlListView_EndUpdate ($ListView) EndFunc ;========================================================================================== Func LWS_WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $tText = DllStructCreate( "wchar[512]" ) Local Static $pText = DllStructGetPtr( $tText ) Local Static $aResult, $iRows, $iFrom Local $tNMHDR, $hWndFrom, $iCode, $tInfo, $VKey $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $TreeView Switch $iCode Case $NM_CUSTOMDRAW Local $tNMTVCUSTOMDRAW = DllStructCreate($tagNMTVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMTVCUSTOMDRAW, "DrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any item-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Local $hItemSpec = DllStructGetData($tNMTVCUSTOMDRAW, "ItemSpec") ; $hItemSpec = $hItem Local $iItemState = DllStructGetData($tNMTVCUSTOMDRAW, "ItemState") Local $iItemParam = DllStructGetData($tNMTVCUSTOMDRAW, "ItemParam") ; ItemParam = index in array Local $hDC = DllStructGetData($tNMTVCUSTOMDRAW, "HDC") ; Handle to the item's device context $iSelected = DllCall( "user32.dll", "lresult", "SendMessageW", "hwnd", $TreeView, "uint", $TVM_GETITEMSTATE, "wparam", $hItemSpec, "lparam", $TVIS_SELECTED )[0] ; Selected state If BitAND( $iSelected, $TVIS_SELECTED ) Then Return $CDRF_NOTIFYPOSTPAINT ;If Not BitAnd( $iItemState, $CDIS_FOCUS ) Then DllStructSetData( $tNMTVCUSTOMDRAW, "ClrText", $aTreeViewState[$iItemParam][1] ) ; Forecolor of item text ;DllStructSetData( $tNMTVCUSTOMDRAW, "clrTextBk",$aTreeViewState[$iItemParam][1] ) ; Backcolor of item text Local $tRECT = _GUICtrlTreeView_DisplayRectEx ( $TreeView, $hItemSpec, True) DllStructSetData( $tRECT, "Left", DllStructGetData( $tRECT, "Right") + 7) DllStructSetData( $tRECT, "Right", DllStructGetData( $tRECT, "Right") + 188) _WinAPI_DrawText( $hDC, $aTreeViewState[$iItemParam][3], $tRECT, $DT_LEFT ) ; and background color of the device context. _GUICtrlTreeView_SetBold ($TreeView, $hItemSpec, $aTreeViewState[$iItemParam][2]) ;Else ;_GUICtrlTreeView_SetBold ($TreeView, $hItemSpec, $aTreeViewState[$iItemParam][2]) ;EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors Case $CDDS_ITEMPOSTPAINT Local $hItemSpec = DllStructGetData($tNMTVCUSTOMDRAW, "ItemSpec") ; $hItemSpec = $hItem Local $iItemState = DllStructGetData($tNMTVCUSTOMDRAW, "ItemState") Local $iItemParam = DllStructGetData($tNMTVCUSTOMDRAW, "ItemParam") ; ItemParam = index in array Local $hDC = DllStructGetData($tNMTVCUSTOMDRAW, "HDC") ; Handle to the item's device context Local $tRECT = _GUICtrlTreeView_DisplayRectEx( $TreeView, $hItemSpec, True) DllStructSetData( $tRECT, "Left", DllStructGetData( $tRECT, "Right") + 7) DllStructSetData( $tRECT, "Right", DllStructGetData( $tRECT, "Right") + 188) ;DllStructSetData( $tNMTVCUSTOMDRAW, "ClrText", $aTreeViewState[$iItemParam][1] ) ; Forecolor of item text DllCall( "gdi32.dll", "int", "SetTextColor", "handle", $hDC, "int", 0xFEB577 ) ; 0x77B5FE _WinAPI_SelectObject( $hDC, $aTreeViewState[$iItemParam][2] ? $TreeViewFontBold : $hFont ) ; Bold/normal font _WinAPI_DrawText( $hDC, $aTreeViewState[$iItemParam][3], $tRECT, $DT_LEFT ) ; and background color of the device context. _GUICtrlTreeView_SetBold ($TreeView, $hItemSpec, $aTreeViewState[$iItemParam][2]) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW AdlibRegister("SubFunction_FillListView_Delayed",300) _WinAPI_RedrawWindow($TreeView) Case $NM_RCLICK Local $tMPos = _WinAPI_GetMousePos(True, $hWndFrom) ; ?????????? ???????????? ???????? Local $hItem = _GUICtrlTreeView_HitTestItem($hWndFrom, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) ; ???????? ?????????? ?????? If $hItem <> -1 And $hItem <> 0x0 Then DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hTVContextMenu, "int", 0, "int", MouseGetPos(0), "int", MouseGetPos(1), "hwnd", $Form1, "ptr", 0) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc1 point
-
Reading data from file and making a table with it.
tarretarretarre reacted to LarsJ for a topic
It's pretty easy: $hFile = FileOpen( "control.tbl", 16 ) ; 16 = binary mode $sBinData = FileRead( $hFile ) $iBytes = @extended FileClose( $hFile ) ConsoleWrite( "Bytes: " & $iBytes & @CRLF ) $tBytes = DllStructCreate( "byte[" & $iBytes & "]" ) DllStructSetData( $tBytes, 1, $sBinData ) $pBytes = DllStructGetPtr( $tBytes ) $tHeader = DllStructCreate( "int[5]", $pBytes ) ConsoleWrite( "Header:" ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 3 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 4 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 5 ) & @CRLF ) $pBytes += 20 $tagRow = "int;byte;byte" For $i = 1 To 4 $tRow = DllStructCreate( $tagRow, $pBytes ) ConsoleWrite( "Row " & $i & ":" ) ConsoleWrite( " " & DllStructGetData( $tRow, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tRow, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tRow, 3 ) & @CRLF ) $pBytes += 6 Next1 point -
The picture shows Rubik's Cube in the middle of a rotation, wherein the layer is rotated 90 degrees. New version for AutoIt 3.3.10 The scripts were flawed. Fixed in this update. 08-01-2013: First post In the Cubes menu there are six cubes from 2*2*2 to 7*7*7: Pocket Cube, Rubik's Cube, Rubik's Revenge, Professor's Cube, V-Cube 6 and V-Cube 7. See http://en.wikipedia.org/wiki/Rubik's_Cube. The Scramble menu scrambles the cube. In the input field in the statusbar you can set the number of scramble steps. The Solve menu automatically solves the cube. In this version it just plays back the undo log. The Build menu shows how the cubes are created. It also shows how the rotation of a layer is simulated. The Scramble, Solve and Build menus puts the program into a Scramble, Solve and Build mode. To leave the Scramble and Solve modes click the menu once more. To leave the Build mode uncheck the menu. The program mode or state appears in the statusbar. See the Help menu for more information about the menus. Rotating a layer in the cube Click an edge of the layer with the left mouse button and hold the button downMove the mouse in the direction you want to rotate the layerRelease the left mouse buttonThe rotating layer in the picture has probably been clicked somewhere on the blue edge. You can't rotate a layer in Scramble, Solve and Build modes. The mouse buttons can be switched in the Options. Rotating the entire cube Click in the window with the right mouse button and hold the button downMove the mouse in the direction you want the cube to rotateRelease the right mouse buttonThe description of the mouse rotations can be found in the Help menu. Using the keyboard Use the arrow keys or <A,a>, <W,w>, <S,s>, <Z,z> to rotate the cube. Use <Home> or <H,h> to place the cube in the start position. Use <Page Up> or <I,i> and <Page Down> or <O,o> to zoom in and out. Use Num 1-6 or 1-6 to show the 6 sides of the cube. The program Inspiration for the program is from this site: http://rubiksim.sourceforge.net/. The graphics is generated with old style OpenGL 1.1. Some OpenGL globals and functions are copied from this thread http://www.autoitscript.com/forum/index.php?showtopic=83581 by trancexx. Especially globals and functions for creating an OpenGL window and a rendering context. Zipfile The zipfile contains a number of files: RubiksCube.au3 - GUI and main loop, run this fileMenuFncs.au3 - implements the menu systemMenuWins.au3 - creates menu system windowsKeyboard.au3 - code for shortcut keysOGLconsts.au3 - OpenGL constantsOGLfuncs.au3 - OpenGL functionsCubes.au3 - creates the cubesTurnLayer.au3 - rotate a layerRotateCube.au3 - rotate the cubeScramble.au3 - scramble functionSolveCube.au3 - solve functionsBuild.au3 - build functionsUtilities.au3 - calculations(The files are edited with Notepad++ with a tabwidth of 2. This doesn't match the default settings in Scite.) 21-01-2013: Update #1 Fixed some errors in the Build menu. Added a log to see the colors of all sides at one time. See picture in post #5. RubiksCube3.3.10.7z Testet on XP 32 bit and Win 7 32/64 bit. Previous versions for AutoIt 3.3.81 point