Search the Community
Showing results for tags 'region'.
Found 4 results
How to detect Qwerty vs Dvorak layout?
WoodGrain posted a topic in AutoIt General Help and SupportHi guys, I've seen the @kblayout macro, but the information I'm after is the keyboard layout (aka "Input Method") so I can detect if I'm using "US Keyboard" or "United States-Dvorak Keyboard" rather than 00000c09 or 00000409 which relate to languages such as EN AU or EN US for example. For example I have 1 language set up (English Australia) in my regional settings, but then under the language I have "US Keyboard" and "United States-Dvorak Keyboard" setup, so that when I press WIN+SPACE I can toggle between them. Effectively I want a way of determining if I'm running qwerty or dvorak. Thanks guys!!
Hi! I post here because i was wonderring if someone in this forum could help me with my script. What i'm trying to do, is to basically install a new keyboard layout in Windows and activate it. I want to acheive by the registry or the command line, but not with the autoit automation tools, i don't find it stable... Thanks for your help and have a good day!
Ascend4nt posted a topic in AutoIt Example ScriptsGUI Fun! Not enough posts here are about just plain fun stuff to do with AutoIt, at least not lately. So I figure, why not dig up one of my old UDFs, clean it up a bit, and throw it very emphatically at you lot of misfits! One way of mucking about with AutoIt and Windows that can be entertaining is creating shaped GUIs. Sure, GUIs with regions are nothing new here or in general on the Windows platform. But have you ever just wanted to stare at colorful shapes flying across your screen, for no apparent reason? Well, my friend, you've come to the right place. The first UDF I've put up pretty simple. Boxes, circles, triangles, diamonds, and stars are what I bring you, in technicolor wonder. I will probably add a few more examples when I find the time.. However, its my hope that more people add to this thread - and maybe provide links to other topics or posts where some nifty GUI fun is to be had! GUI related Threads & UDFs of Interest >GUI design concepts (started by Guinness) >Perforator - Perforated GUIs (and really anything GUI or GDI+-related by UEZ) >PNG as GUI >Multiple PNG images as GUI elements >FreeText - Text shape GUIs >Visible Controls on a Transparent Window >Layered Window without Image >AnyGUI - Extend the GUI of any Window >_UskinLibrary - Skinning w/DLL >XSkin - More GUI Skinning >GUIExtender, >GUIFrame, >Toast and other nice UDFs by Melba23 >GIF Animation >GDI+ Animated Waiting / Loading Screens My Examples I should point out other GUI manipulation UDF's I've uploaded in the past, as they too can provide some amusement. >GUIBox - Rubber-band GUIs >Full-screen Crosshairs >BarSweep (very simple example) >BoxSelection (another simple example) Okay, on to the new stuff! _GUIShapes is a UDF with functions to create GUI's shapes like Circles, Boxes, Triangles, Stars, and Diamonds. These GUI's have no interactive elements or controls and are click-through-able, meaning that a click on the GUI will pass through to whatever window is underneath. _LineTraverser is a UDF with functions to create a well, line traverser. Given a start and end point, it will allow you to step through a given line without needing to do any extra work on your behalf. This uses Bresenham's line algorithm to calculate the individual steps. I know this one isn't related to GUI, but its what I used for my second 'GUI fun' example below. Pacman Line-Traversing GUI (>static or >animated). That's right, I managed to animate a GUI! Check it! (now included in the ZIP) Examples that follow will be bundled with the ZIP. Have fun! Updates: GUIShapesExample - whacky shapes flying all over the screen!!! #include "_GUIShapes.au3" ;~ #include <WinAPI.au3> ; already included in <_GUIShapes.au3> ; ======================================================================================================== ; <GUIShapesExample.au3> ; ; Example use of <_GUIShapes.au3> UDF ; ; This example creates a bunch of random GUI shapes with random attributes, and moves ; everything around - randomly. ; ; Author: Ascend4nt ; ======================================================================================================== ; ---------------------- MAIN CODE ------------------------------- Local $iShapeGUIs = 20, $aShapeGUIs[$iShapeGUIs], $iTimer, $iRand, $aRet Local $iRandX, $iRandY, $iRandColor, $iRandLength Local $iTriangles = 0, $iCircles = 0, $iStars = 0, $iDiamonds = 0, $iBoxes = 0 For $i = 0 To $iShapeGUIs - 1 ; Everything random! $iRandX = Random(0, @DesktopWidth - 20, 1) $iRandY = Random(0, @DesktopHeight - 20, 1) $iRandLength = Random(12, 300, 1) $iRandColor = Random(0x111111, 0xFFFFFF, 1) ; Choose a GUI shape at random, with semi-random attributes Switch Random(0, 5, 1) Case 0 $aShapeGUIs[$i] = _TriangleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iTriangles, 1) * Random(1, 10, 1), Default, Mod($i, 4), $iRandColor) $iTriangles += 1 Case 1 $aShapeGUIs[$i] = _CircleGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iCircles, 1) * Random(1, 10, 1), Default, $iRandColor) $iCircles += 1 Case 2 $aShapeGUIs[$i] = _StarGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iStars, 1) * Random(1, 10, 1), $iRandColor) $iStars += 1 Case 3 $aShapeGUIs[$i] = _DiamondGUICreate($iRandX, $iRandY, $iRandLength, Default, BitAND($iDiamonds, 1) * Random(1, 10, 1), $iRandColor) $iDiamonds += 1 Case Else ; 4 $aShapeGUIs[$i] = _BoxGUICreate($iRandX, $iRandY, $iRandLength, BitAND($iBoxes, 1) * Random(1, 10, 1), Default, $iRandColor) $iBoxes += 1 EndSwitch ; Show the randomly created GUI GUISetState(@SW_SHOWNOACTIVATE, $aShapeGUIs[$i]) ; And set a random transparency too WinSetTrans($aShapeGUIs[$i], '', Random(50, 255, 1)) Next ConsoleWrite("GUI Totals: Triangles:" & $iTriangles & ", Circles:" & $iCircles & ", Stars:" & $iStars & ", Diamonds:" & $iDiamonds & ", Boxes:" & $iBoxes & @CRLF) ; Timer for moving shapes $iTimer = TimerInit() While 1 ; Exit on 'ESC' keypress (BitAND() test for down-state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop Sleep(10) ; Move a random GUI every 30+ms If TimerDiff($iTimer) >= 30 Then $iRand = Random(0, $iShapeGUIs - 1, 1) ; Set GUI above other windows WinSetOnTop($aShapeGUIs[$iRand], "", 1) ; Move to a random position WinMove($aShapeGUIs[$iRand], "", Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), Default, Default, 2) ; Reset timer $iTimer = TimerInit() EndIf WEnd _ LineTraverserExample - Where's the ball? Huh, where is it, Fido?! Ooh, there it is! Fetch the ball! Gooood circle.. #include "_GUIShapes.au3" #include "_LineTraverser.au3" ;~ #include <WinAPI.au3> ; ======================================================================================================== ; <LineTraverserExample.au3> ; ; Simple Example of using the <_LineTraverser.au3> and <_GuiShapes.au3> UDF's ; ; A little red-ball will display, and a hollow ball will move towards it. ; A line will be drawn to show how the path from the hollow ball to the red-ball target should work, ; and then the hollow ball moves to it in $iStep increments. ; ; ; Author: Ascend4nt ; ======================================================================================================== Global Const $iStep = 2 Local $hHollowCircle, $hDestCircle, $iExt Local $iXTarget, $iYTarget, $aLineTraverser ; Create the 2 circle GUIs $hHollowCircle = _CircleGUICreate(Random(0, @DesktopWidth - 20, 1), Random(0, @DesktopHeight - 20, 1), 81, 10, Default, Random(0x111111, 0xFFFFFF, 1)) $hDestCircle = _CircleGUICreate(1, 1, 17, 0, 17, 0xFF0000) ; Set initial target point $iXTarget = Random(0, @DesktopWidth - 20, 1) $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Source/Target are same to start off with $aLineTraverser = _LineTraverserCreate($iXTarget, $iYTarget, $iXTarget, $iYTarget) ; Move windows to start positions WinMove($hHollowCircle, '', $aLineTraverser, $aLineTraverser) ; + Center of hollow circle, - half of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ; Transparency on 'seeker' circle WinSetTrans($hHollowCircle, '', 150) ; Show both GUIs, and put on top of all windows WinSetState($hDestCircle, '', @SW_SHOWNOACTIVATE) WinSetState($hHollowCircle, '', @SW_SHOWNOACTIVATE) WinSetOnTop($hHollowCircle, '', 1) WinSetOnTop($hDestCircle, '', 1) While 1 ; Exit on 'ESC' keypress (in down state) If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop ; < 10 ms sleep with an API call DllCall("kernel32.dll",'none','Sleep','dword',3) If Not _LineTraverserStep($aLineTraverser, $iStep) Then $iExt = @extended ; Was there movement? Then moooove If $iExt Then WinMove($hHollowCircle, '', $aLineTraverser, $aLineTraverser) EndIf $aPos = WinGetPos($hHollowCircle) ; Debug check. Should never be hit, so long as Window is moved to each step (including any last steps - see @extended) If $iXTarget <> $aPos Or $iYTarget <> $aPos Then ConsoleWrite("Mismatch: TargetX:" & $iXTarget & ", TraverserX:" & $aLineTraverser & ", Current X:" & $aPos & _ ", TargetY:" & $iYTarget & ", TraverserY:" & $aLineTraverser & ", Current Y:" & $aPos & ", @extended:" & $iExt & @CRLF) EndIf ; A little extra sleep to make it clear we've reached our destination. DllCall("kernel32.dll",'none','Sleep','dword',6) ; Now we'll set a new destination (with a visible line) Dim $iXTarget = Random(0, @DesktopWidth - 20, 1), $iYTarget = Random(0, @DesktopHeight - 20, 1) ; Create a new Line-Traverser (no need to explicitly destroy the last one, it was just an array of numbers) $aLineTraverser = _LineTraverserCreate($aLineTraverser, $aLineTraverser, $iXTarget, $iYTarget) ; + Center of hollow circle, - center of target circle WinMove($hDestCircle, '', $iXTarget + 40 - 8, $iYTarget + 40 - 8) ;~ Draw the line on-screen to give a visual indicator of the path that the hollow circle should take ;~ (note that the line will be overwritten by ANY screen activity, but that's fine for the example) ; Get DC to screen $hDC = _WinAPI_GetDC(0) ; Create pen and select it into DC $hPen = _WinAPI_CreatePen(0, 3, 0xFFFFFF) $hPenOld = _WinAPI_SelectObject($hDC, $hPen) ; Note we add 40 (for the center of the hollow circle GUI) _WinAPI_DrawLine($hDC, $aPos + 40 - 1, $aPos + 40 - 1, $iXTarget + 40 - 1, $iYTarget + 40 - 1) ; Select the old pen back _WinAPI_SelectObject($hDC, $hPenOld) ; Clean up pen and then release DC _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) ; What fun drawing with GDI is =| Else WinMove($hHollowCircle, '', $aLineTraverser, $aLineTraverser) EndIf WEnd GUIShapesFun.zip ~prev downloads: 60
I have been making an effort to keep my scripts as readable as I can, especially since it became clear to me how it otherwise becomes very tricky to maintain a longer script, and extensive use of Regions has been a bigger part of that. SciTE4Autoit3 is great at highlighting different parts of code and so on, and I make heavy usage of the "Tidy" function, which saves a lot of time when it comes to Indentation inside Functions and (also nested) If...EndIf, While...Wend and similar statements. What it seems not intended to do (by default?), is to also apply Indentation within #Region...#EndRegion markings - which is what I would like it to do now. Whenever I do this myself, and then "Tidy" my code, this is undone. Maybe there is a setting somewhere, or a workaround? I´ve only found the "Options"-->"Change Indentation Settings" Menu where Tab Size and Indent Size can be set...