Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/19/2014 in all areas

  1. Firstly, I didn't see a forum section that was well suited for this article, so I decided to place it in the help section, since that would be the most read section. Feel free to move this article to the appropriate section. If you're here at the forums, you understand that Autoit is a very powerful tool for controlling Windows. You may also be aware of a tool that is included with Windows 7 called, "Windows Speech Recognition" which allows you to use voice commands to run tasks, like... Opening the start menu, or running a program. What you may not be aware of is, "Windows Speech Recognition Macros" or "WSR Macros" for short. This is a free program put out by Microsoft that lets you create your own voice commands. You would essentially... create a trigger word or phrase, then you have the option of what you want WSR to do when it hears that phrase. While that sounds amazing, in practice it's very limited. This is where Autoit comes into play. Using WSR Macros, you can set a voice command to run a program. Any program. This allows for a very large array of amazing things that you can do using Autoit. For example. I use PotPlayer for watching videos. If I say, "Pause" WSR has no clue what I'm talking about. But, creating a simple and very short program in Autoit. Opt("WinTitleMatchMode", 2) If WinActive("PotPlayer") <> 0 Then Send("{Space}") EndIf Now I can tell WSR to run "Pause.exe" if I say, pause. (compiled from the au3) Using this simple combination of programs, you can create any string of trigger words to do anything your imagination can think of. Helpful Tips: Using more than 1 word for the trigger will help WSR distinguish between if you are just talking or if you're giving a command. This will also help if you are transcribing, as not to run a command when your intention is to transcribe the word. Because language is artistic, there can be several ways to complete the same action. "Open my music folder" "Let's listen to some music" "Open my music" To prevent a ton of file clutter, instead of selecting "New Speech Macro..." for every way you say things, select "Explore Speech Macros..." Then go to the original macro file (WSRMac extension) and alter the contents a bit. Like this... (Not incapsulated to maintain color for easier reading) ----- <?xml version="1.0" encoding="UTF-16"?> <speechMacros> <command> <listenFor>Open my music folder</listenFor> <run command="C:Music" params=""/> </command> <command> <listenFor>Let's listen to some music</listenFor> <run command="C:Music" params=""/> </command> <command> <listenFor>Open my music</listenFor> <run command="C:Music" params=""/> </command> <Signature> encrypted coding, very long, useless to the purpose ----- Notice... You don't need a seperate file, just add another command to the same file. If you really wanted to tidy up, you could actually merge all your different voice commands into 1 giant (and very confusing) file.
    1 point
  2. Hi there. This script is an implicit function plotter, plotting a graph that simulates a landscape. Basically, everything you see in this picture is based on implicit equations and functions. I modified the original equations a bit and added animation for the sea, a moving sun and two different kinds of lighting. Procedural Scene (only per-pixel-colors are calculated, no drawing function is used) Animated sea waves Animated sun Ambient light Directional light The animation has 60 Frames and runs @30FPS. The animation must be pre-buffered due the massive calculations done for every pixel, this takes approximately 5 minutes (get a coffee ). Here are the equations I used in the final version (don't change anythin in the script, except you want to redo all the math): Tree trunks: Light leaves: Dark leaves: Ground: Water: The Sun: Movement of the Sun: Calculation of the RGB values: If you really can't wait 5 minutes for the animation to calculate, here is a GIF (rendered with GDI+): Have fun LandScape.au3
    1 point
  3. More like -256.
    1 point
  4. 1 point
  5. In the first example NOT is only effective for Func1.
    1 point
  6. Hi Cryslacks, have a look at MouseDown & MouseWheel in the help file Bill
    1 point
  7. Another Example #include <IE.au3> Local $oIE = _IECreate() _IEDocWriteHTML($oIE, HTML()) Local $oTableDatas = _IETagNameGetCollection ($oIE, "td") For $oTableData In $oTableDatas If StringRegExp($oTableData.innerText, "Phone Number") Then ConsoleWrite("Phone Number : " & StringRegExpReplace($oTableData.innerText, "(?s).*?(\d)([\d\-]+).*", "\1\2") & @CRLF) ExitLoop EndIf Next Func HTML() $sHTML = _ "<html><body>" & _ "<table><tbody><tr><td><b>" & _ "Phone Number: </b> '206-338-2015'</td></tr></tbody>" & _ "</table></body></html>" Return $sHTML EndFunc With Website #include <ie.au3> $oIE = _IECreate ("http://msrunes.esy.es/") Local $oTableDatas = _IETagNameGetCollection ($oIE, "td") For $oTableData In $oTableDatas If StringRegExp($oTableData.innerText, "Phone Number") Then ConsoleWrite("Phone Number : " & StringRegExpReplace($oTableData.innerText, "(?s).*?(\d)([\d\-]+).*", "\1\2") & @CRLF) ExitLoop EndIf Next
    1 point
  8. Malkey, Using spaces to complete the aim is truly awesome. Brilliant. michaelslamet, To detect mouse pressed you have to subclass the control, using the native $GUI_EVENT_PRIMARYDOWN caused lag problems. Here is the final script #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> #include <WinAPI.au3> ; Register callback function and obtain handle to _New_WndProc Global $___hNew_WndProc = DllCallbackRegister("_New_WndProc", "int", "hwnd;uint;wparam;lparam") ; Get pointer to _New_WndProc Global $___pNew_WndProc = DllCallbackGetPtr($___hNew_WndProc) Global $hEdit ; Handle of the Edit Global $___pOld_WndProc ; Old Window Procedure's Address Example() Func Example() ; Create GUI GUICreate("Edit Char From Pos", 400, 200, -1, -1) GUICtrlCreateEdit("Kc and Kp are the equilibrium constants of gaseous mixtures." & @CRLF & @CRLF & _ "However, the difference between the two constants is that Kc is defined by molar concentrations," & @CRLF & @CRLF & _ "whereas Kp is defined by the partial pressures of the gasses inside a closed system." & @CRLF & @CRLF & _ "The equilibrium constants do not include the concentrations of single components such as liquids and solid, and they do not have any units.", 2, 2, 394, 170, 0) If StringRegExp(GUICtrlRead(-1), "\v+$") = 0 Then GUICtrlSetData(-1, GUICtrlRead(-1) & @CRLF) GUICtrlSetData(-1, StringRegExpReplace(GUICtrlRead(-1), "(\V)(\v)", "\1 \2")) $hEdit = GUICtrlGetHandle(-1) $___pOld_WndProc = _SubClass($hEdit, $___pNew_WndProc) ;store the old WndProc OnAutoItExitRegister("OnExit") GUISetState(@SW_SHOW) Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example ;malkey made a better function Func Hover_WordDetect() ;by malkey Local $aCharPos = _GUICtrlEdit_CharFromPos($hEdit, _WinAPI_GetMousePosX(True, $hEdit), _WinAPI_GetMousePosY(True, $hEdit)) Local Const $sLine = _GUICtrlEdit_GetLine($hEdit, $aCharPos[1]) $aCharPos[0] -= _GUICtrlEdit_LineIndex($hEdit, $aCharPos[1]) If StringMid($sLine, $aCharPos[0] + 1, 1) == " " Then Return Null Return StringRegExpReplace($sLine, "(?s)^.{0," & $aCharPos[0] & "}(?: |^)([^ ]*).*$", "\1") EndFunc ;==>Hover_WordDetect Func _SubClass($hWnd, $pNew_WindowProc) Local $iRes = _WinAPI_SetWindowLong ($hWnd, -4, $pNew_WindowProc) If @error Then Return SetError(1, 0, 0) If $iRes = 0 Then Return SetError(1, 0, 0) Return SetError(0, 0, $iRes) EndFunc ;==>_SubClass ;The new window procedure of the edit control. Func _New_WndProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_LBUTTONDOWN Local $Text = Hover_WordDetect() If $Text Then ConsoleWrite("Clicked : " & $Text & @CRLF) Case $WM_MOUSEMOVE ToolTip(Hover_WordDetect()) Return 0 ;don't post message to the gui EndSwitch ; Pass to the Original Window Procedure. Return _WinAPI_CallWindowProc($___pOld_WndProc, $hWnd, $iMsg, _ $wParam, $lParam) EndFunc ;==>_New_WndProc Func OnExit();Mem Release ;unsubclass the control _SubClass($hEdit, $___pOld_WndProc) DllCallbackFree($___hNew_WndProc) EndFunc ;==>OnExit ;the following functions now don't have any use but for future reference(or backup) I'm posting them ;The no. of pixels to negotiate in case the mouse is over blank space Func Hover_WordDetect_($XPrecision = -1, $YPrecision = -1) ;by phoenix XL Local $aCharPos[2], $iMousePos[2] = [_WinAPI_GetMousePosX(True, $hEdit), _WinAPI_GetMousePosY(True, $hEdit)] Static Local $iXPrecision = GetLineDimension($hEdit, 1), $iYPrecision = GetLineDimension($hEdit, 2) $aCharPos = _GUICtrlEdit_CharFromPos($hEdit, $iMousePos[0], $iMousePos[1]) ;lets check if its blank space Local $aRealPos = _GUICtrlEdit_PosFromChar($hEdit, $aCharPos[0]) ;~ _ArrayDisplay($iMousePos) ;~ _ArrayDisplay($aRealPos) If $XPrecision <> -1 Then $iXPrecision = $XPrecision If $YPrecision <> -1 Then $iYPrecision = $YPrecision ;~ ConsoleWrite($iXPrecision & @CRLF) ;~ ConsoleWrite($iYPrecision & @CRLF) Switch $aRealPos[0] Case $iMousePos[0] - $iXPrecision To $iMousePos[0] + $iXPrecision ;if we reach here then X-Coord is inside precision ;lets check Y-Coord Switch $aRealPos[1] Case $iMousePos[1] - $iYPrecision To $iMousePos[1] + $iYPrecision ; ==> All good Case Else Return "" EndSwitch Case Else Return "" EndSwitch Local Const $sLine = _GUICtrlEdit_GetLine($hEdit, $aCharPos[1]) $aCharPos[0] -= _GUICtrlEdit_LineIndex($hEdit, $aCharPos[1]) Local $aWords = StringSplit($sLine, " "), $iCount = 0 For $i = 1 To $aWords[0] Switch $aCharPos[0] Case $iCount To $iCount + StringLen($aWords[$i]) ;~ ConsoleWrite($aWords[$i] & @CRLF) Return $aWords[$i] Case Else ;~ ConsoleWrite("From: " & $iCount & " to: " & $iCount + StringLen($aWords[$i]) & @TAB & $aCharPos[0] & @CRLF) $iCount += StringLen($aWords[$i]) + 1 EndSwitch Next ;~ ConsoleWrite("" & @CRLF) Return "" EndFunc ;==>Hover_WordDetect_ Func GetLineDimension($hEdit, $iDimension) ;$iDimension : 1 - width, 2 - height ; Create DC $hDC = _WinAPI_GetDC($hEdit) $hFont = _SendMessage($hEdit, $WM_GETFONT) ; $WM_GetFont $hPrev_Font = _WinAPI_SelectObject($hDC, $hFont) Local $tSize = DllStructCreate("int;int") DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", "¤", "int", 1, "ptr", DllStructGetPtr($tSize)) _WinAPI_SelectObject($hDC, $hPrev_Font) _WinAPI_ReleaseDC($hEdit, $hDC) Return DllStructGetData($tSize, $iDimension) EndFunc ;==>GetLineDimension Regards
    1 point
  9. Or this Local $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.type == "radio" and $oInput.value == "0" Then $oInput.checked = true Next
    1 point
  10. jchd

    StringRegExp Question

    I whish you the best of luck, sincerely.
    1 point
  11. I had seen the UDF (in one of my searches around), and have considered it, though haven't had the time to learn about it along with all the other new things I'm digesting (sometimes I feel like I'm getting fed info about AutoIt about as fast as a whale scooping up krill - though still in human form.......) - it is on my list of things to study further and I will likely use the UDF - moving from disk to memory was my first thought when I had some speed issues, though the tip on BEGIN/COMMIT (I think it was from one of your posts - seeing the avatar, I know I've read a lot of your info) worked very well for my current project. Your comment about 'such a tiny DB' also encourages me. The world I've been around calls 50k records (of 20-30 columns with various data up to 300 characters) 'big' - I've always felt that a few times that is 'medium' perhaps, though I have seen discussions on millions of records being considered 'small'. It all depends on your project and point of view, though with my current skills and knowledge, I would not consider using AutoIt with SQLite for such a database in my project, which is not a persistent DB, it is rebuilt from filenames on every run (the only way we can guarantee the data and then properly manipulate it). We aren't doing a 'build it and then search many', we are (simply?) processing current filenames, manipulating the data, reformatting according to various rules and options, then updating the file names to be in a consistent manner. The process is only run a few times and all filenames are updated, so 'long' process times of 3-5 minutes isn't horrible. One similar product takes up to 20 minutes to update their database, so I'm not unhappy with my times, just looking for ideas on if I'm burning up resources I shouldn't. Seems I'm in the ballpark though. I will look at the UDF again as I get the project nearer completion (i.e., finish all these last features up, clear some bugs, etc.) - for now it may become a future update function. While we are on the 'speed' discussion, I do have an issue with processing that I was thinking of making a new topic with - if that is best, let me know. While I'm running a process (reading the filenames, manipulating them, etc. - all in AutoIt and memory (i.e., no disk activity), though building the SQLite commands, if I go to another program (while I'm waiting I read forum posts, help files, etc. to learn something else, or do a bit of coding - whatever), it seriously affects processing time. Again, I'm used to php and server processing in the back-end, with massive processing power, multi-tasking, etc. going (I'm not all that familiar with the details, but I know it is a different method altogether than GUI and user-side processing) so never worried about such things, but my time to process some 30000 records I have in a test base goes from ~3 minutes (when just watching the program) to L O N G - sometimes 10+ minutes or more when I am off looking at other things. I know this has to do with keeping window focus on the process - I can, at any time, click on the progress window and it speeds up quickly (I have it updating a progress meter with 'time spent' every few hundred records to see the progress) and I wonder if I could/should use something like (I know this is not the program and I will figure out all the correct commands, I'm just wondering if this is the right approach); Local $mywindow,$activewindow while 1 $activewindow = _WinAPI_GetFocus() If Not $mywindow Then Static $mywindow = $activewindow EndIf _WinAPI_SetFocus($mywindow) ; process a bit - maybe a few hundred records = ~ 300ms _WinAPI_SetFocus($activewindow) If (identify 'all records processed') Then ExitLoop EndIf WEnd to keep the focus 'somewhat' on my program (allowing the user to do other things, though with an understood 'cost') Perhaps WinActivate is more correct, etc. - again, I am not asking for a written program, I'm happy to do that, just want to understand if I'm on the right track with the best method to pursue (i.e., 'focus switching') when I get to the point this feature moves up on the priority list. I do a lot of 'look-ahead' thinking on every program part, when I see a potential for a customer complaint I try to make sure I know the direction that I need to study long before getting into that part of the programming - to me, that is 'best practice' instead of waiting until it is urgent and then having to piece-meal some bit of patch-up code to cover - and..... worse thing ....having to go back and fix all the mess later. We are currently covering this 'known issue' with documentation (stating that they need to stay on this window or processing time will suffer) - or is there some other way to achieve the same/better results in AutoIt?
    1 point
  12. jchd

    StringRegExp Question

    That isn't going to end as easy as you seem to think of it. You can encounter valid but meaningless variable names in single end of line comments, in comment blocks, in strings; actual name may also appear in statements but without the $ sign (IsDeclared, Assign). guinness has published a number of tools to dissect AutoIt code. You'd better look there first. Else a valid variable name (with $) matches the following pattern: \$\w{1,4093} and even then, I'm not sure you can use a variable name of that size (not going to test that either).
    1 point
  13. mikell

    StringRegExp Question

    This expression #Include <Array.au3> $str = "$array[0] & $one, $two=1 & @crlf & ($three) [$four] " $res = StringRegExp($str, '\$[^\s=,\[\]\)]+', 3) _ArrayDisplay($res) means : "get all matches including a $ followed by one or more characters which are not h, CR, LF, =, comma, [ , ], ) " It's a pretty way to put in the expression the trailing filter without getting it Edit Otherwise you can use an assertion (lookahead) like this $res = StringRegExp($str, '(\$.+?)(?=[\s=,\[\]\)])', 3) which means : "get a $ followed by one or more of any character, this group being followed by a space, a comma etc " To get the $ you must include it in the capturing group
    1 point
  14. asdf8

    Includes Helper

    Version supports also AutoIt 3.3.10.2 currently exists only for the modified for AutoIt SciTe-Ru. Since I do not use SciTE4AutoIt3, I need some time, and then I will publish the new version here.
    1 point
  15. mikell

    StringRegExp Question

    The first post suggested that the leading $ must be grabbed If not it needs grouping parentheses $res = StringRegExp($str, '\$([^\s=,\[]+)', 3) jc, the 3 in the regex also suggests that he wants to get plain string results BTW does my expression match the OP's specifications in a satisfying way ?
    1 point
  16. If you're concerned by SQLite speed on such a tiny DB which you want persistent, you can always make good use of my SQLite Backup UDF which allows copy of databases to/from memory very easily. This way you can "backup" the disk DB to memory, perform any action on it and back up to disk once done. Of course while you're working on the memory DB, a power outage will loose changes but it's up to you to perform intermediary backups to disk to protect against such issues.
    1 point
  17. mikell

    StringRegExp Question

    Hmm looks like a variable check Try this #Include <Array.au3> $str = "$array[0] & $one, $two=1 & @crlf & $three" $res = StringRegExp($str, '\$[^\s=,\[]+', 3) _ArrayDisplay($res)
    1 point
  18. The UI Automation will not come far enough if it only exposes AWT Frame Attached some code which shows JAB (Java Accessibility Bridge) can be loaded from AutoIT. Not finished at all (put on my long term TODO list) Maybe its usefull for you or others as a starting point. ;~ By inspecting the WindowsAccessBridge-32.dll it reveals some information about the hidden dialogs ;~ So it seems the hidden dialog is shown after you call windows_run() no clue if interaction is needed ;~ ;~ Somehow it sends a message unclear if this is to the JVM to respond to ;~ push SSZ6E73E320_AccessBridge_FromJava_Hello ;~ push SSZ6E73E300_AccessBridge_FromWindows_Hello ;~ db 'AccessBridge-FromWindows-Hello',0 ;~ db 'AccessBridge-FromJava-Hello',0 ;~ Copied from this NVDA reference and translated to AutoIT ;~ http://www.webbie.org.uk/nvda/api/JABHandler-pysrc.html ;~ ;~ def initialize(): ;~ global isRunning ;~ if not bridgeDll: ;~ raise NotImplementedError("dll not available") ;~ bridgeDll.Windows_run() ;~ #Accept wm_copydata and any wm_user messages from other processes even if running with higher privilages ;~*** ChangeWindowMessageFilter=getattr(windll.user32,'ChangeWindowMessageFilter',None) ;~*** if ChangeWindowMessageFilter: ;~*** if not ChangeWindowMessageFilter(winUser.WM_COPYDATA,1): ;~*** raise WinError() ;~*** for msg in xrange(winUser.WM_USER+1,65535): ;~*** if not ChangeWindowMessageFilter(msg,1): ;~*** raise WinError() ;~ #Register java events ;~ bridgeDll.setFocusGainedFP(internal_event_focusGained) ;~ bridgeDll.setPropertyActiveDescendentChangeFP(internal_event_activeDescendantChange) ;~ bridgeDll.setPropertyNameChangeFP(event_nameChange) ;~ bridgeDll.setPropertyDescriptionChangeFP(event_descriptionChange) ;~ bridgeDll.setPropertyValueChangeFP(event_valueChange) ;~ bridgeDll.setPropertyStateChangeFP(internal_event_stateChange) ;~ bridgeDll.setPropertyCaretChangeFP(internal_event_caretChange) ;~ isRunning=True ;create the structs ;~ ;~ http://docs.oracle.com/javase/accessbridge/2.0.2/api.htm ;~ ;~ #define MAX_STRING_SIZE 1024 ;~ #define SHORT_STRING_SIZE 256 ;~ struct AccessBridgeVersionInfo { ;~ wchar_t VMversion[SHORT_STRING_SIZE]; // version of the Java VM ;~ wchar_t bridgeJavaClassVersion[SHORT_STRING_SIZE]; // version of the AccessBridge.class ;~ wchar_t bridgeJavaDLLVersion[SHORT_STRING_SIZE]; // version of JavaAccessBridge.dll ;~ wchar_t bridgeWinDLLVersion[SHORT_STRING_SIZE]; // version of WindowsAccessBridge.dll ;~ }; ;~ Local $AccessBridgeVersionInfo=DllStructCreate("WCHAR VMversion[256];WCHAR bridgeJavaClassVersion[256];WCHAR bridgeJavaDLLVersion[256];WCHAR bridgeWinDLLVersion[256]") Local $AccessBridgeVersionInfo=DllStructCreate("WCHAR VMversion[256];WCHAR bridgeJavaClassVersion[256];WCHAR bridgeJavaDLLVersion[256];WCHAR bridgeWinDLLVersion[256]") ;~ struct AccessibleContextInfo { ;~ wchar_ name[MAX_STRING_SIZE]; // the AccessibleName of the object ;~ wchar_ description[MAX_STRING_SIZE]; // the AccessibleDescription of the object ;~ wchar_ role[SHORT_STRING_SIZE]; // localized AccesibleRole string ;~ wchar_ states[SHORT_STRING_SIZE]; // localized AccesibleStateSet string ;~ // (comma separated) ;~ jint indexInParent // index of object in parent ;~ jint childrenCount // # of children, if any ;~ jint x; // screen x-axis co-ordinate in pixels ;~ jint y; // screen y-axis co-ordinate in pixels ;~ jint width; // pixel width of object ;~ jint height; // pixel height of object ;~ BOOL accessibleComponent; // flags for various additional ;~ BOOL accessibleAction; // Java Accessibility interfaces ;~ BOOL accessibleSelection; // FALSE if this object doesn't ;~ BOOL accessibleText; // implement the additional interface ;~ BOOL accessibleInterfaces; // new bitfield containing additional ;~ // interface flags ;~ }; ;~ Local $AccessibleContextInfo=DllStructCreate("WCHAR name[1024];WCHAR description[1024];WCHAR role[256];WCHAR states[256];int indexInParent;int childrenCount;int x;int y;int width;int height;BOOL accessibleComponent;BOOL accessibleAction;BOOL accessibleSelection;BOOL accessibleText;BOOL accessibleInterfaces") Local $AccessibleContextInfo=DllStructCreate("WCHAR name[1024];WCHAR description[1024];WCHAR role[256];WCHAR states[256];int64 indexInParent;int64 childrenCount;int64 x;int64 y;int64 width;int64 height;byte accessibleComponent;byte accessibleAction;byte accessibleSelection;byte accessibleText;byte accessibleinterfaces") ;~ #AutoIt3Wrapper_UseX64=Y #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <constants.au3> #include <WinAPI.au3> #include <debug.au3> local $hwnd local $i local $result local $vmID local $ac ;~ Make messages elevated _ChangeWindowMessageFilter($WM_COPYDATA,1) for $i=$WM_USER to $WM_USER+65536 _ChangeWindowMessageFilter($i, 1) Next Func _ChangeWindowMessageFilter($iMsg, $iAction) Local $aCall = DllCall("user32.dll", "bool", "ChangeWindowMessageFilter", "dword", $iMsg, "dword", $iAction) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return 1 EndFunc local $bridgeDLL=DLLOPEN("WindowsAccessBridge-32.dll") ;~ sleep(500) If $bridgeDLL=true Then consolewrite($bridgeDLL & @CRLF) Else consolewrite("DLL not found try to change to WindowsAccessBridge-64.dll if you use 64 bits autoit and windows") endIf ;~ TODO: Handle messages received from initialize $result =dllcall($bridgeDLL,"int:cdecl", "Windows_run") consolewrite($result & " " & @error & " initializeAccessBridge is finished") sleep(250) consolewrite("Windows_run passed :" & $result & @CRLF) Local $var = WinList() consolewrite("Before loading all Windows:" & $var[0][0] & @CRLF) For $i = 1 To $var[0][0] ; Only display visble windows that have a title If IsVisible($var[$i][1]) Then local $handle=wingethandle($var[$i][0]) $result =dllcall($bridgeDLL,"BOOL:cdecl", "isJavaWindow", "hwnd", $handle) if @error=0 Then if $result[0]=1 Then consolewrite( $i & " Java Window Title=" & $var[$i][0] & " Handle=" & $var[$i][1] & @TAB & " res: " & $result[0] & @CRLF) local $ac=0 local $vmID=0 $result =dllcall($bridgeDLL,"BOOL:cdecl", "getAccessibleContextFromHWND", "hwnd", $handle, "long*", $vmID, "ptr*", $ac) if @error=0 Then consolewrite("We have a context " & @CRLF) $vmID=$result[2] $ac=$result[3] if @error > 0 then consolewrite("Struct error") ;~ $result =dllcall($bridgeDLL, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "struct", $AccessBridgeVersionInfo) $result =dllcall($bridgeDLL, "BOOL:cdecl", "getVersionInfo", "long", $vmId, "ptr", DllStructGetPtr($AccessBridgeVersionInfo)) consolewrite( @error & " context found of " & $vmID & @CRLF) if @error=0 Then $s1=dllstructgetdata($AccessBridgeVersionInfo, "VMVersion") $s2=dllstructgetdata($AccessBridgeVersionInfo, "bridgeJavaClassVersion") $s3=dllstructgetdata($AccessBridgeVersionInfo, "bridgeJavaDLLVersion") $s4=dllstructgetdata($AccessBridgeVersionInfo, "bridgeWinDLLVersion") consolewrite("VMVersion: <" & $s1 & ">" & @CRLF) consolewrite("bridgeJavaClassVersion: <" & $s2 & ">" & @CRLF) consolewrite("bridgeJavaDLLVersion: <" & $s3 & ">" & @CRLF) consolewrite("bridgeWinDLLVersion: <" & $s4 & ">" & @CRLF) EndIf ;~ Retrieves an AccessibleContextInfo object of the AccessibleContext object ac. $result =dllcall($bridgeDLL, "BOOL:cdecl", "getAccessibleContextInfo","long", $vmId, "ptr", $ac, "ptr", DllStructGetPtr($AccessibleContextInfo)) ;~ Local $AccessibleContextInfo=DllStructCreate("WCHAR name[1024];WCHAR description[1024];WCHAR role[256];WCHAR states[256];int indexInParent;int childrenCount;int x;int y;int width;int height;BOOL accessibleComponent;BOOL accessibleAction;BOOL accessibleSelection;BOOL accessibleText;BOOL accessibleInterfaces") if @error<>0 Then consolewrite("We have an error " & @CRLF) EndIf $s1=dllstructgetdata($AccessibleContextInfo, "name") $s2=dllstructgetdata($AccessibleContextInfo, "description") consolewrite("name: <" & $s1 & ">" & @CRLF) consolewrite("description: <" & $s2 & ">" & @CRLF) ;~ AccessibleContext GetAccessibleChildFromContext(long vmID, AccessibleContext ac, jint index); ;~ Returns an AccessibleContext object that represents the nth child of the object ac, where n is specified by the value index. Else consolewrite( @error & " No context found" & @CRLF) endif EndIf Else EndIf endif Next ;~ http://www.autohotkey.com/board/topic/95343-how-to-send-to-unseen-controls-in-a-java-app/ local $result =dllcall($bridgeDLL,"BOOL", "shutdownAccessBridge") Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible
    1 point
  19. Helpful Tip: To save space on Autoit clutter you can use the parameters option. For instance: Pressing the arrow keys on the keyboard. Instead of having 4 different autoit programs, you can have 1 take the parameters into account, and send the appropriate command. Example: WSR ----- <command> <listenFor>Up</listenFor> <run command="C:UsersSorimachiDocumentsSpeech MacrosArrow Keys.au3" params="1"/> </command> <command> <listenFor>Down</listenFor> <run command="C:UsersSorimachiDocumentsSpeech MacrosArrow Keys.au3" params="2"/> </command> <command> <listenFor>Left</listenFor> <run command="C:UsersSorimachiDocumentsSpeech MacrosArrow Keys.au3" params="3"/> </command> <command> <listenFor>Right</listenFor> <run command="C:UsersSorimachiDocumentsSpeech MacrosArrow Keys.au3" params="4"/> </command> ----- Autoit $command = $CmdLine[1] If $command = "1" Then UpArrow() ElseIf $command = "2" Then DownArrow() ElseIf $command = "3" Then LeftArrow() ElseIf $command = "4" Then RightArrow() EndIf Func UpArrow() Send("{UP}") EndFunc ;==>UpArrow Func DownArrow() Send("{DOWN}") EndFunc ;==>DownArrow Func LeftArrow() Send("{LEFT}") EndFunc ;==>LeftArrow Func RightArrow() Send("{RIGHT}") EndFunc ;==>RightArrow
    1 point
  20. Nice tutorial - hadn't seen that page - learned a lot about what, to me, has been the most confusing part of moving to AutoIt. I come from years in php - tossing variable names in/out/around at whim (and often getting lost in a mistyped letter that takes hours to find..... - one of the things I really like about AutoIt is helping me catch that stuff). From the tutorial I see that AutoIt actually gives Global to variables in the script and Local to function variables - I've taken to using the AutoItSetOption("MustDeclareVars", 1) directive to help break myself of willie-nillie naming (and have seen my code tighten up dramatically - finding that using ONE Global variable called $temp very useful for doing minor checks that I only need for a couple lines. Sure keeps the page cleaner! One thing, though, from the tutorial that I still don't quite understand is shown below Foo() Foo() Foo() Func Foo() ; Set the flag only on the first entry into the function ; This assignment will be ignored on subsequent entries Local Static $fFoo_First_Pass = True ; Check the flag If $fFoo_First_Pass Then ; Immediately clear the flag to prevent running on subsequent passes $fFoo_First_Pass = False ; Run on first pass because flag is set ConsoleWrite("First pass" & @CRLF) Else ; Flag remains cleared for subsequent passes ConsoleWrite("Not first pass" & @CRLF) EndIf EndFunc ;==>Foo I believe I understand it now (though just looking at the code, it certainly requires an understanding of the Static declaration), however, I was confused by the text Perhaps (at least, for me), it would be more easily understood to change 'assignment' to "re-assignment attempt" - or something like that. What I thought, at first, is that the INITIAL assignment is ignored, though that would, of course, negate the function of Static.... Anyway, I now understand what it can do - just have to find a great use for it, then use it over and over a few times - in the meantime, I'm bookmarking that page! One other 'take away' from reading this tutorial that I really was happy to get clear is the ByRef. That had me totally baffled until I read this. Now, I see why all the 'pros' using AutoIt run everything in functions - I was just making main code with functions as a by-product (php style I have used for years). ByRef can certainly be used to great advantage - though I am not planning to go back to all my previous AutoIt scripts and change things, I am going to be using these powerful tools to make things easier in the future! One question that came to mind in digesting all this (and it has a direct reflection on the project I'm working right now) - what is the 'best practice' and 'fastest', perhaps 'prefered' (terms that are, I know, difficult to scope, however.....) way to manipulate data of small-medium (in my world) lists of text (in this case, the 'core customer' will often be dealing with some 50k songs - not very big, though some will reach in the 100K - 200K range and I wonder more about if my code is right for them). I read the filenames, dissect and manipulate them in various fashion (breaking out the Artist, Title, etc.), then rename/manipulate as/when needed (fixing caps, spelling, fname/lname switch around, etc.) Lots of features/functions, though lots of potentially wasted time doing too many disk writes). I wrote all this in php and was very satisfied with the processing times I got using MySQL on a local server base, though when I found how unsecure it all was, I got into AutoIt and am porting everything over. I'm getting fast times using SQLite (thanks to a tip from the forum to use BEGIN/COMMIT - brought the time to process the list down about 90%) - ~30 seconds to do the first run for 32K files (compared to the MySQL times of ~30 seconds to do all the runs, it is quite a bit slower, though 'acceptable'.) I'm wondering about holding 'all that' data (perhaps it isn't much in today's world of multi-gig memory??) in arrays when there is 5X that. I've not run into any problems with my 'small' list, but I am doing a 'safety save' of the data in the middle of processing to make sure we have the changes, then reading it back to a clean array (in a slightly different, smaller manner - that could easily be taken care of in memory) before going on with the re-work part of the program to make sure the larger data sets are as protected as possible (of course, the customer will let me know if things crash!). Any tips on how 'best' to handle things are much appreciated. (and, sorry for swinging the topic a bit, though I believe the original question is answered)
    1 point
  21. I am late to the party I see. This is my favourite subject in AutoIt.
    1 point
  22. onlinethlive, I recommend the Variables - using Global, Local, Static and ByRef tutorial in the Wiki - I wrote it to answer the very question you are asking. TechCoder, Your summary is pretty close to the truth - well done if you worked all that out empirically. M23
    1 point
  23. also being new to autoit, I, too, am having challenges understanding what these are/do, though I have found the best teacher to be experience in this matter (I read all the materials and still was left with questions. So, I went into the SciTE editor, copied over some files from the Help and ran them, changing Dim, Local and Global around a bit to see the difference. Most of the time, there isn't much difference you can see, but after writing my own program and putting all of these to 'Global' (I had thought, why not, "Global" sounds good - I can use them anywhere and not have to mess with all this again!") - well, let's just say that setting everything to Global is NOT a good idea! So, what is the right idea? When do you use which one? Again, I'm no expert, but here is how I am currently seeing these work: Global - use when you really (and I mean 'really') need to have a variable available anywhere in your code. Sparingly is a good thing to think about here. I don't know why, but using it all the time does cause problems, so I use it now on just a few things that I have to have and it works better. Local - use this "all the time" - it is good for things you need to declare for something 'small', like something you use in a function. My current thinking (as/until I learn more) is to write my programs with Local on all variables then 'see what happens' and when an error shows up on that variable, I try Global. Most of the time now (after just a few programs) I am learning how/why/when Global should be used, but still I fall back to this as a first step. Dim - well, so far, I haven't had to use it so I don't know much about it (and I'm well into my 5th autoit program and in this one I have nearly 3000 lines of code). I'd say it isn't as required as the others, though I'm sure it has valuable reason for being. I have used ReDim quite a bit, which resets the size of arrays. That is a 'newbie' look at these commands. Like all, though, the more you program and practice, the more likely you will NEED one of them - that is when you really learn about them (i.e., my recommendation is to get out of the books and into a PROJECT of some sort - makes you dig in a different way.)
    1 point
  24. Look up one of these keyword in the help file and read on.
    1 point
  25. I think you are not understanding what is being suggested. Write script 1, then use FileInstall to include it in script 2, as has been suggested: FileInstall("C:\Script2.au3", @TempDir & "\Script2.au3") Then call that script1 with the syntax jdelaney gave you in post 12. Whole lot easier than writing the thing on the fly.
    1 point
×
×
  • Create New...