Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/29/2015 in all areas

  1. Hello Again! I previously stumbled upon a topic asking for maps datatype's instructions... I too wasn't sure what a map is until I tried it... So I am making this topic to help other newbies (and some oldbies) better understand the Maps datatype of AutoIt! Lets start! A Note for Readers The maps datatype is still in development and is currently in Alpha Stage (More Risky than Beta) and its unstable, so AutoIt can crash indefinably while using Maps! I can't guarantee if this will be implemented in stable versions, this is a fairly new thing to AutoIt coders & in my honest opinion I don't see any use for it Maps are the best datatype in AutoIt, Very Useful ... Not hurting anyone though . Also the maps datatype is DISABLED IN STABLE VERSIONS, So you need to install the latest beta version of AutoIt to make maps work . If you find any bugs while using a map, please report it in the Official Bug Tracker Introduction To Maps Maps are just like arrays, instead they use "keys" to access elements inside them... A key can be either a string or an integer (Other datatypes work too but they are converted to a integer [Equivalent to Int($vKey)] before assignment [Source]). Although Integers don't represent the order of elements in a map unlike in an array... Declaring Maps Its similar to declaring an Array: ; This is the only way to declare a map ; You must have a declarative keyword like Dim/Global/Local before the declaration unless the map is assigned a value from a functions return Local $mMap[] ; Don't insert any numbers or strings it! Simple, Isn't it? Using Maps Using maps is similar to arrays (again!): Local $mMap[] ; Lets declare our map first! ; Adding data to maps is easy... ; This is our key ; | ; v $mMap["Key"] = "Value" ; <--- And our value! ; A key is Case-Sensitive meaning "Key" is not same as "key"! $mMap["key"] = "value" ; Not the same as $mMap["Key"]! ; There are 2 different ways to access an element in a map $mMap["Key"] ; 1st Method $mMap.Key ; 2nd Method Enumerating Maps Its quite easy to enumerate through arrays but what about maps? how can I enumerate through them!? #include <MsgBoxConstants.au3> ; Lets create our map first Local $mMap[] ; Lets add some information to the map, feel free to modify & add new elements $mMap["Name"] = "Damon Harris" $mMap["Alias"] = "TheDcoder" $mMap["Gender"] = "Male" $mMap["Age"] = 14 $mMap["Location"] = "India" $aMapKeys = MapKeys($mMap) ; MapKeys function returns all the keys in the format of an array Local $sProfile = "Profile of " & $mMap["Name"] & ':' & @CRLF ; We will use this string later For $vKey In $aMapKeys ; We use this to get the keys in a map :) $sProfile &= @CRLF & $vKey & ': ' & $mMap[$vKey] ; Add some details to the profile string using our map! Next MsgBox($MB_ICONINFORMATION + $MB_OK, "Profile", $sProfile) ; Finally display the profile :) It is easy as always Multi-Dimensional Maps Now now... I know that you are a little confused that how can an multi-dimensional maps exist... Although I am not 100% sure if its called that but lets continue: #include <MsgBoxConstants.au3> ; Multi-Dimensional maps are just maps in a map Local $mMapOfMapsvilla[] ; This map will store an other map Local $mParkMap[] ; This Park map will be inserted in the Mapsvilla's map :P $mMapOfMapsvilla["Map Item 1"] = "Town Hall" $mMapOfMapsvilla["Map Item 2"] = "Police Station" $mMapOfMapsvilla["Map Item 3"] = "Shopping Mall" $mMapOfMapsvilla["Map Item 4"] = "Residential Area" $mMapOfMapsvilla["Map Item 5"] = "Park" $mParkMap["Map Item 1"] = "Cottan Candy Stand" $mParkMap["Map Item 2"] = "Public Toilet" $mParkMap["Map Item 3"] = "Woods" $mMapOfMapsvilla.Park = $mParkMap MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla["Map Item 1"]) ; Will display Town Hall MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla.Park["Map Item 1"]) ; Will display Cottan Candy Stand I am sure its easy for you to understand now Frequently Asked Questions (FAQs) & Their answers Q #1. Help! My code does not respond to anything (or) I get an "Variable subscript badly formatted" error on the line of declaration... A. DONT USE F5 or Go, Instead use Alt + F5 or Tools -> Beta Run in SciTE (Make sure that you have Beta installed) Q #2. Why are you using "m" in-front of every map variable? A. Best coding Practices: Names of Variables Q #3. What are "Elements" which you mention frequently??? A. This is a newbie question (I have no intention of insulting you ), so I guess you are new to programming. "Elements" are data slots inside a Map (or an Array), you can imagine elements as individual variable which are stored in a Map. You can access them using "keys", Please refer to "Introduction to Maps" section at the starting of this post Q #4. Are Maps faster than Arrays? A. You need to understand that Maps have different purpose than Arrays. Maps are designed to store data dynamically (like storing information for certain controlIDs of GUI) and Arrays are designed to store data in a order (for instance, Storing every character of a string in an element for easy access). If you still want to know then if Maps are faster, then the answer is maybe... Maps are *supposed* (I am not sure ) to be faster in addition of elements (while Arrays are painfully slow while adding or removing elements). Here (Post #24) is a benchmark (Thanks kealper! ) More FAQs coming soon! Feel free to ask a question in the mean while
    1 point
  2. At least we can assert that MouseClick requires a visible target window
    1 point
  3. LarsJ

    Resize control

    On my PC it's dots but that probably depends on the theme. #include <GUIConstants.au3> #include <WinAPI.au3> Opt( "MustDeclareVars", 1 ) Global Const $SBS_SIZEBOX = 0x08 Global Const $SBS_SIZEGRIP = 0x10 Global $hGui, $hSizebox Example() Func Example() $hGui = GUICreate( "Resize corner", 300, 200, -1, 300, $WS_OVERLAPPEDWINDOW ) $hSizebox = _WinAPI_CreateWindowEx( 0, "Scrollbar", "", $WS_CHILD+$WS_VISIBLE+$SBS_SIZEBOX, 300-20, 200-20, 20, 20, $hGui ) ; $SBS_SIZEBOX or $SBS_SIZEGRIP GUIRegisterMsg( $WM_SIZE, "WM_SIZE" ) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) Exit EndFunc Func WM_SIZE( $hWnd, $iMsg, $wParam, $lParam ) Local $aSize = WinGetClientSize( $hGui ) WinMove( $hSizebox, "", $aSize[0] - 20, $aSize[1] - 20 ) EndFunc
    1 point
  4. #include <IE.au3> #include <Process.au3> Local $regValue = "0x2AF8" RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_BROWSER_EMULATION", _ProcessGetName(@AutoItPID), "REG_DWORD", $regValue) RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION", _ProcessGetName(@AutoItPID), "REG_DWORD", $regValue) $mainwin = GUICreate("test", 700, 700) $OBJECT = ObjCreate("Shell.Explorer.2") $OBJECT_CTRL = GUICtrlCreateObj($OBJECT, 0, 0, 700, 600) GUISetState() _IENavigate($object, "http://www.pinterest.com/") While 1 Sleep(100) WEndJust what i needed just took some digging
    1 point
  5. I would think that the mouse pointer changes the displays image with its cursor as you found out, Jos
    1 point
  6. Jos

    Using Assigned Variables

    Understood, but just worked on the OP's current line of thinking and pursued to get that cleared up first without changing too much. I am not stopping any of you to chime in here and show the OP a better alternative. Jos
    1 point
  7. jchd

    Using Assigned Variables

    You may be right Jos but I find that Assign + Eval + related pitfalls is much, much harder to manage than understanding how a speadsheet works, either single column (1D array) or multiple columns (2D array). Most people are used to sheet;column;row and that is dramatically similar to array[row][column].
    1 point
  8. EDIT: normal link was broken, so link only in TXT way ... (new cripled forum is really hell :-( )
    1 point
  9. COPYLEFT: © 2013 Freeware by "Exit" ALL WRONGS RESERVED
    1 point
  10. https://www.autoitconsulting.com/site/scripting/detect-an-ssd-disk-using-a-script/
    1 point
  11. https://www.autoitscript.com/forum/topic/146672-_singletonhwid-enforce-a-design-paradigm-where-only-one-instance-of-the-script-may-be-running-with-using-a-unique-id-based-on-the-users-hardware/?page=3 (towards the end)
    1 point
  12. https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine Command Line Parameter Argument constant variables constants
    1 point
  13. hey there i figured the problem out i think Local $regValue = "0x2AF8" RegWrite("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_BROWSER_EMULATION", _ProcessGetName(@AutoItPID), "REG_DWORD", $regValue) RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION", _ProcessGetName(@AutoItPID), "REG_DWORD", $regValue)
    1 point
  14. Szhlopp

    Force update/redraw gui

    _WinAPI_RedrawWindow ($GUI) ; Also sends $WM_PAINT GUISetBkColor(0xF0F0F0) Both redraw the window
    1 point
×
×
  • Create New...