c7aesa7r Posted April 7, 2019 Share Posted April 7, 2019 (edited) $key = "{a}" $hwd = '0x001C1000' $hwd2 = WinGetHandle("[CLASS:TFormMain]") consolewrite("hwd = " & $hwd & @CR ) consolewrite("hwd2 = " & $hwd2 & @CR) ControlSend($hwd,"","",$key) ControlSend($hwd2,"","",$key) In the script above when i use ControlSend with handle (hw2) stored by WinGetHandle it work perfectly, and when i use ControlSend with the handle (hwd) stored in a variable it never works. Don't want be rude, but im not looking for alternative ways to my script, i would like just understand why with hwd2 it works and hwd don't. Edited April 7, 2019 by c7aesa7r Link to comment Share on other sites More sharing options...
Exit Posted April 7, 2019 Share Posted April 7, 2019 hwd is a string, not a handle hwd2 is a handle Thy this: $h1 = WinGetHandle("[active]") $h2 = '0x000504C8' ConsoleWrite(IsHWnd($h1) & @CRLF) ConsoleWrite(IsHWnd($h2) & @CRLF) ConsoleWrite($h1=$h2 & @CRLF) ConsoleWrite("" & @CRLF) consoloutput is: --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 1 0 False +>13:43:14 AutoIt3.exe ended.rc:0 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Nine Posted April 7, 2019 Share Posted April 7, 2019 Use this to actually create a handle (with or without ' or ") $hwd = HWnd (0x001C1000) memerim 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
c7aesa7r Posted April 7, 2019 Author Share Posted April 7, 2019 (edited) 8 hours ago, Nine said: Use this to actually create a handle (with or without ' or ") $hwd = HWnd (0x001C1000) 😸Gracias. @Nine how can i call a value stored in var? I tried execute,call.😳😳 I mean when $var be = 1 Then $x = carlos, $var be = 2 ,$ x = etc $var = 0 $x = 0 If $var = 1 Then $x = carlos If $var = 2 Then $x = bea If $var = 3 Then $x = thaynara If $var = 4 Then $x = pedro While 1 $var = $var + 1 Execute($var) ConsoleWrite($x & @LF) WEnd Edited April 7, 2019 by c7aesa7r Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 7, 2019 Share Posted April 7, 2019 @c7aesa7r Use Switch statement instead of If, and use the equal operator to assign a value to your variables. Maybe you should read this post Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
c7aesa7r Posted April 7, 2019 Author Share Posted April 7, 2019 (edited) @FrancescoDiMuro i have read the link you post, but im still dont understand how do it, i also look in help for switch $var = 0 $x = 0 Switch $var Case $var = 1 $x = 1 Case $var = 2 $x = 2 Case $var = 3 $x = 3 Case $var = 4 $x = 4 EndSwitch While 1 $var = $var + 1 ConsoleWrite("var = " & $var & @LF) ConsoleWrite("x = " & $x & @LF) sleep(500) If $var = 5 Then $var = 0 WEnd I also tried: $var = 0 $x = 0 While 1 $var = $var + 1 If $var = 1 Then $x = "carlos" If $var = 2 Then $x = "bea" If $var = 3 Then $x = "thaynara" If $var = 4 Then $x = "pedro" If $var = 5 Then ExitLoop WEnd While 1 $var = $var + 1 ConsoleWrite($x & @LF) sleep(500) If $var = 5 Then $var = 0 WEnd Im trying $x have value according to actual $var number Edited April 7, 2019 by c7aesa7r Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 7, 2019 Share Posted April 7, 2019 @c7aesa7r In the first script, you assign to $var the value of 0, then Switch it from 1 to 4 pretending to have some output, then you enter in an infinite loop which increments $var from 0 to 5, and resets it continuously when it reaches the value of 5, always printing $x = 0. In the second script, you have a loop that stops as soon as $var reaches 5, but to the variable $x is assigned always the last value before exiting the loop ($var = 4), then you enter again in an infinite while loop where you continuously increment $var until it's resetted to 0 when it reaches the value of 5. 27 minutes ago, c7aesa7r said: WEnd Im trying $x have value according to actual $var number Then use Switch statement in an appropriate way, as it is showed in the Help file, and design a little bit of logic before write the script. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
c7aesa7r Posted April 7, 2019 Author Share Posted April 7, 2019 (edited) -Edit- I did it, nothing with "Switch" @FrancescoDiMuro thank you for your 'precious' help, i dont know why people come in others post with no intention to help and only say go "look help file". $var = 0 $x = 0 While 1 $var = $var + 1 Call("Sel") ConsoleWrite("var = " & $var & @LF) ConsoleWrite("x = " & $x & @LF) ConsoleWrite(" " & @LF) sleep(2000) If $var = 5 Then $var = 0 WEnd Func Sel() Select Case $var = 1 $x = 1 Case $var = 2 $x = 2 Case $var = 3 $x = 3 Case $var = 4 $x = 4 EndSelect EndFunc Edited April 7, 2019 by c7aesa7r Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 8, 2019 Share Posted April 8, 2019 (edited) 7 hours ago, c7aesa7r said: i dont know why people come in others post with no intention to help and only say go "look help file". That's because the Help file is the very first resource of Help from which you can see in details how to use a function, thanks for the example(s) included. Why everyone should even waste his/her time to explain something that is already explained in details somewhere else? Lazyness? Edited April 8, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
jdelaney Posted April 9, 2019 Share Posted April 9, 2019 you can also convert a string to handle via HWND function. That's what I use to pass handles between scripts in command line execs. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now