Jump to content

2 Different Keystrokes 1 Script


Recommended Posts

hi,

i got a really easy question for you guys:

how can i put 2 different key-combinations together in one script so that they will be executed alternately?

i want my desktop to be turnt by 90° using Send("^!{LEFT}") and then if i run the script for the second time to undo the turn by turning my dektop another 90° in the opposite direction using Send("^!{UP}"). so i know the two commands to turn the desktop, but i have no idea how to connect them in one script.

please help me =)

Link to comment
Share on other sites

hmm, i have a convertible netbook... when i need this script, my keyboard is usually covered by the screen. so hotkeys are not really better tha hitting the combination.

i wanted to compile the script to .exe and deposit this file somwhere on the desktop where i can klick it with the stylus. at the moment i always have to lift the screen a bit to hit the combination. it would be an improvement to have two .exe files to rotate the desktop (which is that easy that i can do it myself ;P) but there has to be a possibility to get it into one, no?

Link to comment
Share on other sites

Gui maybe?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Gui = GUICreate('',180,60,@DesktopWidth -184, @DesktopHeight -120)
$b1 = GUICtrlCreateButton('Tilt /L',0,0,88,60)
$b2 = GUICtrlCreateButton('Tilt /B',88,0,88,60)
GUISetState(@SW_SHOW)
WinSetOnTop($Gui,'',1)
While 1
    $msg = GUIGetMsg()
    if $msg = $b1 Then
        TiltLeft()
    endif
        if $msg = $b2 Then
        TiltBack()
    endif
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
WEnd

Func TiltLeft()
    Send("^!{Left}")
EndFunc

Func TiltBack()
    Send("^!{UP}")
EndFunc
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

ok does work thank you =D

it's not what i expected, but nevertheless very useful. im wondering whether there is really no easier solution than creating GUI ?! something like a icon which tilts the desktop and sets a variable. and if i run the script the sencond time the variable causes another rotation.

Edited by justalittlequestion
Link to comment
Share on other sites

ok does work thank you =D

it's not what i expected, but nevertheless very useful. im wondering whether there is really no easier solution than creating GUI ?! something like a icon which tilts the desktop and sets a variable. and if i run the script the sencond time the variable causes another rotation.

I assume that when the desktop is rotated the desktop dimensions are changed so then you could just have

If @DesktopWidth > @DesktopHeight Then
    TiltLeft()
Else
    TiltBack()
EndIf


Func TiltLeft()
    Send("^!{Left}")
EndFunc

Func TiltBack()
    Send("^!{UP}")
EndFunc
Edited by martin
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

I assume that when the desktop is rotated the desktop dimensions are changed so then you could just have

If @DesktopWidth > @DesktopHeight Then
    TiltLeft()
Else
    TiltBack()
EndIf


Func TiltLeft()
    Send("^!{Left}")
EndFunc

Func TiltBack()
    Send("^!{UP}")
EndFunc

LOL you know I was going to do that but i couldnt find the ChangeResolution.Au3 UDF? Is there a new version out?
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

LOL you know I was going to do that but i couldnt find the ChangeResolution.Au3 UDF? Is there a new version out?

Well I was assuming Turnleft meant rotate 90 degrees like on a phone say or on monitors which can be used in portrait or landscape. If it means 180 degrees then it's no help at all, so you could have a little ini file

$inifile = @AppDataDir & "\ScreenBits\Rotation.ini"

If IniRead($iniFile,"Screen","Rotation","Back") = "Back" then
 TiltLeft()
Else
 TiltBack()
EndIf


Func TiltLeft()
 Send("^!{Left}")
 IniWrite($iniFile,"Screen","Rotation","Left")
EndFunc

Func TiltBack()
 Send("^!{UP}")
 IniWrite($iniFile,"Screen","Rotation","Back")
EndFunc

EDIT: Um, I see the OP did specify 90 degrees, so what was wrong with my first attempt?

Edited by martin
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

I assume that when the desktop is rotated the desktop dimensions are changed so then you could just have

If @DesktopWidth > @DesktopHeight Then
    TiltLeft()
Else
    TiltBack()
EndIf


Func TiltLeft()
    Send("^!{Left}")
EndFunc

Func TiltBack()
    Send("^!{UP}")
EndFunc

you are a genius! that's exactly what i was looking for.

thank you both very much.

EDIT: nothing was wrong with your first attempt. i just posted a bit too late ;P

Edited by justalittlequestion
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...