Leaderboard
Popular Content
Showing content with the highest reputation on 02/01/2015 in all areas
-
Here is czardas example modified to get out with hotkey or pressing the button again. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_bGetOut = False ; Declare a global Flag. HotKeySet("{F2}", "GetOut") ; Set a hotkey to call a function. #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Test", 146, 66, 268, 198) Global $Checkbox1 = GUICtrlCreateCheckbox("Test", 32, 8, 97, 17) Global $Button1 = GUICtrlCreateButton("Write", 32, 32, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $App = "Untitled - Notepad" WinWait($App) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Write() EndSwitch WEnd Func _Write() $Timer = TimerInit() While GUIGetMsg() <> $Button1 If TimerDiff($Timer) >= 1000 Then ControlSend($App, "", "Edit1", "{5}") $Timer = TimerInit() EndIf If $g_bGetOut Then ExitLoop ; Check if the flag was altered. WEnd $g_bGetOut = False ; Reset the flag in case you need to get out again later. EndFunc ;==>_Write Func GetOut() $g_bGetOut = True ; Set the trigger. EndFunc ;==>GetOut2 points
-
Here is a little tutorial I decided to make. (yes another tutorial) It is intended for people with absolutely no knowledge of programming/scripting at all. It also assumes you do not know how to use autoit3 help file. What it does assume, is that you have installed autoit3 and scite4autoit which can be found here Autoit > Scite4autoit The most important thing to know, is how to navigate and use the helpfile Please do not underestimate how valuable this resource is. By default the help file is located in your myprograms or myprogramsx86 of you OS drive in the folder AutoIt3 It looks like this with the ? on it, click it Once the helpfile loads you will see essentially two panels, the one on the left is about navigation The one on the right is about information, and for now, just focus on the index tab and click it to see something like this in the left panel Notice it says "Type in the keyword to find", this is where we can find what we are looking for. For example, if I want to find a string function, or browse all the string functions, I simply type "string" into the field below the prompt, and it navigates automatically to the items in the index, like so. If you highlight one of the items in the list and hit enter, or double click on an item, it will bring up information about that item in the right side panel, like so. Above I clicked on the String function and it shows me everything i need to know about that function. Firstly, it tells me in essence what it does. "Returns the string representation of an expression." Secondly, it shows me how to enter the function into scite editor "String ( expression )" In the scope of this post, the expession here is the paramater we pass to the function for processing. A paramater is any variable or literal we put inside the braces of a function. It also tells me the return value - "Returns a string." - a string it what is between those two quotes (text if you will) So what is a return value? Its what the function pumps out after you pass it the correct paramaters, you can test it in the example at the bottom of the right panel. But not before you take a look at another important part of the information, The remarks. "Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)" Here its telling us that if we put a string of over 4095 characters on one line in our script, it will fail. Never skip the remarks, it will cost you valuable time and cause you headaches. Every time you are going to use a function, you should have that function open in the helpfile and refer to it every step of the way. All the information in that panel is important, read it all, and then, notice the little button at the bottom of the example entitled "Open this Script", press that, and the script will automagically open in your scite4autoit editor, and is ready to run, by hitting the F5 key Q. What is a variable? A. $this_is_a_variable = "this is a literal string"; A variable will always have the $ at the beginning and never have a space in it (those are rules) Look at the example $var = String(10) ;$var is the string "10" ;$var is the variable here, and 10 is a literal paramater passed to the String function. Lets take the String function out of the equasion and consider this statement (in the scope of this post a statement is information you type into scite which is telling autoit3 something it needs to know) $var = 10 Here the variable $var is now equal to the literal value 10, it is named a variable because it can change its value. $var = $var + 1 $var is now equal to 11, 10 however, will always be 10. Lets have a look at another function, you remember how to find what we need in the helpfile? then find FileRead. Heres what it tells us. Read in a number of characters from a previously opened text file. This means it will read into the variable it is assigned, (think $var) the amount of individual characters we want from a file that autoit3 has already opened. FileRead ( "filehandle/filename" [, count] ) This is like a prototype of the function we will enter into our editor, notice the bracets "[" and "]" they are telling us that this paramater is optional! more below. Parameters filehandle/filename - The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter. Forget filehandle for now, filename here is the path to the file we want to read from, for example "c:usersscriptsmyfile.txt" count - [optional] The number of characters to read. Default read the entire file. Its quite common for beginners to misunderstand these [ and ], you dont type them literally into your script, they are just to let you know that you can completely leave out that paramater if you do not need it. In this case, if you want to read the whole file into your variable ($var) you would leave out everything between and including those bracets. If you do need it you would remove the bracets and enter your paramater. Return Value Success: Returns the binary/string read. @extended is set to the number of bytes/characters returned. This tells us the function will return a string if we gave it a filename as a paramater, since we are reading the file, the string will be the contents of the file. Special: Sets @error to -1 if end-of-file is reached. @error information tells us information about why the call to a function may have failed. It is important to check the @error state after each function you use. Failure: Sets @error to 1 if file not opened in read mode or other error. Looking at the example usually shows you how to check for errors. Remarks If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles. Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both! Both ANSI and UTF16/UTF8 text formats can be read - AutoIt will automatically determine the type. A file can be read as binary(byte) data by using FileOpen with the binary flag - in this case count is in bytes rather than characters. There are plenty of good tutorials on this forum created by various members, which is why it is important to know how to search the forums. But hang on, this tutorial is about how to use the helpfile, so cast your mind way back to when we learnt how to find what we need It was typing it into the index tab prompt field, so type "tutorial" into that, and you will find basic tuts in their also.1 point
-
Need to pop back in here after reading some article, it is possible for website to get your local IP address, even if you are behind a NAT router or even if you are using VPN supposedly. Using WebRTC and STUN. This site correctly identified My public IP and my local, (behind router) IP https://diafygi.github.io/webrtc-ips/1 point
-
That's really a nice modification, I think ask at forum is better than learning myself with the bot.1 point
-
$WS_EX_MDICHILD bug
TheAutomator reacted to SmOke_N for a topic
I wrote this 7+ years ago, it doesn't use the _WinAPI* functions (which is easy enough to implement), but is this what you're looking to do? Because I believe class names have changed for the explorer windows, try this revised example to see if it's the effect you want. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $ghGUI = GUICreate("MyExplorer", 1200, 500, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN)) Global $goShell1 = _createNewExplorerWindow() Global $goShell2 = _createNewExplorerWindow() Global $ghExp1 = _WinEmbedToGUI(HWnd($goShell1.hwnd), $ghGUI, 600, 0, 600, 500) Global $ghExp2 = _WinEmbedToGUI(HWnd($goShell2.hwnd), $ghGUI, 0, 0, 600, 500) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $ghGUI) WinClose($ghExp1) WinClose($ghExp2) Exit EndSwitch WEnd Func _createNewExplorerWindow() Local $oShell = ObjCreate("Shell.Application") Local $oWin1 = $oShell.windows(), $oWin2 Local $nCount = $oWin1.count() $oShell.Explore("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") Do Sleep(50) $oWin2 = $oShell.windows() Until $nCount <> $oWin2.count() Return $oWin2($oWin2.count() - 1) EndFunc Func _WinEmbedToGUI($hWnd, $hGUI, $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI, $nStyle = -2, $nExStyle = -2) Local $nExStyleEx = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20) If IsArray($nExStyleEx) = 0 Then Return SetError(1, 0, 0) DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOr($nExStyleEx[0], 0x00000040));WS_EX_MDICHILD DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI) WinSetState($hWnd, '', @SW_SHOW) WinMove($hWnd, "", $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI) If $nStyle = -2 And $nExStyle = -2 Then Return $hWnd Local $GWL_STYLE = -16, $GWL_EXSTYLE = -20 Local $SWP_NOMOVE = 0x2, $SWP_NOSIZE = 0x1 Local $SWP_SHOWWINDOW = 0x40, $SWP_NOZORDER = 0x4 Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) If $nStyle = -2 Then $nStyle = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU If $nExStyle = -2 Then $nExStyle = $nExStyleEx[0] DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $nStyle) DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $nExStyle) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _ "int", 0, "int", 0, "int", $iFlags) Return $hWnd EndFunc Edit: With _WinAPI function rather than straight dllcalls (I removed the WinSetState() as well, no idea why I had that there though.): #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $ghGUI = GUICreate("MyExplorer", 1200, 500, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN)) Global $goShell1 = _createNewExplorerWindow() Global $goShell2 = _createNewExplorerWindow() Global $ghExp1 = _Win_EmbedToHwnd(HWnd($goShell1.hwnd), $ghGUI, 600, 0, 600, 500) Global $ghExp2 = _Win_EmbedToHwnd(HWnd($goShell2.hwnd), $ghGUI, 0, 0, 600, 500) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $ghGUI) WinClose($ghExp1) WinClose($ghExp2) Exit EndSwitch WEnd Func _createNewExplorerWindow() Local $oShell = ObjCreate("Shell.Application") Local $oWin1 = $oShell.windows(), $oWin2 Local $nCount = $oWin1.count() $oShell.Explore("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") Do Sleep(10) $oWin2 = $oShell.windows() Until $nCount <> $oWin2.count() Return $oWin2($oWin2.count() - 1) EndFunc Func _Win_EmbedToHwnd($hChild, $hParent, $nLeftParent, $nTopParent, $nRightParent, _ $nBottomParent, $iStyle = Default, $iExStyle = Default) Local Const $GWL_STYLE = -16, $GWL_EXSTYLE = -20 Local Const $SWP_NOSIZE = 0x01, $SWP_NOMOVE = 0x02 Local Const $SWP_NOZORDER = 0x04, $SWP_SHOWWINDOW = 0x40 Local Const $WS_EX_MDICHILD = 0x00000040 Local $iLongEx = _WinAPI_GetWindowLong($hChild, $GWL_EXSTYLE) If @error Then Return SetError(1, 0, 0) EndIf $iStyle = ((IsKeyword($iStyle) Or $iStyle < 0) ? _ BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) : $iStyle) $iExStyle = ((IsKeyword($iExStyle) Or $iExStyle < 0) ? $iLongEx : $iExStyle) Local Const $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) ; set to mdi child _WinAPI_SetWindowLong($hChild, $GWL_EXSTYLE, BitOr($iLongEx, $WS_EX_MDICHILD)) _WinAPI_SetParent($hChild, $hParent) WinMove($hChild, "", $nLeftParent, $nTopParent, $nRightParent, $nBottomParent) _WinAPI_SetWindowLong($hChild, $GWL_STYLE, $iStyle) _WinAPI_SetWindowLong($hChild, $GWL_EXSTYLE, $iExStyle) _WinAPI_SetWindowPos($hChild, 0, 0, 0, 0, 0, $iFlags) _WinAPI_SetFocus($hParent) Return $hChild EndFunc1 point