iagman Posted April 2, 2009 Share Posted April 2, 2009 Horns of a dilemma. Also, the fangs of frustration, not to mention the claws of confusion. I want to open the windows calculator from a button on my dialog box. I want the calculator to open positioned side-by-side with my dialog box. Both are the same pixel height and it looks cool when they are joined. This is my code: Case $msg = $WindowsCalculatorLaunchButton ;Button: Launch Windows Calculator $CkCalcOpen = WinExists ( "Calculator") if $CkCalcOpen = 1 Then MsgBox(0, "Notice", "Calculator is already open") Else $cPOS = WinGetPos($StockCalcPos) ;Get position of GUI Run ( "calc.exe", "", @SW_HIDE) WinWait ( "[CLASS:SciCalc]", "") WinMove ("[CLASS:SciCalc]", "", $cPOS[0] + $cPOS[2], $cPOS[1] ) ;WinSetState ( "[CLASS:SciCalc]", "", @SW_SHOW ) EndIf ; The WinSetState line above is commented out. It doesn't seem to have any effect one way or another. Apparently, the default location when the calculator opens is in the upper left side of screen. In the above code, I tried to have the calculator hidden when opened, then move it to my desired position before showing it. But, the code doesnt work that way. The calculator opens (not hidden) momentarily in the upper right corner of screen, then quickly snaps to my desired location. This looks rather amateurish. I have tried various other commands and ways of arranging the code, but so far I cannot keep the calculator from first appearing in its default location even if it is just a fraction of a second. Thus my dilemma. iagman Link to comment Share on other sites More sharing options...
Valuater Posted April 2, 2009 Share Posted April 2, 2009 Ahhh.... Fast but not perfect... FileDelete(@ScriptDir & "\Mover.au3") $StockCalcPos = GUICreate("HOLD_ON", Default, Default, 100, 100) GUISetState() Mover("HOLD_ON") Sleep(2000); give it a sec Run("calc.exe") Sleep(56000) Func Mover($GUI) Local $file_loc = @ScriptDir & "\Mover.au3" $a = "" $a &= 'While 1' & @CRLF $a &= '$cPOS = WinGetPos("' & $GUI & '") ;Get position of GUI ' & @CRLF $a &= 'If IsArray($cPOS) Then' & @CRLF $a &= '$Move = WinMove ("Calculator", "", $cPOS[0] + $cPOS[2], $cPOS[1] )' & @CRLF $a &= 'If $Move = 1 then exit' & @CRLF ;$a &= 'Sleep(1)' & @CRLF $a &= 'EndIf' & @CRLF $a &= 'WEnd' & @CRLF FileWrite($file_loc, $a) If @Compiled = 1 Then $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"') Run($file_exe) Else $file_au3 = FileGetShortName($file_loc) Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE) EndIf EndFunc ;==>Mover 8) Link to comment Share on other sites More sharing options...
iagman Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks for your code. That is what mine was doing; displaying the calculator in it's default location briefly, and then moving to the location determined by the code. I was hoping there was a way to keep the calculator hidden until it was relocated. Then it would appear positioned properly. Maybe a DLL finagle of some sort. Is DLL pronounced "dill" as in pickle? iagman Link to comment Share on other sites More sharing options...
martin Posted April 3, 2009 Share Posted April 3, 2009 Thanks for your code. That is what mine was doing; displaying the calculator in it's default location briefly, and then moving to the location determined by the code.I was hoping there was a way to keep the calculator hidden until it was relocated. Then it would appear positioned properly.Maybe a DLL finagle of some sort. Is DLL pronounced "dill" as in pickle?iagmanI can't help with the calulator window, but I've always pronounced "dll" as de-el-el. Since I don't use the word in converstion it hasn't worried me wether I'm right or wrong, but since you asked I looked here. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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