Jump to content

Gabriel13

Members
  • Posts

    9
  • Joined

  • Last visited

  • Days Won

    1

Gabriel13 last won the day on November 13 2012

Gabriel13 had the most liked content!

About Gabriel13

  • Birthday August 25

Profile Information

  • Location
    at my computer, usually
  • Interests
    JSON

Recent Profile Visitors

292 profile views

Gabriel13's Achievements

Seeker

Seeker (1/7)

8

Reputation

  1. This is a script I've been using for a while – I prefer my Windows XP setup with the taskbar on top, but unfortunately there are numerous Windows programs which assume the taskbar will always be on the bottom. As a result, those programs often place their windows with title bars directly underneath my taskbar – requiring a lot of repeated hassle to get those windows out from under it. This script takes care of this problem for you – I leave it running all day, and it automatically moves any badly-placed windows out from under the taskbar for me. I'm hopeful that others will also find this little program useful! opt('mustDeclareVars',1) func fixWindows($aWinList,$nWidth,$nHeight) for $i=1 to $aWinList[0][0] local $hwnd=$aWinList[$i][1] local $pos=winGetPos($hwnd) if isArray($pos) then local $x=$pos[0],$y=$pos[1],$winWidth=$pos[2],$winHeight=$pos[3] if $x<=0 and $y<=0 and $winHeight>=(@DesktopHeight-4) then ; don’t move this window – something covering the whole screen is probably meant to be there elseif $x<$nWidth and $y<$nHeight then ; move this window out from under the taskbar winMove($hwnd,"",$x,$nHeight) endif endif next endfunc func start() local $aTaskbarPos,$trayWidth,$trayHeight do sleep(2000) ; check every two seconds $aTaskbarPos=winGetPos('[CLASS:Shell_TrayWnd]') until isArray($aTaskbarPos) if $aTaskbarPos[1]>0 then ; taskbar is not at the top of the screen, quit exit endif $trayWidth=$aTaskbarPos[0]+$aTaskbarPos[2]-32 ; allow for windows mostly on the other side of the taskbar (for dual monitor setup) $trayHeight=$aTaskbarPos[1]+$aTaskbarPos[3]-4 while true sleep(2000) ; check every two seconds fixWindows(winList(),$trayWidth,$trayHeight) wend endfunc start()keepWindowsClearOfTopTaskbar.7z
  2. You're welcome! I'd appreciate any feedback you have on it. In particular, the use of 2D arrays to represent JSON objects, how well does that work for everyone? I believe they should be compatible with the 2D array handling routines from the standard Array.au3 UDF library. I'll be working on adding comments for each function next – hopefully, that'll help me get my error codes organized. Slightly edited for clarity.
  3. Details, details… In related news, a recent phishing attack revealed that '12345' was the most popular phished Hotmail password. Apparently President Skroob uses Hotmail!
  4. I started this JSON library back in late 2007, because I needed a way to pass structured data between Javascript HTAs and AutoIt3 scripts. I've recently worked to get it in good enough shape to share with the AutoIt community, and while it still needs a bit more polish, the core functionality should be solid. Three files are included in the attached archive: JSON.au3 – the UDF Library itself. It includes a (very large) comment section at the top, which should provide sufficient documentation on how the various data types are encoded and decoded, as well as the various Javascript-based decoding extensions allowed (single-quoted strings, comments, etc.).JSON_Translate.au3 provides example functions for the powerful "translator" functionality. Translator functions can be used for both encoding and decoding. When encoding, it allows you to recursively convert your data from its normal format into the required data structures used by the JSON UDF library. When decoding, it allows you to convert the data in the opposite direction – from the JSON UDF library's data structures to the data structures your program normally uses. To use this functionality, you'll need to write your own translator functions, but this allows you to meet the custom needs of your own programs without having to hack JSON.au3. The examples provided in this file can probably be improved, but show one way of translating AutoIt-specific data types (such as binary and hwnd) back and forth.testJSON.au3 provides some quick examples of regular and translator-enhanced usage, which also help verify that encoding and decoding are working properly. These tests may not be comprehensive.The area needing the most work is error-handling. JSON data structures can be deeply nested, and it's tricky to make sure errors "bubble up" properly in AutoIt. (Plus, I need a flowchart to keep track of all my setError() numbers!) Thanks to Douglas Crockford of JSON.org, whose 2005 Javascript code for JSON encoding and decoding provided an excellent starting point for this library. Edit: updated to 0.9.1 on 2009-10-19 substantially updated opening commentsencoding: implemented logic to return "warning" @error flags for unsupported variable types & JSON objects with non-unique key stringsother minor fixes & tweaksJSON.7z
  5. Opened a ticket for this issue: #1234 (…that's amazing, I've got the same combination on my luggage!)
  6. It's a bit surprising that a COM object can mutate my variable types just by "looking" at them like this. This was nowhere on my radar screen when looking for bugs, and introduces another potential set of unexpected side-effects to watch out for. Also, when dealing with JSON data, the distinction between "0" and "false" can indeed be significant. That being said, I'm sure your explanation covers why this particular scenario may have gone unnoticed until now.
  7. It looks like this should work: msgbox(0,default,stringRegExp('<img src="/Client.Images/Society/facebook.gif"/>','src="(.*)".*>')) ; returns 1 (true) …with the added benefit that it removes the quotes from the captured value, too.
  8. While debugging my JSON library, I've run into a situation where working with a Scripting.Dictionary object results in my boolean values being changed into numbers. func testDictionary($a) local $d=objCreate('Scripting.Dictionary') for $i=0 to ubound($a)-1 $d.add($i,$a[$i]) next return $d endfunc local $aTest[2]=[false,true] msgbox(0,default,$aTest[0]) ; displays false msgbox(0,default,$aTest[1]) ; displays true local $ignore=testDictionary($aTest) msgbox(0,default,$aTest[0]) ; now displays 0 instead of false msgbox(0,default,$aTest[1]) ; now displays 1 instead of true Apparently, by just referencing the boolean values in the $d.add() call, they're converted into numbers within my array. The only way I've found to avoid this problem is to make sure I have an immutable reference to my variables – in this case, by changing the top line to: func testDictionary(const byRef $a)
  9. Hello, I've got a mature, two-year-old JSON UDF I'll be posting this weekend, once I'm able to start a new topic in the Example Scripts forum.
×
×
  • Create New...