Byte11

Maximize Sometimes Doesn't Work

2 posts in this topic

#1 ·  Posted (edited)

WinSetState ("[CLASS:OpusApp]", "", @SW_SHOWMAXIMIZED) and WinSetState ("[CLASS:OpusApp]", "", @SW_MAXIMIZE) don't maximize the window.  Using WinSetState("[CLASS:OpusApp]","",@SW_RESTORE) allows me to maximize it about 15% of the time. I've tried using  WinMove("[active]",0,0,@Desktopwidth,@Desktopheight), but that only makes it worse. I've also tried putting in a sleep and maximizing it again. Does anyone have a solution?

Here's my code:

Quote

#include <Misc.au3>

;Startup Script
;Run("C:\hifuase\falhseiu\feashilu\fesahliu\fesaihlulfaheui\fewalihuaflheui\grdlihjnuslgr\ferswahiuhoiuafe\greyhugfral.docx")
;WinWait(".docx", "")
;WinSetState (".docx", "", @SW_HIDE)

;Keypress Script
Local $i = 0

While $i = 0
   if _IsPressed(11) then
      if _IsPressed(10) then
         if _IsPressed(22) then
            if Not StringInStr(WinGetTitle("[active]"), ".docx") = 0 then
               ;SplashTextOn("Title", "Message goes here.")
               WinSetState ("[active]", "", @SW_HIDE)
            Else
               send("#d")
               WinSetState ("[CLASS:OpusApp]", "", @SW_SHOWMAXIMIZED)
               WinSetState("[CLASS:OpusApp]","",@SW_RESTORE)
               WinSetState ("[CLASS:OpusApp]", "", @SW_SHOWMAXIMIZED)
            EndIf
         EndIf
      EndIf

   EndIf
WEnd

The startup script is intentionally commented, because I'm not testing it right now. The other comment is just for debugging when I need it. 

 

UPDATE: When I run two instances of the program, it works almost all the time, but if I copy the code inside the else statement twice it doesn't work at all (despite the fact that it's running the same code just in one program vs two). I also noticed that when I run two instances of it, about 50% of the time when it opens both the windows, it also hits the windows button and types the letter d into the search box. Neither of these actions are in my code. I'm not really sure what's going on. 

Edited by Byte11

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Changed the application to test and it worked everytime, also used only one "hotkey" for simplicity.

#include <Misc.au3>

;Startup Script
;Run("C:\hifuase\falhseiu\feashilu\fesahliu\fesaihlulfaheui\fewalihuaflheui\grdlihjnuslgr\ferswahiuhoiuafe\greyhugfral.docx")
;WinWait(".docx", "")
;WinSetState (".docx", "", @SW_HIDE)

;Keypress Script
Local $i = 0

While $i = 0
   ;if _IsPressed(11) then
      ;if _IsPressed(10) then
         if _IsPressed(22) then
            if StringInStr(WinGetTitle("[active]"), "Photo Viewer") <> 0 then
                WinSetState ("[active]", "", @SW_MINIMIZE)
                WinSetState ("[CLASS:classFoxitReader]", "", @SW_MAXIMIZE)
            EndIf
         EndIf
      ;EndIf
   ;EndIf
WEnd

If the idea is to, at the press of some keys, while a certain window is active, to minimize the active window and to maximize another window, this works for me.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • distancesprinter
      By distancesprinter
      _ArrayDisplay($aArray, "Window Title", "1:", 0, Default, "Column") ; Expected results are rows 1 to the end of the array, all columns. The result is rows 0-1, all columns. The API reference is here:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm
       
      Am I doing something wrong?
    • imitto
      By imitto
      Hi!
      I just playing around with _ArrayMin for my next project, but seems like it's not working. I think the code is OK, but I always get the value of $aArray[2][1], not col 2's lowest value (see attached image)

    • nss
      By nss
      Hi all.
       
      Because of me wondering if I could access the key/value pair arrays with the numbers as indexes, I have found out that the zeroth element for some reason doesn't return anything.
      Here's the example:
       
      local $r[2] $r["test1"]="hello" $r["test2"]="how are you" msgbox(64, $r[0], $r[1]) ; prints the ["test2"] but not ["test1"]. Is this even supposed to be a thing?  
       
      BTW, I haven't seen Autoit get updated since 2015; is it abandened or something?
      Any help/clarification appreciated.
    • TheDcoder
      By TheDcoder
      Hello everyone, I discovered a bug yesterday and I posted it at the bug tracker:
      I also made a simple script which can be used to reproduce the bug:
      CreateVariable() ConsoleWrite($sGlobalVariable & @CRLF) Func CreateVariable() Global $sGlobalVariable = "Foobar" EndFunc The bug was closed by @BrewManNH:
      While I partially agree with the above statement, My code was not practical enough... so @mLipok advised me to create a thread on the forums with practical code (Thanks!). That is the point of this thread, I am going to provide the code where I experience this bug/problem .
      I discovered this bug when I was working on one of my projects called "ProxAllium". When the main script finishes execution, Au3Check throws a nasty warning about "variable possibly used before declaration":

      As you can see, the variable is indeed being used after calling the function in which the variable is declared... The warning won't appear if I declare the function ABOVE the variable. As @BrewManNH said, Au3Check reads line by line... I think this should be changed, Au3Check should not throw warnings if the interpreter is able to run the code, at least most of the time anyway!
      So what do you guys think? Is this a valid bug?... and I request those who participate in the discussion not to discuss the code being "poor", that is another thing/thread in itself
      P.S I had already written this once but the forum editor decided to mess up and when I undid (Ctrl + Z) something... This is a poorly written version of that article, I was very frustrated while writing this!
    • WoodGrain
      By WoodGrain
      Hi All,
      Could someone please PLEASE tell me what I'm doing wrong here?
      I feel like I'm close to figuring this out, I think I've identified what is causing the issue.
      Whenever I try to use the hotkey CTRL+SHIFT+T (or any other letter other than T for that matter) to paste the text to notepad, my CTRL and SHIFT keys are held down *IF* I release them *WHILE* the raw text is being written.
      It seems to be that if I release the CTRL+SHIFT keys:
      Before the Send Raw text starts to write to the screen: the CTRL and SHIFT keys ARE NOT held down, this is good During the Send Raw text being written to the screen: the CTRL and SHIFT keys ARE held down perpetually until I physically press them on the keyboard, this is bad After the Send Raw text has written all text to the screen: the CTRL and SHIFT keys ARE NOT held down, this is good This is also the case if I were to use the Windows Key as the hot key instead of the CTRL+SHIFT, I would need to tap the WIN key physically on my keyboard if I released it while the raw tet was being sent to the screen (eg, WIN+T).
      This issue also happens no matter which program I try to write the text to.
      Here's some example code:
      (I've put a bunch of "a's" in there to give enough time to test releasing the CTRL+SHIFT before/during/after the writing of them)
      HotKeySet("^+t", "WriteTxt") Func WriteTxt() WinWaitActive("Untitled - Notepad") $var = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" send($var, 1) EndFunc While 1 Sleep(500) WEnd Thanks guys!